diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2013-09-18 23:23:17 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2013-09-18 23:23:17 +0000 |
commit | 626956111d630f90a0456e4c8751eb48f1067403 (patch) | |
tree | 9e5891d4f2f6bf724941df5d4ead55c04b1cb602 /clang/test/SemaCXX/gnu-flags.cpp | |
parent | f9edb00fa49c178f91bf5a367a604c7c88fa4518 (diff) | |
download | bcm5719-llvm-626956111d630f90a0456e4c8751eb48f1067403.tar.gz bcm5719-llvm-626956111d630f90a0456e4c8751eb48f1067403.zip |
Add specific warning flags for GNU ext in Sema.
This patch adds the following, more specific warning flags:
gnu-anonymous-struct
gnu-compound-literal-initializer
gnu-empty-struct
gnu-flexible-array-initializer
gnu-flexible-array-union-member
gnu-folding-constant
redeclared-class-member
gnu-redeclared-enum
gnu-union-cast
gnu-variable-sized-type-not-at-end
Patch by Peter Lewis.
llvm-svn: 190972
Diffstat (limited to 'clang/test/SemaCXX/gnu-flags.cpp')
-rw-r--r-- | clang/test/SemaCXX/gnu-flags.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/gnu-flags.cpp b/clang/test/SemaCXX/gnu-flags.cpp new file mode 100644 index 00000000000..05770c53704 --- /dev/null +++ b/clang/test/SemaCXX/gnu-flags.cpp @@ -0,0 +1,76 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wno-gnu +// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu +// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wno-gnu \ +// RUN: -Wgnu-anonymous-struct -Wredeclared-class-member \ +// RUN: -Wgnu-flexible-array-union-member -Wgnu-folding-constant \ +// RUN: -Wgnu-empty-struct +// RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wgnu \ +// RUN: -Wno-gnu-anonymous-struct -Wno-redeclared-class-member \ +// RUN: -Wno-gnu-flexible-array-union-member -Wno-gnu-folding-constant \ +// RUN: -Wno-gnu-empty-struct +// Additional disabled tests: +// %clang_cc1 -fsyntax-only -verify %s -DANONYMOUSSTRUCT -Wno-gnu -Wgnu-anonymous-struct +// %clang_cc1 -fsyntax-only -verify %s -DREDECLAREDCLASSMEMBER -Wno-gnu -Wredeclared-class-member +// %clang_cc1 -fsyntax-only -verify %s -DFLEXIBLEARRAYUNIONMEMBER -Wno-gnu -Wgnu-flexible-array-union-member +// %clang_cc1 -fsyntax-only -verify %s -DFOLDINGCONSTANT -Wno-gnu -Wgnu-folding-constant +// %clang_cc1 -fsyntax-only -verify %s -DEMPTYSTRUCT -Wno-gnu -Wgnu-empty-struct + +#if NONE +// expected-no-diagnostics +#endif + + +#if ALL || ANONYMOUSSTRUCT +// expected-warning@+5 {{anonymous structs are a GNU extension}} +#endif + +struct as { + int x; + struct { + int a; + float b; + }; +}; + + +#if ALL || REDECLAREDCLASSMEMBER +// expected-note@+6 {{previous declaration is here}} +// expected-warning@+6 {{class member cannot be redeclared}} +#endif + +namespace rcm { + class A { + class X; + class X; + class X {}; + }; +} + + +#if ALL || FLEXIBLEARRAYUNIONMEMBER +// expected-warning@+6 {{flexible array member 'c1' in a union is a GNU extension}} +#endif + +struct faum { + int l; + union { + int c1[]; + }; +}; + + +#if ALL || FOLDINGCONSTANT +// expected-warning@+4 {{in-class initializer for static data member is not a constant expression; folding it to a constant is a GNU extension}} +#endif + +struct fic { + static const int B = int(0.75 * 1000 * 1000); +}; + + +#if ALL || EMPTYSTRUCT +// expected-warning@+3 {{flexible array member 'a' in otherwise empty struct is a GNU extension}} +#endif + +struct ofam {int a[];}; + |