40 lines · c
1// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic2 3// Test that we can parse declarations at global scope.4int v;5 6void func(void) {7 // Test that we can parse declarations within a compound statement.8 int a;9 {10 int b;11 }12 13 int z = ({ // expected-warning {{use of GNU statement expression extension}}14 // Test that we can parse declarations within a GNU statement expression.15 int w = 12;16 w;17 });18 19 // Test that we diagnose declarations where a statement is required.20 // See GH92775.21 if (1)22 int x; // expected-error {{expected expression}}23 for (;;)24 int c; // expected-error {{expected expression}}25 26 label:27 int y; // expected-warning {{label followed by a declaration is a C23 extension}}28 29 // Test that lookup works as expected.30 (void)a;31 (void)v;32 (void)z;33 (void)b; // expected-error {{use of undeclared identifier 'b'}}34 (void)w; // expected-error {{use of undeclared identifier 'w'}}35 (void)x; // expected-error {{use of undeclared identifier 'x'}}36 (void)c; // expected-error {{use of undeclared identifier 'c'}}37 (void)y;38}39 40