xref: /llvm-project/clang/test/C/C23/n2508.c (revision 50c81128de8616117118564eff22cf508cba7848)
1 // RUN: %clang_cc1 -verify -std=c23 %s
2 // RUN: %clang_cc1 -verify=pedantic -std=c11 -pedantic %s
3 // RUN: %clang_cc1 -verify=compat -std=c23 -Wpre-c23-compat %s
4 
5 // expected-no-diagnostics
6 
7 /* WG14 N2508: yes
8  * Free positioning of labels inside compound statements
9  */
test(void)10 void test(void) {
11   {
12   inner:
13   } /* pedantic-warning {{label at end of compound statement is a C23 extension}}
14        compat-warning {{label at end of compound statement is incompatible with C standards before C23}}
15      */
16 
17   switch (1) {
18   case 1:
19   } /* pedantic-warning {{label at end of compound statement is a C23 extension}}
20        compat-warning {{label at end of compound statement is incompatible with C standards before C23}}
21      */
22 
23   {
24   multiple: labels: on: a: line:
25   } /* pedantic-warning {{label at end of compound statement is a C23 extension}}
26        compat-warning {{label at end of compound statement is incompatible with C standards before C23}}
27      */
28 
29 final:
30 } /* pedantic-warning {{label at end of compound statement is a C23 extension}}
31      compat-warning {{label at end of compound statement is incompatible with C standards before C23}}
32    */
33 
test_labels(void)34 void test_labels(void) {
35 label:
36   int i = 0; /* pedantic-warning {{label followed by a declaration is a C23 extension}}
37                 compat-warning {{label followed by a declaration is incompatible with C standards before C23}}
38               */
39 
40   switch (i) {
41   case 1:
42     _Static_assert(1, ""); /* pedantic-warning {{label followed by a declaration is a C23 extension}}
43                               compat-warning {{label followed by a declaration is incompatible with C standards before C23}}
44                             */
45   default:
46     _Static_assert(1, ""); /* pedantic-warning {{label followed by a declaration is a C23 extension}}
47                               compat-warning {{label followed by a declaration is incompatible with C standards before C23}}
48                             */
49   }
50 }
51