gnu-flags.c revision e85baa92c8b6d68c254e33934397d4883fc12aef
1// RUN: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF 2// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu 3// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL \ 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: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wgnu \ 7// RUN: -Wno-gnu-alignof-expression -Wno-gnu-case-range -Wno-gnu-complex-integer -Wno-gnu-conditional-omitted-operand \ 8// RUN: -Wno-gnu-empty-initializer -Wno-gnu-label-as-value -Wno-gnu-statement-expression 9// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -Wgnu-alignof-expression 10// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wno-gnu-alignof-expression 11// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -DCASERANGE -Wgnu-case-range 12// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -DCOMPLEXINT -Wgnu-complex-integer 13// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -DOMITTEDOPERAND -Wgnu-conditional-omitted-operand 14// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -DEMPTYINIT -Wgnu-empty-initializer 15// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -DLABELVALUE -Wgnu-label-as-value 16// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -DSTATEMENTEXP -Wgnu-statement-expression 17 18#if NONE 19// expected-no-diagnostics 20#endif 21 22 23#ifdef __s390x__ 24#define EXPECTED_ALIGN 2 25#else 26#define EXPECTED_ALIGN 1 27#endif 28 29#if ALL || ALIGNOF 30// expected-warning@+4 {{'_Alignof' applied to an expression is a GNU extension}} 31#endif 32 33char align; 34_Static_assert(_Alignof(align) == EXPECTED_ALIGN, "align's alignment is wrong"); 35 36 37#if ALL || CASERANGE 38// expected-warning@+5 {{use of GNU case range extension}} 39#endif 40 41void caserange(int x) { 42 switch (x) { 43 case 42 ... 44: ; 44 } 45} 46 47 48#if ALL || COMPLEXINT 49// expected-warning@+3 {{complex integer types are a GNU extension}} 50#endif 51 52_Complex short int complexint; 53 54 55#if ALL || OMITTEDOPERAND 56// expected-warning@+3 {{use of GNU ?: conditional expression extension, omitting middle operand}} 57#endif 58 59static const char* omittedoperand = (const char*)0 ?: "Null"; 60 61 62#if ALL || EMPTYINIT 63// expected-warning@+3 {{use of GNU empty initializer extension}} 64#endif 65 66struct { int x; } emptyinit = {}; 67 68 69#if ALL || LABELVALUE 70// expected-warning@+6 {{use of GNU address-of-label extension}} 71// expected-warning@+7 {{use of GNU indirect-goto extension}} 72#endif 73 74void labelvalue() { 75 void *ptr; 76 ptr = &&foo; 77foo: 78 goto *ptr; 79} 80 81#if ALL || STATEMENTEXP 82// expected-warning@+5 {{use of GNU statement expression extension}} 83#endif 84 85void statementexp() 86{ 87 int a = ({ 1; }); 88} 89