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