51 lines · c
1// RUN: %clang_cc1 -verify -std=c23 %s2// RUN: %clang_cc1 -verify=pedantic -std=c11 -pedantic %s3// RUN: %clang_cc1 -verify=compat -std=c23 -Wpre-c23-compat %s4 5// expected-no-diagnostics6 7/* WG14 N2508: yes8 * Free positioning of labels inside compound statements9 */10void 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 29final: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 34void test_labels(void) {35label: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