1 // RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wno-gnu
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DNONE -Wno-gnu
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DNONE -Wno-gnu
4 
5 // RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu
6 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DALL -Wgnu
7 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DALL -Wgnu
8 
9 // RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wno-gnu \
10 // RUN:   -Wgnu-anonymous-struct -Wredeclared-class-member \
11 // RUN:   -Wgnu-flexible-array-union-member -Wgnu-folding-constant \
12 // RUN:   -Wgnu-empty-struct
13 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DALL -Wno-gnu \
14 // RUN:   -Wgnu-anonymous-struct -Wredeclared-class-member \
15 // RUN:   -Wgnu-flexible-array-union-member -Wgnu-folding-constant \
16 // RUN:   -Wgnu-empty-struct
17 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DALL -Wno-gnu \
18 // RUN:   -Wgnu-anonymous-struct -Wredeclared-class-member \
19 // RUN:   -Wgnu-flexible-array-union-member -Wgnu-folding-constant \
20 // RUN:   -Wgnu-empty-struct
21 
22 // RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wgnu \
23 // RUN:   -Wno-gnu-anonymous-struct -Wno-redeclared-class-member \
24 // RUN:   -Wno-gnu-flexible-array-union-member -Wno-gnu-folding-constant \
25 // RUN:   -Wno-gnu-empty-struct
26 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DNONE -Wgnu \
27 // RUN:   -Wno-gnu-anonymous-struct -Wno-redeclared-class-member \
28 // RUN:   -Wno-gnu-flexible-array-union-member -Wno-gnu-folding-constant \
29 // RUN:   -Wno-gnu-empty-struct
30 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DNONE -Wgnu \
31 // RUN:   -Wno-gnu-anonymous-struct -Wno-redeclared-class-member \
32 // RUN:   -Wno-gnu-flexible-array-union-member -Wno-gnu-folding-constant \
33 // RUN:   -Wno-gnu-empty-struct
34 
35 // Additional disabled tests:
36 // %clang_cc1 -fsyntax-only -verify %s -DANONYMOUSSTRUCT -Wno-gnu -Wgnu-anonymous-struct
37 // %clang_cc1 -fsyntax-only -verify %s -DREDECLAREDCLASSMEMBER -Wno-gnu -Wredeclared-class-member
38 // %clang_cc1 -fsyntax-only -verify %s -DFLEXIBLEARRAYUNIONMEMBER -Wno-gnu -Wgnu-flexible-array-union-member
39 // %clang_cc1 -fsyntax-only -verify %s -DFOLDINGCONSTANT -Wno-gnu -Wgnu-folding-constant
40 // %clang_cc1 -fsyntax-only -verify %s -DEMPTYSTRUCT -Wno-gnu -Wgnu-empty-struct
41 
42 #if NONE
43 // expected-no-diagnostics
44 #endif
45 
46 
47 #if ALL || ANONYMOUSSTRUCT
48 // expected-warning@+5 {{anonymous structs are a GNU extension}}
49 #endif
50 
51 struct as {
52   int x;
53   struct {
54     int a;
55     float b;
56   };
57 };
58 
59 
60 #if ALL || REDECLAREDCLASSMEMBER
61 // expected-note@+6 {{previous declaration is here}}
62 // expected-warning@+6 {{class member cannot be redeclared}}
63 #endif
64 
65 namespace rcm {
66   class A {
67     class X;
68     class X;
69     class X {};
70   };
71 }
72 
73 
74 #if ALL || FLEXIBLEARRAYUNIONMEMBER
75 // expected-warning@+6 {{flexible array member 'c1' in a union is a GNU extension}}
76 #endif
77 
78 struct faum {
79    int l;
80    union {
81        int c1[];
82    };
83 };
84 
85 
86 #if (ALL || FOLDINGCONSTANT) && (__cplusplus <= 199711L) // C++03 or earlier modes
87 // expected-warning@+4 {{in-class initializer for static data member is not a constant expression; folding it to a constant is a GNU extension}}
88 #endif
89 
90 struct fic {
91   static const int B = int(0.75 * 1000 * 1000);
92 };
93 
94 
95 #if ALL || EMPTYSTRUCT
96 // expected-warning@+3 {{flexible array member 'a' in otherwise empty struct is a GNU extension}}
97 #endif
98 
99 struct ofam {int a[];};
100 
101