Skip to content

Commit f2931ef

Browse files
committed
add tests
1 parent abbdb31 commit f2931ef

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name statement-expression.c %s
2+
3+
// No crash for the following examples, where GNU Statement Expression extension
4+
// could introduce region terminators (break, goto etc) before implicit
5+
// initializers in a struct or an array.
6+
// See https://github.com/llvm/llvm-project/pull/89564
7+
8+
struct Foo {
9+
int field1;
10+
int field2;
11+
};
12+
13+
void f1(void) {
14+
struct Foo foo = {
15+
.field1 = ({
16+
switch (0) {
17+
case 0:
18+
break; // A region terminator
19+
}
20+
0;
21+
}),
22+
// ImplicitValueInitExpr introduced here for .field2
23+
};
24+
}
25+
26+
void f2(void) {
27+
int arr[3] = {
28+
[0] = ({
29+
goto L0; // A region terminator
30+
L0:
31+
0;
32+
}),
33+
// ImplicitValueInitExpr introduced here for subscript [1]
34+
[2] = 0,
35+
};
36+
}

0 commit comments

Comments
 (0)