[clang][Driver] Support simplified triple versions for config files (#111387)
[llvm-project.git] / clang / test / Parser / decls.c
blob39ef05bf4bd9999f8649c852b9a7b38d08c578a3
1 // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
3 // Test that we can parse declarations at global scope.
4 int v;
6 void func(void) {
7 // Test that we can parse declarations within a compound statement.
8 int a;
10 int b;
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;
17 });
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}}
26 label:
27 int y; // expected-warning {{label followed by a declaration is a C23 extension}}
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;