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