15f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wno-gnu
224515d9819fcea76743d8ffca077620b679bf318Eli Friedman// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu
35f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wno-gnu \
424515d9819fcea76743d8ffca077620b679bf318Eli Friedman// RUN:   -Wgnu-alignof-expression -Wgnu-case-range -Wgnu-complex-integer -Wgnu-conditional-omitted-operand \
55f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// RUN:   -Wgnu-empty-initializer -Wgnu-label-as-value -Wgnu-statement-expression \
65f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// RUN:   -Wgnu-compound-literal-initializer -Wgnu-flexible-array-initializer \
75f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// RUN:   -Wgnu-redeclared-enum  -Wgnu-folding-constant -Wgnu-empty-struct \
85f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// RUN:   -Wgnu-union-cast -Wgnu-variable-sized-type-not-at-end
924515d9819fcea76743d8ffca077620b679bf318Eli Friedman// RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wgnu \
1024515d9819fcea76743d8ffca077620b679bf318Eli Friedman// RUN:   -Wno-gnu-alignof-expression -Wno-gnu-case-range -Wno-gnu-complex-integer -Wno-gnu-conditional-omitted-operand \
115f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// RUN:   -Wno-gnu-empty-initializer -Wno-gnu-label-as-value -Wno-gnu-statement-expression \
125f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// RUN:   -Wno-gnu-compound-literal-initializer -Wno-gnu-flexible-array-initializer \
135f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// RUN:   -Wno-gnu-redeclared-enum -Wno-gnu-folding-constant -Wno-gnu-empty-struct \
145f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// RUN:   -Wno-gnu-union-cast -Wno-gnu-variable-sized-type-not-at-end
155f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// Additional disabled tests:
165f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -Wno-gnu -Wgnu-alignof-expression
175f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// %clang_cc1 -fsyntax-only -verify %s -DCASERANGE -Wno-gnu -Wgnu-case-range
185f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// %clang_cc1 -fsyntax-only -verify %s -DCOMPLEXINT -Wno-gnu -Wgnu-complex-integer
195f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// %clang_cc1 -fsyntax-only -verify %s -DOMITTEDOPERAND -Wno-gnu -Wgnu-conditional-omitted-operand
205f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// %clang_cc1 -fsyntax-only -verify %s -DEMPTYINIT -Wno-gnu -Wgnu-empty-initializer
215f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// %clang_cc1 -fsyntax-only -verify %s -DLABELVALUE -Wno-gnu -Wgnu-label-as-value
225f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// %clang_cc1 -fsyntax-only -verify %s -DSTATEMENTEXP -Wno-gnu -Wgnu-statement-expression
235f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// %clang_cc1 -fsyntax-only -verify %s -DCOMPOUNDLITERALINITIALIZER -Wno-gnu -Wgnu-compound-literal-initializer
245f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// %clang_cc1 -fsyntax-only -verify %s -DFLEXIBLEARRAYINITIALIZER -Wno-gnu -Wgnu-flexible-array-initializer
255f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// %clang_cc1 -fsyntax-only -verify %s -DREDECLAREDENUM -Wno-gnu -Wgnu-redeclared-enum
265f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// %clang_cc1 -fsyntax-only -verify %s -DUNIONCAST -Wno-gnu -Wgnu-union-cast
275f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// %clang_cc1 -fsyntax-only -verify %s -DVARIABLESIZEDTYPENOTATEND -Wno-gnu -Wgnu-variable-sized-type-not-at-end
285f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// %clang_cc1 -fsyntax-only -verify %s -DFOLDINGCONSTANT -Wno-gnu -Wgnu-folding-constant
295f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// %clang_cc1 -fsyntax-only -verify %s -DEMPTYSTRUCT -Wno-gnu -Wgnu-empty-struct
3024515d9819fcea76743d8ffca077620b679bf318Eli Friedman
3124515d9819fcea76743d8ffca077620b679bf318Eli Friedman#if NONE
3224515d9819fcea76743d8ffca077620b679bf318Eli Friedman// expected-no-diagnostics
3324515d9819fcea76743d8ffca077620b679bf318Eli Friedman#endif
3424515d9819fcea76743d8ffca077620b679bf318Eli Friedman
3524515d9819fcea76743d8ffca077620b679bf318Eli Friedman
3624515d9819fcea76743d8ffca077620b679bf318Eli Friedman#if ALL || ALIGNOF
3724515d9819fcea76743d8ffca077620b679bf318Eli Friedman// expected-warning@+4 {{'_Alignof' applied to an expression is a GNU extension}}
3824515d9819fcea76743d8ffca077620b679bf318Eli Friedman#endif
3924515d9819fcea76743d8ffca077620b679bf318Eli Friedman
4024515d9819fcea76743d8ffca077620b679bf318Eli Friedmanchar align;
418d061b8ee7f5a56c494708b1ad00fffbb01dc4e9Dmitri Gribenko_Static_assert(_Alignof(align) > 0, "align's alignment is wrong");
4224515d9819fcea76743d8ffca077620b679bf318Eli Friedman
4324515d9819fcea76743d8ffca077620b679bf318Eli Friedman
4424515d9819fcea76743d8ffca077620b679bf318Eli Friedman#if ALL || CASERANGE
4524515d9819fcea76743d8ffca077620b679bf318Eli Friedman// expected-warning@+5 {{use of GNU case range extension}}
4624515d9819fcea76743d8ffca077620b679bf318Eli Friedman#endif
4724515d9819fcea76743d8ffca077620b679bf318Eli Friedman
4824515d9819fcea76743d8ffca077620b679bf318Eli Friedmanvoid caserange(int x) {
4924515d9819fcea76743d8ffca077620b679bf318Eli Friedman  switch (x) {
5024515d9819fcea76743d8ffca077620b679bf318Eli Friedman  case 42 ... 44: ;
5124515d9819fcea76743d8ffca077620b679bf318Eli Friedman  }
5224515d9819fcea76743d8ffca077620b679bf318Eli Friedman}
5324515d9819fcea76743d8ffca077620b679bf318Eli Friedman
5424515d9819fcea76743d8ffca077620b679bf318Eli Friedman
5524515d9819fcea76743d8ffca077620b679bf318Eli Friedman#if ALL || COMPLEXINT
5624515d9819fcea76743d8ffca077620b679bf318Eli Friedman// expected-warning@+3 {{complex integer types are a GNU extension}}
5724515d9819fcea76743d8ffca077620b679bf318Eli Friedman#endif
5824515d9819fcea76743d8ffca077620b679bf318Eli Friedman
5924515d9819fcea76743d8ffca077620b679bf318Eli Friedman_Complex short int complexint;
6024515d9819fcea76743d8ffca077620b679bf318Eli Friedman
6124515d9819fcea76743d8ffca077620b679bf318Eli Friedman
6224515d9819fcea76743d8ffca077620b679bf318Eli Friedman#if ALL || OMITTEDOPERAND
6324515d9819fcea76743d8ffca077620b679bf318Eli Friedman// expected-warning@+3 {{use of GNU ?: conditional expression extension, omitting middle operand}}
6424515d9819fcea76743d8ffca077620b679bf318Eli Friedman#endif
6524515d9819fcea76743d8ffca077620b679bf318Eli Friedman
6624515d9819fcea76743d8ffca077620b679bf318Eli Friedmanstatic const char* omittedoperand = (const char*)0 ?: "Null";
6724515d9819fcea76743d8ffca077620b679bf318Eli Friedman
6824515d9819fcea76743d8ffca077620b679bf318Eli Friedman
6924515d9819fcea76743d8ffca077620b679bf318Eli Friedman#if ALL || EMPTYINIT
7024515d9819fcea76743d8ffca077620b679bf318Eli Friedman// expected-warning@+3 {{use of GNU empty initializer extension}}
7124515d9819fcea76743d8ffca077620b679bf318Eli Friedman#endif
7224515d9819fcea76743d8ffca077620b679bf318Eli Friedman
7324515d9819fcea76743d8ffca077620b679bf318Eli Friedmanstruct { int x; } emptyinit = {};
7424515d9819fcea76743d8ffca077620b679bf318Eli Friedman
7524515d9819fcea76743d8ffca077620b679bf318Eli Friedman
7624515d9819fcea76743d8ffca077620b679bf318Eli Friedman#if ALL || LABELVALUE
7724515d9819fcea76743d8ffca077620b679bf318Eli Friedman// expected-warning@+6 {{use of GNU address-of-label extension}}
7824515d9819fcea76743d8ffca077620b679bf318Eli Friedman// expected-warning@+7 {{use of GNU indirect-goto extension}}
7924515d9819fcea76743d8ffca077620b679bf318Eli Friedman#endif
8024515d9819fcea76743d8ffca077620b679bf318Eli Friedman
8124515d9819fcea76743d8ffca077620b679bf318Eli Friedmanvoid labelvalue() {
8224515d9819fcea76743d8ffca077620b679bf318Eli Friedman	void *ptr;
8324515d9819fcea76743d8ffca077620b679bf318Eli Friedman	ptr = &&foo;
8424515d9819fcea76743d8ffca077620b679bf318Eli Friedmanfoo:
8524515d9819fcea76743d8ffca077620b679bf318Eli Friedman	goto *ptr;
8624515d9819fcea76743d8ffca077620b679bf318Eli Friedman}
8724515d9819fcea76743d8ffca077620b679bf318Eli Friedman
885f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
8924515d9819fcea76743d8ffca077620b679bf318Eli Friedman#if ALL || STATEMENTEXP
9024515d9819fcea76743d8ffca077620b679bf318Eli Friedman// expected-warning@+5 {{use of GNU statement expression extension}}
9124515d9819fcea76743d8ffca077620b679bf318Eli Friedman#endif
9224515d9819fcea76743d8ffca077620b679bf318Eli Friedman
9324515d9819fcea76743d8ffca077620b679bf318Eli Friedmanvoid statementexp()
9424515d9819fcea76743d8ffca077620b679bf318Eli Friedman{
9524515d9819fcea76743d8ffca077620b679bf318Eli Friedman	int a = ({ 1; });
9624515d9819fcea76743d8ffca077620b679bf318Eli Friedman}
975f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
985f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
995f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman#if ALL || COMPOUNDLITERALINITIALIZER
1005f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// expected-warning@+4 {{initialization of an array of type 'int [5]' from a compound literal of type 'int [5]' is a GNU extension}}
1015f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman#endif
1025f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1035f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedmantypedef int int5[5];
1045f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedmanint cli[5] = (int[]){1, 2, 3, 4, 5};
1055f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1065f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1075f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman#if ALL || FLEXIBLEARRAYINITIALIZER
1085f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// expected-note@+6 {{initialized flexible array member 'y' is here}}
1095f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// expected-warning@+6 {{flexible array initialization is a GNU extension}}
1105f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman#endif
1115f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1125f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedmanstruct fai {
1135f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman  int x;
1145f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman  int y[];
1155f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman} fai = { 1, { 2, 3, 4 } };
1165f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1175f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1185f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman#if ALL || FOLDINGCONSTANT
1195f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// expected-warning@+5 {{expression is not an integer constant expression; folding it to a constant is a GNU extension}}
1205f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// expected-warning@+7 {{variable length array folded to constant array as an extension}}
1215f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman#endif
1225f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1235f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedmanenum {
1245f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman	fic = (int)(0.75 * 1000 * 1000)
1255f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman};
1265f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedmanstatic const int size = 100;
1275f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedmanvoid foo(void) { int data[size]; }
1285f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1295f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman#if ALL || REDECLAREDENUM
1305f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// expected-note@+4 {{previous definition is here}}
1315f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// expected-warning@+8 {{redeclaration of already-defined enum 'RE' is a GNU extension}}
1325f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman#endif
1335f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1345f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedmanenum RE {
1355f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman  Val1,
1365f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman  Val2
1375f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman};
1385f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1395f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedmanenum RE;
1405f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1415f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1425f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman#if ALL || UNIONCAST
1435f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// expected-warning@+4 {{cast to union type is a GNU extension}}
1445f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman#endif
1455f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1465f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedmanunion uc { int i; unsigned : 3; };
1475f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedmanunion uc w = (union uc)2;
1485f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1495f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1505f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman#if ALL || VARIABLESIZEDTYPENOTATEND
1515f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// expected-warning@+8 {{field 'hdr' with variable sized type 'struct vst' not at the end of a struct or class is a GNU extension}}
1525f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman#endif
1535f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1545f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedmanstruct vst {
1555f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman short tag_type;
1565f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman char tag_data[];
1575f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman};
1585f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedmanstruct vstnae {
1595f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman  struct vst hdr;
1605f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman  char data;
1615f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman};
1625f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1635f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1645f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman#if ALL || EMPTYSTRUCT
1655f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// expected-warning@+4 {{empty struct is a GNU extension}}
1665f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman// expected-warning@+4 {{struct without named members is a GNU extension}}
1675f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman#endif
1685f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
1695f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedmanconst struct {} es;
1705f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedmanstruct {int:5;} swnm;
1715f33c37f8fe476602d9a1cc968060f6113ec8aaaEli Friedman
172