gnu-flags.c revision e0f720eaa958fa3eb539851779c51b8371e09e7b
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#if ALL || ALIGNOF
24// expected-warning@+4 {{'_Alignof' applied to an expression is a GNU extension}}
25#endif
26
27char align;
28_Static_assert(_Alignof(align) == 1, "align's alignment is wrong");
29
30
31#if ALL || CASERANGE
32// expected-warning@+5 {{use of GNU case range extension}}
33#endif
34
35void caserange(int x) {
36  switch (x) {
37  case 42 ... 44: ;
38  }
39}
40
41
42#if ALL || COMPLEXINT
43// expected-warning@+3 {{complex integer types are a GNU extension}}
44#endif
45
46_Complex short int complexint;
47
48
49#if ALL || OMITTEDOPERAND
50// expected-warning@+3 {{use of GNU ?: conditional expression extension, omitting middle operand}}
51#endif
52
53static const char* omittedoperand = (const char*)0 ?: "Null";
54
55
56#if ALL || EMPTYINIT
57// expected-warning@+3 {{use of GNU empty initializer extension}}
58#endif
59
60struct { int x; } emptyinit = {};
61
62
63#if ALL || LABELVALUE
64// expected-warning@+6 {{use of GNU address-of-label extension}}
65// expected-warning@+7 {{use of GNU indirect-goto extension}}
66#endif
67
68void labelvalue() {
69	void *ptr;
70	ptr = &&foo;
71foo:
72	goto *ptr;
73}
74
75#if ALL || STATEMENTEXP
76// expected-warning@+5 {{use of GNU statement expression extension}}
77#endif
78
79void statementexp()
80{
81	int a = ({ 1; });
82}
83