On 17/08/2013, at 5:22 , Eli Friedman <[email protected]> wrote: > diag::ext_gnu_local_label shouldn't exist; it's not something we need to > diagnose.
Is it not a GNU extension to have local labels?
Are you suggesting the I delete the diagnostic for local labels, or not add the
explicit flag for that diagnostic?
> You can trigger ext_gnu_empty_initializer with "struct { int x; } x = {};"
Thanks, I'll use that.
> It would be nice if you could avoid adding thirty invocations of clang to the
> regression tests; we rely on them to run quickly.
On 17/08/2013, at 5:56 , Richard Smith <[email protected]> wrote:
> Perhaps fold all the tests into one file, add a -D for each warning flag,
> then do
>
> // RUN: %clang_cc1 -verify %s
> // RUN: %clang_cc1 -verify %s -Wgnu-alignof-expression -DALIGNOF
> // RUN: %clang_cc1 -verify %s -Wgnu-case-range -DCASE_RANGE
> // ...
> // RUN: %clang_cc1 -verify %s -Wgnu -DALIGNOF -DCASE_RANGE -DCOMPLEX_INTEGER
> ...
>
> ... though even this is more thorough testing than we'd usually have for
> warning flags.
Here is the updated patch, with all the tests combined, and only four
invocations (and another eight disabled ones). It still includes the local
labels flag, let me know what you want me to do about that. BTW, if you take
this gnu-flags.c test file, and remove the // RUN: from the continuations lines
(4&5 and 6&7) llvm-lit hangs. Maybe this is to be expected (garbage in,
garbage out) but I figured I'd mention it.
Index: include/clang/Basic/DiagnosticGroups.td
===================================================================
--- include/clang/Basic/DiagnosticGroups.td (revision 188533)
+++ include/clang/Basic/DiagnosticGroups.td (working copy)
@@ -21,6 +21,7 @@
def : DiagGroup<"address">;
def AddressOfTemporary : DiagGroup<"address-of-temporary">;
def : DiagGroup<"aggregate-return">;
+def GNUAlignofExpression : DiagGroup<"gnu-alignof-expression">;
def AmbigMemberTemplate : DiagGroup<"ambiguous-member-template">;
def ArrayBounds : DiagGroup<"array-bounds">;
def ArrayBoundsPointerArithmetic :
DiagGroup<"array-bounds-pointer-arithmetic">;
@@ -45,10 +46,13 @@
def BuiltinRequiresHeader : DiagGroup<"builtin-requires-header">;
def C99Compat : DiagGroup<"c99-compat">;
def CXXCompat: DiagGroup<"c++-compat">;
+def GNUCaseRange : DiagGroup<"gnu-case-range">;
def CastAlign : DiagGroup<"cast-align">;
def : DiagGroup<"cast-qual">;
def : DiagGroup<"char-align">;
def Comment : DiagGroup<"comment">;
+def GNUComplexInteger : DiagGroup<"gnu-complex-integer">;
+def GNUConditionalOmittedOperand :
DiagGroup<"gnu-conditional-omitted-operand">;
def ConfigMacros : DiagGroup<"config-macros">;
def : DiagGroup<"ctor-dtor-privacy">;
def GNUDesignator : DiagGroup<"gnu-designator">;
@@ -82,6 +86,7 @@
DocumentationDeprecatedSync]>;
def EmptyBody : DiagGroup<"empty-body">;
+def GNUEmptyInitializer : DiagGroup<"gnu-empty-initializer">;
def ExtraTokens : DiagGroup<"extra-tokens">;
def CXX11ExtraSemi : DiagGroup<"c++11-extra-semi">;
def ExtraSemi : DiagGroup<"extra-semi", [CXX11ExtraSemi]>;
@@ -162,6 +167,8 @@
def : DiagGroup<"init-self">;
def : DiagGroup<"inline">;
def : DiagGroup<"invalid-pch">;
+def GNULabelsAsValue : DiagGroup<"gnu-label-as-value">;
+def GNULocalLabel : DiagGroup<"gnu-local-label">;
def LiteralRange : DiagGroup<"literal-range">;
def LocalTypeTemplateArgs : DiagGroup<"local-type-template-args",
[CXX98CompatLocalTypeTemplateArgs]>;
@@ -248,6 +255,7 @@
def StaticLocalInInline : DiagGroup<"static-local-in-inline">;
def GNUStaticFloatInit : DiagGroup<"gnu-static-float-init">;
def StaticFloatInit : DiagGroup<"static-float-init", [GNUStaticFloatInit]>;
+def GNUStatementExpression : DiagGroup<"gnu-statement-expression">;
def StringPlusInt : DiagGroup<"string-plus-int">;
def StrncatSize : DiagGroup<"strncat-size">;
def TautologicalOutOfRangeCompare :
DiagGroup<"tautological-constant-out-of-range-compare">;
@@ -527,8 +535,14 @@
def C99 : DiagGroup<"c99-extensions">;
// A warning group for warnings about GCC extensions.
-def GNU : DiagGroup<"gnu", [GNUDesignator, VLAExtension,
- ZeroLengthArray, GNUStaticFloatInit]>;
+def GNU : DiagGroup<"gnu", [GNUAlignofExpression, GNUCaseRange,
+ GNUComplexInteger,
+ GNUConditionalOmittedOperand,
+ GNUDesignator, GNUEmptyInitializer,
+ VLAExtension,
+ GNULabelsAsValue, GNULocalLabel,
+ GNUStatementExpression, GNUStaticFloatInit,
+ ZeroLengthArray]>;
// A warning group for warnings about code that clang accepts but gcc doesn't.
def GccCompat : DiagGroup<"gcc-compat">;
Index: include/clang/Basic/DiagnosticParseKinds.td
===================================================================
--- include/clang/Basic/DiagnosticParseKinds.td (revision 188533)
+++ include/clang/Basic/DiagnosticParseKinds.td (working copy)
@@ -54,7 +54,7 @@
def ext_plain_complex : ExtWarn<
"plain '_Complex' requires a type specifier; assuming '_Complex double'">;
def ext_integer_complex : Extension<
- "complex integer types are a GNU extension">, InGroup<GNU>;
+ "complex integer types are a GNU extension">, InGroup<GNUComplexInteger>;
def ext_thread_before : Extension<"'__thread' before '%0'">;
def error_empty_enum : Error<"use of empty enum">;
@@ -99,7 +99,7 @@
"alignof expressions are incompatible with C++98">,
InGroup<CXX98Compat>, DefaultIgnore;
def ext_alignof_expr : ExtWarn<
- "%0 applied to an expression is a GNU extension">, InGroup<GNU>;
+ "%0 applied to an expression is a GNU extension">,
InGroup<GNUAlignofExpression>;
def warn_microsoft_dependent_exists : Warning<
"dependent %select{__if_not_exists|__if_exists}0 declarations are ignored">,
@@ -119,17 +119,17 @@
"_Noreturn functions are a C11-specific feature">, InGroup<C11>;
def ext_gnu_indirect_goto : Extension<
- "use of GNU indirect-goto extension">, InGroup<GNU>;
+ "use of GNU indirect-goto extension">, InGroup<GNULabelsAsValue>;
def ext_gnu_address_of_label : Extension<
- "use of GNU address-of-label extension">, InGroup<GNU>;
+ "use of GNU address-of-label extension">, InGroup<GNULabelsAsValue>;
def ext_gnu_local_label : Extension<
- "use of GNU locally declared label extension">, InGroup<GNU>;
+ "use of GNU locally declared label extension">, InGroup<GNULocalLabel>;
def ext_gnu_statement_expr : Extension<
- "use of GNU statement expression extension">, InGroup<GNU>;
+ "use of GNU statement expression extension">,
InGroup<GNUStatementExpression>;
def ext_gnu_conditional_expr : Extension<
- "use of GNU ?: expression extension, eliding middle term">, InGroup<GNU>;
+ "use of GNU ?: conditional expression extension, omitting middle operand">,
InGroup<GNUConditionalOmittedOperand>;
def ext_gnu_empty_initializer : Extension<
- "use of GNU empty initializer extension">, InGroup<GNU>;
+ "use of GNU empty initializer extension">, InGroup<GNUEmptyInitializer>;
def ext_gnu_array_range : Extension<"use of GNU array range extension">,
InGroup<GNUDesignator>;
def ext_gnu_missing_equal_designator : ExtWarn<
@@ -140,7 +140,7 @@
"use of GNU old-style field designator extension">,
InGroup<GNUDesignator>;
def ext_gnu_case_range : Extension<"use of GNU case range extension">,
- InGroup<GNU>;
+ InGroup<GNUCaseRange>;
// Generic errors.
def err_expected_expression : Error<"expected expression">;
Index: test/Sema/gnu-flags.c
===================================================================
--- test/Sema/gnu-flags.c (revision 0)
+++ test/Sema/gnu-flags.c (revision 0)
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL \
+// RUN: -Wgnu-alignof-expression -Wgnu-case-range -Wgnu-complex-integer
-Wgnu-conditional-omitted-operand \
+// RUN: -Wgnu-empty-initializer -Wgnu-label-as-value -Wgnu-local-label
-Wgnu-statement-expression
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wgnu \
+// RUN: -Wno-gnu-alignof-expression -Wno-gnu-case-range
-Wno-gnu-complex-integer -Wno-gnu-conditional-omitted-operand \
+// RUN: -Wno-gnu-empty-initializer -Wno-gnu-label-as-value
-Wno-gnu-local-label -Wno-gnu-statement-expression
+// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF
-Wgnu-alignof-expression
+// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DNONE
-Wno-gnu-alignof-expression
+// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -DCASERANGE
-Wgnu-case-range
+// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -DCOMPLEXINT
-Wgnu-complex-integer
+// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -DOMITTEDOPERAND
-Wgnu-conditional-omitted-operand
+// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -DEMPTYINIT
-Wgnu-empty-initializer
+// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -DLABELVALUE
-Wgnu-label-as-value
+// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -DLOCALLABEL
-Wgnu-local-label
+// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -DSTATEMENTEXP
-Wgnu-statement-expression
+
+#if NONE
+// expected-no-diagnostics
+#endif
+
+
+#if ALL || ALIGNOF
+// expected-warning@+4 {{'_Alignof' applied to an expression is a GNU
extension}}
+#endif
+
+char align;
+_Static_assert(_Alignof(align) == 1, "align's alignment is wrong");
+
+
+#if ALL || CASERANGE
+// expected-warning@+5 {{use of GNU case range extension}}
+#endif
+
+void caserange(int x) {
+ switch (x) {
+ case 42 ... 44: ;
+ }
+}
+
+
+#if ALL || COMPLEXINT
+// expected-warning@+3 {{complex integer types are a GNU extension}}
+#endif
+
+_Complex short int complexint;
+
+
+#if ALL || OMITTEDOPERAND
+// expected-warning@+3 {{use of GNU ?: conditional expression extension,
omitting middle operand}}
+#endif
+
+static const char* omittedoperand = (const char*)0 ?: "Null";
+
+
+#if ALL || EMPTYINIT
+// expected-warning@+3 {{use of GNU empty initializer extension}}
+#endif
+
+struct { int x; } emptyinit = {};
+
+
+#if ALL || LABELVALUE
+// expected-warning@+6 {{use of GNU address-of-label extension}}
+// expected-warning@+7 {{use of GNU indirect-goto extension}}
+#endif
+
+void labelvalue() {
+ void *ptr;
+ ptr = &&foo;
+foo:
+ goto *ptr;
+}
+
+
+#if ALL || LOCALLABEL
+// expected-warning@+5 {{use of GNU locally declared label extension}}
+#endif
+
+void locallabel() {
+ {
+ __label__ foo;
+ goto foo;
+foo:
+ ;
+ }
+}
+
+
+#if ALL || STATEMENTEXP
+// expected-warning@+5 {{use of GNU statement expression extension}}
+#endif
+
+void statementexp()
+{
+ int a = ({ 1; });
+}
explicit-gnu-flags.diff
Description: Binary data
-- Keyboard Maestro 6.1 now out - set web checkboxes & radio buttons, exit from loops, and more. Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac <http://www.stairways.com/> <http://download.keyboardmaestro.com/>
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
