blob: 3cd18cabe9700b5a78a10bdd47b2929d91767fb7 [file] [log] [blame]
Eli Friedman62695612013-09-18 23:23:17 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wno-gnu
Charles Li542f04c2015-11-11 19:34:47 +00002// 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
Eli Friedman62695612013-09-18 23:23:17 +00005// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu
Charles Li542f04c2015-11-11 19:34:47 +00006// 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
Eli Friedman62695612013-09-18 23:23:17 +00009// 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
Charles Li542f04c2015-11-11 19:34:47 +000013// 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
Eli Friedman62695612013-09-18 23:23:17 +000022// 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
Charles Li542f04c2015-11-11 19:34:47 +000026// 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
Eli Friedman62695612013-09-18 23:23:17 +000035// 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
51struct 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
65namespace 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
78struct faum {
79 int l;
80 union {
81 int c1[];
82 };
83};
84
85
Charles Li542f04c2015-11-11 19:34:47 +000086#if (ALL || FOLDINGCONSTANT) && (__cplusplus <= 199711L) // C++03 or earlier modes
Eli Friedman62695612013-09-18 23:23:17 +000087// 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
90struct 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
99struct ofam {int a[];};
100