llvm-project
30 строк · 992.0 Байт
1// RUN: %clang_cc1 -fsyntax-only -std=c17 -Wc2x-compat -verify=c17 %s
2// RUN: %clang_cc1 -fsyntax-only -std=c2x -Wpre-c2x-compat -verify=c2x %s
3
4void test_label_in_func() {
5int x;
6label1:
7x = 1;
8label2: label3: label4:
9} // c17-warning {{label at end of compound statement is a C23 extension}} \
10c2x-warning {{label at end of compound statement is incompatible with C standards before C23}}
11
12int test_label_in_switch(int v) {
13switch (v) {
14case 1:
15return 1;
16case 2:
17return 2;
18case 3: case 4: case 5:
19} // c17-warning {{label at end of compound statement is a C23 extension}} \
20c2x-warning {{label at end of compound statement is incompatible with C standards before C23}}
21
22switch (v) {
23case 6:
24return 6;
25default:
26} // c17-warning {{label at end of compound statement is a C23 extension}} \
27c2x-warning {{label at end of compound statement is incompatible with C standards before C23}}
28
29return 0;
30}
31