File tree 2 files changed +15
-3
lines changed
2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -2378,6 +2378,18 @@ Expr* SemanticsExprVisitor::visitIndexExpr(IndexExpr* subscriptExpr)
2378
2378
IntegerConstantExpressionCoercionType::AnyInteger,
2379
2379
nullptr ,
2380
2380
ConstantFoldingKind::LinkTime);
2381
+
2382
+ // Validate that array size is greater than zero
2383
+ if (auto constElementCount = as<ConstantIntVal>(elementCount))
2384
+ {
2385
+ if (constElementCount->getValue () <= 0 )
2386
+ {
2387
+ getSink ()->diagnose (
2388
+ subscriptExpr->indexExprs [0 ],
2389
+ Diagnostics::invalidArraySize);
2390
+ return CreateErrorExpr (subscriptExpr);
2391
+ }
2392
+ }
2381
2393
}
2382
2394
else if (subscriptExpr->indexExprs .getCount () != 0 )
2383
2395
{
Original file line number Diff line number Diff line change 2
2
3
3
// Test that array size cannot be zero
4
4
5
- // TEST :SIMPLE:
5
+ // DIAGNOSTIC_TEST :SIMPLE(filecheck=CHECK) :
6
6
7
7
[numthreads(4 , 1 , 1 )]
8
8
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
9
9
{
10
10
bar();
11
11
}
12
-
13
- func bar() - > int [0 ]; // expected-error 30025 "array size must be larger than zero."
12
+ // CHECK: ([[# @LINE+1]]): error 30025
13
+ func bar() - > int [0 ];
You can’t perform that action at this time.
0 commit comments