diff options
Diffstat (limited to 'tests/diagnostics')
| -rw-r--r-- | tests/diagnostics/comma-operator-warning-slang2026.slang | 19 | ||||
| -rw-r--r-- | tests/diagnostics/comma-operator-warning.slang | 24 |
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/diagnostics/comma-operator-warning-slang2026.slang b/tests/diagnostics/comma-operator-warning-slang2026.slang new file mode 100644 index 000000000..e91f540d4 --- /dev/null +++ b/tests/diagnostics/comma-operator-warning-slang2026.slang @@ -0,0 +1,19 @@ +//DIAGNOSTIC_TEST:SIMPLE: + +#language 2026 + +int testCommaOperatorInSlang2026() +{ + // In Slang 2026, this creates a tuple - should NOT generate a warning + let m = (1, 2, 3); + + // Test accessing tuple elements + let x = m._0; + let y = m._1; + let z = m._2; + + // Another tuple example - should NOT generate a warning + var t = (1.0f, 2.0f, 3.0f); + + return x + y + z; +}
\ No newline at end of file diff --git a/tests/diagnostics/comma-operator-warning.slang b/tests/diagnostics/comma-operator-warning.slang new file mode 100644 index 000000000..945cc792d --- /dev/null +++ b/tests/diagnostics/comma-operator-warning.slang @@ -0,0 +1,24 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): + +int testCommaOperator() +{ + // This should generate a warning - comma operator in variable initialization + // CHECK: ([[# @LINE+1]]): warning 41024: + float4 vColor = (0.f, 0.f, 0.f, 1.f); + + // This should NOT generate a warning - comma operator in for-loop side effect + for (int i = 0; i < 10; i++, vColor.x++) + { + } + + // This should generate a warning - comma operator in regular expression + // CHECK: ([[# @LINE+1]]): warning 41024: + int x = (1, 2, 3); + + // This should now generate a warning - comma operator in return statement + // CHECK: ([[# @LINE+2]]): warning 41024: + int a = 5; + return a *= 2, a + 1; +} + +void someFunction(int value) {}
\ No newline at end of file |
