[PATCH] Add more specific lexer flags for misc GNU extensions
Peter N Lewis
peter at stairways.com.au
Tue Sep 3 19:54:28 PDT 2013
On 03/09/2013, at 10:13 , Eli Friedman <eli.friedman at gmail.com> wrote:
> LGTM.
Can you commit this, or does it require a second?
Thanks,
Peter.
>
> -Eli
>
>
> On Fri, Aug 30, 2013 at 12:35 AM, Peter N Lewis <peter at stairways.com.au> wrote:
> On 30/08/2013, at 10:12 , Eli Friedman <eli.friedman at gmail.com> wrote:
> > On Thu, Aug 29, 2013 at 6:58 PM, Peter N Lewis <peter at stairways.com.au> wrote:
> > On 30/08/2013, at 6:34 , Eli Friedman <eli.friedman at gmail.com> wrote:
> > > +// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DZEROARGS -Wgnu-zero-variadic-macro-arguments
> > > +// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DIMAGINARYCONST -Wgnu-imaginary-constant
> > > +// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DBINARYLITERAL -Wgnu-binary-literal
> > > +// RUNNOT: %clang_cc1 -fsyntax-only -verify %s -DLINE0 -Wgnu-zero-line-directive
> > >
> > > I haven't seen RUNNOT before; is that some sort of new syntax?
> >
> > They are just disabled RUN statements - disabled by default to cut down on excessive invocations of the tests. If there is a better syntax to indicate "you could run this test if you want to, but we wont run it every time for everyone", let me know. I initially tried // DONTRUN: but that still runs (I guess the parser looks for RUN:).
> >
> > Please don't make it looks like a RUN command if it isn't intended to run. You can just make a list with a header like "additional tests" and have a list of unprefixed commands.
>
> OK, changed.
>
> Index: test/Lexer/gnu-flags.c
> ===================================================================
> --- test/Lexer/gnu-flags.c (revision 0)
> +++ test/Lexer/gnu-flags.c (revision 0)
> @@ -0,0 +1,56 @@
> +// RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE
> +// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu
> +// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL \
> +// RUN: -Wgnu-zero-variadic-macro-arguments \
> +// RUN: -Wgnu-imaginary-constant -Wgnu-binary-literal -Wgnu-zero-line-directive
> +// RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wgnu \
> +// RUN: -Wno-gnu-zero-variadic-macro-arguments \
> +// RUN: -Wno-gnu-imaginary-constant -Wno-gnu-binary-literal -Wno-gnu-zero-line-directive
> +// Additional disabled tests:
> +// %clang_cc1 -fsyntax-only -verify %s -DZEROARGS -Wgnu-zero-variadic-macro-arguments
> +// %clang_cc1 -fsyntax-only -verify %s -DIMAGINARYCONST -Wgnu-imaginary-constant
> +// %clang_cc1 -fsyntax-only -verify %s -DBINARYLITERAL -Wgnu-binary-literal
> +// %clang_cc1 -fsyntax-only -verify %s -DLINE0 -Wgnu-zero-line-directive
> +
> +#if NONE
> +// expected-no-diagnostics
> +#endif
> +
> +
> +#if ALL || ZEROARGS
> +// expected-warning at +9 {{must specify at least one argument for '...' parameter of variadic macro}}
> +// expected-note at +4 {{macro 'efoo' defined here}}
> +// expected-warning at +3 {{token pasting of ',' and __VA_ARGS__ is a GNU extension}}
> +#endif
> +
> +#define efoo(format, args...) foo(format , ##args)
> +
> +void foo( const char* c )
> +{
> + efoo("6");
> +}
> +
> +
> +#if ALL || IMAGINARYCONST
> +// expected-warning at +3 {{imaginary constants are a GNU extension}}
> +#endif
> +
> +float _Complex c = 1.if;
> +
> +
> +#if ALL || BINARYLITERAL
> +// expected-warning at +3 {{binary integer literals are a GNU extension}}
> +#endif
> +
> +int b = 0b0101;
> +
> +
> +// This case is handled differently because lit has a bug whereby #line 0 is reported to be on line 4294967295
> +// http://llvm.org/bugs/show_bug.cgi?id=16952
> +#if ALL || LINE0
> +#line 0 // expected-warning {{#line directive with zero argument is a GNU extension}}
> +#else
> +#line 0
> +#endif
> +
> +// WARNING: Do not add more tests after the #line 0 line! Add them before the LINE0 test
> Index: include/clang/Basic/DiagnosticGroups.td
> ===================================================================
> --- include/clang/Basic/DiagnosticGroups.td (revision 189654)
> +++ include/clang/Basic/DiagnosticGroups.td (working copy)
> @@ -28,6 +28,7 @@
> def Availability : DiagGroup<"availability">;
> def Section : DiagGroup<"section">;
> def AutoImport : DiagGroup<"auto-import">;
> +def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">;
> def BitFieldConstantConversion : DiagGroup<"bitfield-constant-conversion">;
> def ConstantConversion :
> DiagGroup<"constant-conversion", [ BitFieldConstantConversion ] >;
> @@ -152,6 +153,7 @@
> def DanglingElse: DiagGroup<"dangling-else">;
> def DanglingField : DiagGroup<"dangling-field">;
> def DistributedObjectModifiers : DiagGroup<"distributed-object-modifiers">;
> +def GNUImaginaryConstant : DiagGroup<"gnu-imaginary-constant">;
> def IgnoredQualifiers : DiagGroup<"ignored-qualifiers">;
> def : DiagGroup<"import">;
> def IncompatiblePointerTypesDiscardsQualifiers
> @@ -369,6 +371,8 @@
> def VolatileRegisterVar : DiagGroup<"volatile-register-var">;
> def Visibility : DiagGroup<"visibility">;
> def ZeroLengthArray : DiagGroup<"zero-length-array">;
> +def GNUZeroLineDirective : DiagGroup<"gnu-zero-line-directive">;
> +def GNUZeroVariadicMacroArguments : DiagGroup<"gnu-zero-variadic-macro-arguments">;
>
> // GCC calls -Wdeprecated-writable-strings -Wwrite-strings.
> def GCCWriteStrings : DiagGroup<"write-strings" , [DeprecatedWritableStr]>;
> @@ -535,14 +539,15 @@
> def C99 : DiagGroup<"c99-extensions">;
>
> // A warning group for warnings about GCC extensions.
> -def GNU : DiagGroup<"gnu", [GNUAlignofExpression, GNUCaseRange,
> - GNUComplexInteger,
> +def GNU : DiagGroup<"gnu", [GNUAlignofExpression, GNUBinaryLiteral,
> + GNUCaseRange, GNUComplexInteger,
> GNUConditionalOmittedOperand,
> GNUDesignator, GNUEmptyInitializer,
> VLAExtension,
> - GNULabelsAsValue,
> + GNUImaginaryConstant, GNULabelsAsValue,
> GNUStatementExpression, GNUStaticFloatInit,
> - ZeroLengthArray]>;
> + ZeroLengthArray,
> + GNUZeroLineDirective, GNUZeroVariadicMacroArguments]>;
> // A warning group for warnings about code that clang accepts but gcc doesn't.
> def GccCompat : DiagGroup<"gcc-compat">;
>
> Index: include/clang/Basic/DiagnosticLexKinds.td
> ===================================================================
> --- include/clang/Basic/DiagnosticLexKinds.td (revision 189654)
> +++ include/clang/Basic/DiagnosticLexKinds.td (working copy)
> @@ -167,7 +167,7 @@
> "Unicode character literals may not contain multiple characters">;
> def err_exponent_has_no_digits : Error<"exponent has no digits">;
> def ext_imaginary_constant : Extension<
> - "imaginary constants are a GNU extension">, InGroup<GNU>;
> + "imaginary constants are a GNU extension">, InGroup<GNUImaginaryConstant>;
> def err_hexconstant_requires_exponent : Error<
> "hexadecimal floating constants require an exponent">;
> def err_hexconstant_requires_digits : Error<
> @@ -175,7 +175,7 @@
> def ext_hexconstant_invalid : Extension<
> "hexadecimal floating constants are a C99 feature">, InGroup<C99>;
> def ext_binary_literal : Extension<
> - "binary integer literals are a GNU extension">, InGroup<GNU>;
> + "binary integer literals are a GNU extension">, InGroup<GNUBinaryLiteral>;
> def ext_binary_literal_cxx1y : Extension<
> "binary integer literals are a C++1y extension">, InGroup<CXX1y>;
> def warn_cxx11_compat_binary_literal : Warning<
> @@ -322,7 +322,7 @@
> InGroup<DiagGroup<"embedded-directive">>;
> def ext_missing_varargs_arg : Extension<
> "must specify at least one argument for '...' parameter of variadic macro">,
> - InGroup<GNU>;
> + InGroup<GNUZeroVariadicMacroArguments>;
> def ext_empty_fnmacro_arg : Extension<
> "empty macro arguments are a C99 feature">, InGroup<C99>;
> def warn_cxx98_compat_empty_fnmacro_arg : Warning<
> @@ -457,7 +457,7 @@
> "'##' cannot appear at start of macro expansion">;
> def err_paste_at_end : Error<"'##' cannot appear at end of macro expansion">;
> def ext_paste_comma : Extension<
> - "token pasting of ',' and __VA_ARGS__ is a GNU extension">, InGroup<GNU>;
> + "token pasting of ',' and __VA_ARGS__ is a GNU extension">, InGroup<GNUZeroVariadicMacroArguments>;
> def err_unterm_macro_invoc : Error<
> "unterminated function-like macro invocation">;
> def err_too_many_args_in_macro_invoc : Error<
> @@ -482,7 +482,7 @@
> "#line directive requires a positive integer argument">;
> def ext_pp_line_zero : Extension<
> "#line directive with zero argument is a GNU extension">,
> - InGroup<GNU>;
> + InGroup<GNUZeroLineDirective>;
> def err_pp_line_invalid_filename : Error<
> "invalid filename for #line directive">;
> def warn_pp_line_decimal : Warning<
>
>
>
>
>
>
>
--
Keyboard Maestro 6.2 now out - control Mail, reveal a file, format AppleScripts and more.
Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
<http://www.stairways.com/> <http://download.keyboardmaestro.com/>
More information about the cfe-commits
mailing list