[Clang/AMDGPU] Zero sized arrays not allowed in HIP device code. (#113470)
[llvm-project.git] / clang / test / SemaCXX / gnu-flags.cpp
blob3cd18cabe9700b5a78a10bdd47b2929d91767fb7
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
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
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
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
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
42 #if NONE
43 // expected-no-diagnostics
44 #endif
47 #if ALL || ANONYMOUSSTRUCT
48 // expected-warning@+5 {{anonymous structs are a GNU extension}}
49 #endif
51 struct as {
52 int x;
53 struct {
54 int a;
55 float b;
60 #if ALL || REDECLAREDCLASSMEMBER
61 // expected-note@+6 {{previous declaration is here}}
62 // expected-warning@+6 {{class member cannot be redeclared}}
63 #endif
65 namespace rcm {
66 class A {
67 class X;
68 class X;
69 class X {};
74 #if ALL || FLEXIBLEARRAYUNIONMEMBER
75 // expected-warning@+6 {{flexible array member 'c1' in a union is a GNU extension}}
76 #endif
78 struct faum {
79 int l;
80 union {
81 int c1[];
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
90 struct fic {
91 static const int B = int(0.75 * 1000 * 1000);
95 #if ALL || EMPTYSTRUCT
96 // expected-warning@+3 {{flexible array member 'a' in otherwise empty struct is a GNU extension}}
97 #endif
99 struct ofam {int a[];};