xref: /llvm-project/clang/test/Parser/c2x-label.c (revision 9c4ade0623af842cda16e5c71b27fb794a3ff3db)
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 
test_label_in_func()4 void test_label_in_func() {
5     int x;
6 label1:
7     x = 1;
8 label2: label3: label4:
9 } // c17-warning {{label at end of compound statement is a C23 extension}} \
10      c2x-warning {{label at end of compound statement is incompatible with C standards before C23}}
11 
test_label_in_switch(int v)12 int test_label_in_switch(int v) {
13     switch (v) {
14     case 1:
15         return 1;
16     case 2:
17         return 2;
18     case 3: case 4: case 5:
19     } // c17-warning {{label at end of compound statement is a C23 extension}} \
20          c2x-warning {{label at end of compound statement is incompatible with C standards before C23}}
21 
22     switch (v) {
23     case 6:
24         return 6;
25     default:
26     } // c17-warning {{label at end of compound statement is a C23 extension}} \
27          c2x-warning {{label at end of compound statement is incompatible with C standards before C23}}
28 
29     return 0;
30 }
31