Skip to content
Next Next commit
Add test cases for variable definitions inside for-init and condition…
… statements

Interpreter/execute-stmts.cpp fails with:
```
i = 2
i = 5
i = 5
i = 5
j = 4
error: Parsing failed.
error: Parsing failed.

error: 'expected-error' diagnostics seen but not expected:
  Line 1: redefinition of 'i'
  Line 1: redefinition of 'i'
error: 'expected-note' diagnostics seen but not expected:
  Line 1: previous definition is here
  Line 1: previous definition is here
```
  • Loading branch information
weliveindetail committed Mar 6, 2024
commit 27ff0ddc0d736f4959abe61c9fd43b9c48ffb6a6
8 changes: 8 additions & 0 deletions clang/test/Interpreter/execute-stmts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
//CODEGEN-CHECK-COUNT-2: define internal void @__stmts__
//CODEGEN-CHECK-NOT: define internal void @__stmts__

// New tests fail right now
// XFAIL: *

extern "C" int printf(const char*,...);

Expand Down Expand Up @@ -41,3 +43,9 @@ for (; i > 4; --i) { printf("i = %d\n", i); };

int j = i; printf("j = %d\n", j);
// CHECK-NEXT: j = 4

if (int i = j) printf("i = %d\n", i);
// CHECK-NEXT: i = 4

for (int i = j; i > 3; --i) printf("i = %d\n", i);
// CHECK-NEXT: i = 4