1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wno-gnu
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu
3*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wno-gnu \
4*f4a2713aSLionel Sambuc // RUN: -Wgnu-alignof-expression -Wgnu-case-range -Wgnu-complex-integer -Wgnu-conditional-omitted-operand \
5*f4a2713aSLionel Sambuc // RUN: -Wgnu-empty-initializer -Wgnu-label-as-value -Wgnu-statement-expression \
6*f4a2713aSLionel Sambuc // RUN: -Wgnu-compound-literal-initializer -Wgnu-flexible-array-initializer \
7*f4a2713aSLionel Sambuc // RUN: -Wgnu-redeclared-enum -Wgnu-folding-constant -Wgnu-empty-struct \
8*f4a2713aSLionel Sambuc // RUN: -Wgnu-union-cast -Wgnu-variable-sized-type-not-at-end
9*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wgnu \
10*f4a2713aSLionel Sambuc // RUN: -Wno-gnu-alignof-expression -Wno-gnu-case-range -Wno-gnu-complex-integer -Wno-gnu-conditional-omitted-operand \
11*f4a2713aSLionel Sambuc // RUN: -Wno-gnu-empty-initializer -Wno-gnu-label-as-value -Wno-gnu-statement-expression \
12*f4a2713aSLionel Sambuc // RUN: -Wno-gnu-compound-literal-initializer -Wno-gnu-flexible-array-initializer \
13*f4a2713aSLionel Sambuc // RUN: -Wno-gnu-redeclared-enum -Wno-gnu-folding-constant -Wno-gnu-empty-struct \
14*f4a2713aSLionel Sambuc // RUN: -Wno-gnu-union-cast -Wno-gnu-variable-sized-type-not-at-end
15*f4a2713aSLionel Sambuc // Additional disabled tests:
16*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -Wno-gnu -Wgnu-alignof-expression
17*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DCASERANGE -Wno-gnu -Wgnu-case-range
18*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DCOMPLEXINT -Wno-gnu -Wgnu-complex-integer
19*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DOMITTEDOPERAND -Wno-gnu -Wgnu-conditional-omitted-operand
20*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DEMPTYINIT -Wno-gnu -Wgnu-empty-initializer
21*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DLABELVALUE -Wno-gnu -Wgnu-label-as-value
22*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DSTATEMENTEXP -Wno-gnu -Wgnu-statement-expression
23*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DCOMPOUNDLITERALINITIALIZER -Wno-gnu -Wgnu-compound-literal-initializer
24*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DFLEXIBLEARRAYINITIALIZER -Wno-gnu -Wgnu-flexible-array-initializer
25*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DREDECLAREDENUM -Wno-gnu -Wgnu-redeclared-enum
26*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DUNIONCAST -Wno-gnu -Wgnu-union-cast
27*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DVARIABLESIZEDTYPENOTATEND -Wno-gnu -Wgnu-variable-sized-type-not-at-end
28*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DFOLDINGCONSTANT -Wno-gnu -Wgnu-folding-constant
29*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DEMPTYSTRUCT -Wno-gnu -Wgnu-empty-struct
30*f4a2713aSLionel Sambuc
31*f4a2713aSLionel Sambuc #if NONE
32*f4a2713aSLionel Sambuc // expected-no-diagnostics
33*f4a2713aSLionel Sambuc #endif
34*f4a2713aSLionel Sambuc
35*f4a2713aSLionel Sambuc
36*f4a2713aSLionel Sambuc #if ALL || ALIGNOF
37*f4a2713aSLionel Sambuc // expected-warning@+4 {{'_Alignof' applied to an expression is a GNU extension}}
38*f4a2713aSLionel Sambuc #endif
39*f4a2713aSLionel Sambuc
40*f4a2713aSLionel Sambuc char align;
41*f4a2713aSLionel Sambuc _Static_assert(_Alignof(align) > 0, "align's alignment is wrong");
42*f4a2713aSLionel Sambuc
43*f4a2713aSLionel Sambuc
44*f4a2713aSLionel Sambuc #if ALL || CASERANGE
45*f4a2713aSLionel Sambuc // expected-warning@+5 {{use of GNU case range extension}}
46*f4a2713aSLionel Sambuc #endif
47*f4a2713aSLionel Sambuc
caserange(int x)48*f4a2713aSLionel Sambuc void caserange(int x) {
49*f4a2713aSLionel Sambuc switch (x) {
50*f4a2713aSLionel Sambuc case 42 ... 44: ;
51*f4a2713aSLionel Sambuc }
52*f4a2713aSLionel Sambuc }
53*f4a2713aSLionel Sambuc
54*f4a2713aSLionel Sambuc
55*f4a2713aSLionel Sambuc #if ALL || COMPLEXINT
56*f4a2713aSLionel Sambuc // expected-warning@+3 {{complex integer types are a GNU extension}}
57*f4a2713aSLionel Sambuc #endif
58*f4a2713aSLionel Sambuc
59*f4a2713aSLionel Sambuc _Complex short int complexint;
60*f4a2713aSLionel Sambuc
61*f4a2713aSLionel Sambuc
62*f4a2713aSLionel Sambuc #if ALL || OMITTEDOPERAND
63*f4a2713aSLionel Sambuc // expected-warning@+3 {{use of GNU ?: conditional expression extension, omitting middle operand}}
64*f4a2713aSLionel Sambuc #endif
65*f4a2713aSLionel Sambuc
66*f4a2713aSLionel Sambuc static const char* omittedoperand = (const char*)0 ?: "Null";
67*f4a2713aSLionel Sambuc
68*f4a2713aSLionel Sambuc
69*f4a2713aSLionel Sambuc #if ALL || EMPTYINIT
70*f4a2713aSLionel Sambuc // expected-warning@+3 {{use of GNU empty initializer extension}}
71*f4a2713aSLionel Sambuc #endif
72*f4a2713aSLionel Sambuc
73*f4a2713aSLionel Sambuc struct { int x; } emptyinit = {};
74*f4a2713aSLionel Sambuc
75*f4a2713aSLionel Sambuc
76*f4a2713aSLionel Sambuc #if ALL || LABELVALUE
77*f4a2713aSLionel Sambuc // expected-warning@+6 {{use of GNU address-of-label extension}}
78*f4a2713aSLionel Sambuc // expected-warning@+7 {{use of GNU indirect-goto extension}}
79*f4a2713aSLionel Sambuc #endif
80*f4a2713aSLionel Sambuc
labelvalue()81*f4a2713aSLionel Sambuc void labelvalue() {
82*f4a2713aSLionel Sambuc void *ptr;
83*f4a2713aSLionel Sambuc ptr = &&foo;
84*f4a2713aSLionel Sambuc foo:
85*f4a2713aSLionel Sambuc goto *ptr;
86*f4a2713aSLionel Sambuc }
87*f4a2713aSLionel Sambuc
88*f4a2713aSLionel Sambuc
89*f4a2713aSLionel Sambuc #if ALL || STATEMENTEXP
90*f4a2713aSLionel Sambuc // expected-warning@+5 {{use of GNU statement expression extension}}
91*f4a2713aSLionel Sambuc #endif
92*f4a2713aSLionel Sambuc
statementexp()93*f4a2713aSLionel Sambuc void statementexp()
94*f4a2713aSLionel Sambuc {
95*f4a2713aSLionel Sambuc int a = ({ 1; });
96*f4a2713aSLionel Sambuc }
97*f4a2713aSLionel Sambuc
98*f4a2713aSLionel Sambuc
99*f4a2713aSLionel Sambuc #if ALL || COMPOUNDLITERALINITIALIZER
100*f4a2713aSLionel Sambuc // expected-warning@+4 {{initialization of an array of type 'int [5]' from a compound literal of type 'int [5]' is a GNU extension}}
101*f4a2713aSLionel Sambuc #endif
102*f4a2713aSLionel Sambuc
103*f4a2713aSLionel Sambuc typedef int int5[5];
104*f4a2713aSLionel Sambuc int cli[5] = (int[]){1, 2, 3, 4, 5};
105*f4a2713aSLionel Sambuc
106*f4a2713aSLionel Sambuc
107*f4a2713aSLionel Sambuc #if ALL || FLEXIBLEARRAYINITIALIZER
108*f4a2713aSLionel Sambuc // expected-note@+6 {{initialized flexible array member 'y' is here}}
109*f4a2713aSLionel Sambuc // expected-warning@+6 {{flexible array initialization is a GNU extension}}
110*f4a2713aSLionel Sambuc #endif
111*f4a2713aSLionel Sambuc
112*f4a2713aSLionel Sambuc struct fai {
113*f4a2713aSLionel Sambuc int x;
114*f4a2713aSLionel Sambuc int y[];
115*f4a2713aSLionel Sambuc } fai = { 1, { 2, 3, 4 } };
116*f4a2713aSLionel Sambuc
117*f4a2713aSLionel Sambuc
118*f4a2713aSLionel Sambuc #if ALL || FOLDINGCONSTANT
119*f4a2713aSLionel Sambuc // expected-warning@+5 {{expression is not an integer constant expression; folding it to a constant is a GNU extension}}
120*f4a2713aSLionel Sambuc // expected-warning@+7 {{variable length array folded to constant array as an extension}}
121*f4a2713aSLionel Sambuc #endif
122*f4a2713aSLionel Sambuc
123*f4a2713aSLionel Sambuc enum {
124*f4a2713aSLionel Sambuc fic = (int)(0.75 * 1000 * 1000)
125*f4a2713aSLionel Sambuc };
126*f4a2713aSLionel Sambuc static const int size = 100;
foo(void)127*f4a2713aSLionel Sambuc void foo(void) { int data[size]; }
128*f4a2713aSLionel Sambuc
129*f4a2713aSLionel Sambuc #if ALL || REDECLAREDENUM
130*f4a2713aSLionel Sambuc // expected-note@+4 {{previous definition is here}}
131*f4a2713aSLionel Sambuc // expected-warning@+8 {{redeclaration of already-defined enum 'RE' is a GNU extension}}
132*f4a2713aSLionel Sambuc #endif
133*f4a2713aSLionel Sambuc
134*f4a2713aSLionel Sambuc enum RE {
135*f4a2713aSLionel Sambuc Val1,
136*f4a2713aSLionel Sambuc Val2
137*f4a2713aSLionel Sambuc };
138*f4a2713aSLionel Sambuc
139*f4a2713aSLionel Sambuc enum RE;
140*f4a2713aSLionel Sambuc
141*f4a2713aSLionel Sambuc
142*f4a2713aSLionel Sambuc #if ALL || UNIONCAST
143*f4a2713aSLionel Sambuc // expected-warning@+4 {{cast to union type is a GNU extension}}
144*f4a2713aSLionel Sambuc #endif
145*f4a2713aSLionel Sambuc
146*f4a2713aSLionel Sambuc union uc { int i; unsigned : 3; };
147*f4a2713aSLionel Sambuc union uc w = (union uc)2;
148*f4a2713aSLionel Sambuc
149*f4a2713aSLionel Sambuc
150*f4a2713aSLionel Sambuc #if ALL || VARIABLESIZEDTYPENOTATEND
151*f4a2713aSLionel Sambuc // expected-warning@+8 {{field 'hdr' with variable sized type 'struct vst' not at the end of a struct or class is a GNU extension}}
152*f4a2713aSLionel Sambuc #endif
153*f4a2713aSLionel Sambuc
154*f4a2713aSLionel Sambuc struct vst {
155*f4a2713aSLionel Sambuc short tag_type;
156*f4a2713aSLionel Sambuc char tag_data[];
157*f4a2713aSLionel Sambuc };
158*f4a2713aSLionel Sambuc struct vstnae {
159*f4a2713aSLionel Sambuc struct vst hdr;
160*f4a2713aSLionel Sambuc char data;
161*f4a2713aSLionel Sambuc };
162*f4a2713aSLionel Sambuc
163*f4a2713aSLionel Sambuc
164*f4a2713aSLionel Sambuc #if ALL || EMPTYSTRUCT
165*f4a2713aSLionel Sambuc // expected-warning@+4 {{empty struct is a GNU extension}}
166*f4a2713aSLionel Sambuc // expected-warning@+4 {{struct without named members is a GNU extension}}
167*f4a2713aSLionel Sambuc #endif
168*f4a2713aSLionel Sambuc
169*f4a2713aSLionel Sambuc const struct {} es;
170*f4a2713aSLionel Sambuc struct {int:5;} swnm;
171*f4a2713aSLionel Sambuc
172