[PATCH] Add more specific lexer flags for misc GNU extensions
Eli Friedman
eli.friedman at gmail.com
Thu Aug 29 15:34:51 PDT 2013
+// 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?
-Eli
On Sun, Aug 25, 2013 at 8:04 PM, Peter N Lewis <peter at stairways.com.au>wrote:
> Here is the second take of batch two of the specific gnu flags. This
> patch adds the following flags:
>
> -Wgnu-binary-literal
> -Wgnu-imaginary-constant
> -Wgnu-zero-line-directive
> -Wgnu-zero-variadic-macro-arguments
>
> I have changed "gnu-line-zero-directive" to "gnu-zero-line-directive", as
> well as subsuming "gnu-token-pasting-comma" under
> "gnu-zero-variadic-macro-arguments" so that the latter allows both having
> zero arguments to a variadic macro as well as using the comma token pasting
> feature to remove the extra comma.
>
> Index: test/Lexer/gnu-flags.c
> ===================================================================
> --- test/Lexer/gnu-flags.c (revision 0)
> +++ test/Lexer/gnu-flags.c (revision 0)
> @@ -0,0 +1,55 @@
> +// 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
> +// 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
> +
> +#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 189206)
> +++ 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 189206)
> +++ 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/>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130829/c034eeec/attachment.html>
More information about the cfe-commits
mailing list