mirror of https://github.com/microsoft/clang.git
Add specific warning flags for GNU ext in lexer.
This patch adds the following flags covering existing warnings: -Wgnu-zero-variadic-macro-arguments -Wgnu-imaginary-constant -Wgnu-binary-literal -Wgnu-zero-line-directive Patch by Peter Lewis. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190017 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
86164e8f51
commit
a5e77a8909
|
@ -28,6 +28,7 @@ def ArrayBoundsPointerArithmetic : DiagGroup<"array-bounds-pointer-arithmetic">;
|
|||
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 OverloadedShiftOpParentheses: DiagGroup<"overloaded-shift-op-parentheses">;
|
|||
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 VLAExtension : DiagGroup<"vla-extension">;
|
|||
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 C11 : DiagGroup<"c11-extensions">;
|
|||
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">;
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ def err_multichar_utf_character_literal : Error<
|
|||
"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 err_hexconstant_requires_digits : Error<
|
|||
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 @@ def ext_embedded_directive : Extension<
|
|||
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 @@ def err_paste_at_start : Error<
|
|||
"'##' 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 @@ def err_pp_line_requires_integer : Error<
|
|||
"#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<
|
||||
|
|
|
@ -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@+9 {{must specify at least one argument for '...' parameter of variadic macro}}
|
||||
// expected-note@+4 {{macro 'efoo' defined here}}
|
||||
// expected-warning@+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@+3 {{imaginary constants are a GNU extension}}
|
||||
#endif
|
||||
|
||||
float _Complex c = 1.if;
|
||||
|
||||
|
||||
#if ALL || BINARYLITERAL
|
||||
// expected-warning@+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
|
Loading…
Reference in New Issue