Commit 945d8dd 1 parent ebfbe58 commit 945d8dd Copy full SHA for 945d8dd
File tree 3 files changed +39
-9
lines changed
tests/language-feature/modules/typealias
3 files changed +39
-9
lines changed Original file line number Diff line number Diff line change @@ -5953,22 +5953,25 @@ ForStmt* Parser::ParseForStatement()
5953
5953
FillPosition (stmt);
5954
5954
ReadToken (" for" );
5955
5955
ReadToken (TokenType::LParent);
5956
- auto modifiers = ParseModifiers (this );
5957
- if (peekTypeName (this ) || !modifiers.isEmpty ())
5958
- {
5959
- stmt->initialStatement = parseVarDeclrStatement (modifiers);
5960
- }
5961
- else
5956
+ if (!LookAheadToken (TokenType::Semicolon))
5962
5957
{
5963
- if (!LookAheadToken (TokenType::Semicolon))
5958
+ stmt->initialStatement = ParseStatement ();
5959
+ if (as<DeclStmt>(stmt->initialStatement ) || as<ExpressionStmt>(stmt->initialStatement ))
5964
5960
{
5965
- stmt-> initialStatement = ParseExpressionStatement ();
5961
+ // These are the only allowed form of initial statements of a for loop.
5966
5962
}
5967
5963
else
5968
5964
{
5969
- ReadToken (TokenType::Semicolon);
5965
+ sink->diagnose (
5966
+ stmt->initialStatement ->loc ,
5967
+ Diagnostics::unexpectedTokenExpectedTokenType,
5968
+ " expression" );
5970
5969
}
5971
5970
}
5971
+ else
5972
+ {
5973
+ ReadToken (TokenType::Semicolon);
5974
+ }
5972
5975
if (!LookAheadToken (TokenType::Semicolon))
5973
5976
stmt->predicateExpression = ParseExpression ();
5974
5977
ReadToken (TokenType::Semicolon);
Original file line number Diff line number Diff line change
1
+ //TEST_IGNORE_FILE:
2
+
3
+ typealias i32 = int32_t;
Original file line number Diff line number Diff line change
1
+ //TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -output-using-type
2
+
3
+ // Regression test for bug https://github.com/shader-slang/slang/issues/5808
4
+
5
+ // Using a type defined from a different module
6
+ // in a for loop should work.
7
+
8
+ import lib;
9
+
10
+ //TEST_INPUT:set output = out ubuffer(data=[0 0 0 0], stride=4)
11
+ RWStructuredBuffer<i32> output;
12
+
13
+ [numthreads(1,1,1)]
14
+ void computeMain()
15
+ {
16
+ // CHECK: 0
17
+ // CHECK: 1
18
+ // CHECK: 2
19
+ // CHECK: 3
20
+ for (i32 i = 0; i < 4; i++)
21
+ {
22
+ output[i] = i;
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments