[cfe-commits] r159054 - in /cfe/trunk: include/clang/Basic/DiagnosticLexKinds.td lib/Lex/PPMacroExpansion.cpp lib/Lex/TokenLexer.cpp test/Misc/warning-flags.c test/Preprocessor/macro_fn.c test/SemaCXX/cxx98-compat-pedantic.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Fri Jun 22 16:59:08 PDT 2012
Author: rsmith
Date: Fri Jun 22 18:59:08 2012
New Revision: 159054
URL: http://llvm.org/viewvc/llvm-project?rev=159054&view=rev
Log:
Minor improvements to some C99 variadic-macro-related diagnostics.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Lex/TokenLexer.cpp
cfe/trunk/test/Misc/warning-flags.c
cfe/trunk/test/Preprocessor/macro_fn.c
cfe/trunk/test/SemaCXX/cxx98-compat-pedantic.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=159054&r1=159053&r2=159054&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Jun 22 18:59:08 2012
@@ -252,7 +252,7 @@
def ext_pp_bad_vaargs_use : Extension<
"__VA_ARGS__ can only appear in the expansion of a C99 variadic macro">;
def ext_pp_macro_redef : ExtWarn<"%0 macro redefined">;
-def ext_variadic_macro : Extension<"variadic macros were introduced in C99">,
+def ext_variadic_macro : Extension<"variadic macros are a C99 feature">,
InGroup<VariadicMacros>;
def warn_cxx98_compat_variadic_macro : Warning<
"variadic macros are incompatible with C++98">,
@@ -265,12 +265,14 @@
"embedding a directive within macro arguments has undefined behavior">,
InGroup<DiagGroup<"embedded-directive">>;
def ext_missing_varargs_arg : Extension<
- "varargs argument missing, but tolerated as an extension">;
+ "must specify at least one argument for '...' parameter of variadic macro">,
+ InGroup<GNU>;
def ext_empty_fnmacro_arg : Extension<
- "empty macro arguments were standardized in C99">;
+ "empty macro arguments are a C99 feature">, InGroup<C99>;
def warn_cxx98_compat_empty_fnmacro_arg : Warning<
- "empty macro argument list is incompatible with C++98">,
+ "empty macro arguments are incompatible with C++98">,
InGroup<CXX98CompatPedantic>, DefaultIgnore;
+def note_macro_here : Note<"macro %0 defined here">;
def err_pp_invalid_directive : Error<"invalid preprocessing directive">;
def err_pp_file_not_found : Error<"'%0' file not found">, DefaultFatal;
@@ -395,7 +397,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<
- "Use of comma pasting extension is non-portable">;
+ "token pasting of ',' and __VA_ARGS__ is a GNU extension">, InGroup<GNU>;
def err_unterm_macro_invoc : Error<
"unterminated function-like macro invocation">;
def err_too_many_args_in_macro_invoc : Error<
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=159054&r1=159053&r2=159054&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Jun 22 18:59:08 2012
@@ -487,10 +487,12 @@
} else if (MI->isVariadic() &&
(NumActuals+1 == MinArgsExpected || // A(x, ...) -> A(X)
(NumActuals == 0 && MinArgsExpected == 2))) {// A(x,...) -> A()
- // Varargs where the named vararg parameter is missing: ok as extension.
- // #define A(x, ...)
- // A("blah")
+ // Varargs where the named vararg parameter is missing: OK as extension.
+ // #define A(x, ...)
+ // A("blah")
Diag(Tok, diag::ext_missing_varargs_arg);
+ Diag(MI->getDefinitionLoc(), diag::note_macro_here)
+ << MacroName.getIdentifierInfo();
// Remember this occurred, allowing us to elide the comma when used for
// cases like:
Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=159054&r1=159053&r2=159054&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Fri Jun 22 18:59:08 2012
@@ -252,9 +252,9 @@
const Token *ArgToks = ActualArgs->getUnexpArgument(ArgNo);
unsigned NumToks = MacroArgs::getArgLength(ArgToks);
if (NumToks) { // Not an empty argument?
- // If this is the GNU ", ## __VA_ARG__" extension, and we just learned
- // that __VA_ARG__ expands to multiple tokens, avoid a pasting error when
- // the expander trys to paste ',' with the first token of the __VA_ARG__
+ // If this is the GNU ", ## __VA_ARGS__" extension, and we just learned
+ // that __VA_ARGS__ expands to multiple tokens, avoid a pasting error when
+ // the expander trys to paste ',' with the first token of the __VA_ARGS__
// expansion.
if (PasteBefore && ResultToks.size() >= 2 &&
ResultToks[ResultToks.size()-2].is(tok::comma) &&
Modified: cfe/trunk/test/Misc/warning-flags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags.c?rev=159054&r1=159053&r2=159054&view=diff
==============================================================================
--- cfe/trunk/test/Misc/warning-flags.c (original)
+++ cfe/trunk/test/Misc/warning-flags.c Fri Jun 22 18:59:08 2012
@@ -17,7 +17,7 @@
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (241):
+CHECK: Warnings without flags (238):
CHECK-NEXT: ext_anonymous_struct_union_qualified
CHECK-NEXT: ext_binary_literal
CHECK-NEXT: ext_cast_fn_obj
@@ -25,7 +25,6 @@
CHECK-NEXT: ext_designated_init
CHECK-NEXT: ext_duplicate_declspec
CHECK-NEXT: ext_ellipsis_exception_spec
-CHECK-NEXT: ext_empty_fnmacro_arg
CHECK-NEXT: ext_enum_friend
CHECK-NEXT: ext_enum_value_not_int
CHECK-NEXT: ext_enumerator_list_comma
@@ -44,12 +43,10 @@
CHECK-NEXT: ext_integer_increment_complex
CHECK-NEXT: ext_invalid_sign_spec
CHECK-NEXT: ext_missing_declspec
-CHECK-NEXT: ext_missing_varargs_arg
CHECK-NEXT: ext_missing_whitespace_after_macro_name
CHECK-NEXT: ext_new_paren_array_nonconst
CHECK-NEXT: ext_nonstandard_escape
CHECK-NEXT: ext_param_not_declared
-CHECK-NEXT: ext_paste_comma
CHECK-NEXT: ext_plain_complex
CHECK-NEXT: ext_pp_bad_vaargs_use
CHECK-NEXT: ext_pp_comma_expr
Modified: cfe/trunk/test/Preprocessor/macro_fn.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_fn.c?rev=159054&r1=159053&r2=159054&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/macro_fn.c (original)
+++ cfe/trunk/test/Preprocessor/macro_fn.c Fri Jun 22 18:59:08 2012
@@ -4,8 +4,8 @@
#define zero() 0
#define one(x) 0
#define two(x, y) 0
-#define zero_dot(...) 0 /* expected-warning {{variadic macros were introduced in C99}} */
-#define one_dot(x, ...) 0 /* expected-warning {{variadic macros were introduced in C99}} */
+#define zero_dot(...) 0 /* expected-warning {{variadic macros are a C99 feature}} */
+#define one_dot(x, ...) 0 /* expected-warning {{variadic macros are a C99 feature}} expected-note 2{{macro 'one_dot' defined here}} */
zero()
zero(1); /* expected-error {{too many arguments provided to function-like macro invocation}} */
@@ -19,25 +19,25 @@
two() /* expected-error {{too few arguments provided to function-like macro invocation}} */
two(a) /* expected-error {{too few arguments provided to function-like macro invocation}} */
two(a,b)
-two(a, ) /* expected-warning {{empty macro arguments were standardized in C99}} */
+two(a, ) /* expected-warning {{empty macro arguments are a C99 feature}} */
two(a,b,c) /* expected-error {{too many arguments provided to function-like macro invocation}} */
two(
- , /* expected-warning {{empty macro arguments were standardized in C99}} */
- , /* expected-warning {{empty macro arguments were standardized in C99}} \
+ , /* expected-warning {{empty macro arguments are a C99 feature}} */
+ , /* expected-warning {{empty macro arguments are a C99 feature}} \
expected-error {{too many arguments provided to function-like macro invocation}} */
)
-two(,) /* expected-warning 2 {{empty macro arguments were standardized in C99}} */
+two(,) /* expected-warning 2 {{empty macro arguments are a C99 feature}} */
/* PR4006 & rdar://6807000 */
-#define e(...) __VA_ARGS__ /* expected-warning {{variadic macros were introduced in C99}} */
+#define e(...) __VA_ARGS__ /* expected-warning {{variadic macros are a C99 feature}} */
e(x)
e()
zero_dot()
-one_dot(x) /* empty ... argument: expected-warning {{varargs argument missing, but tolerated as an extension}} */
-one_dot() /* empty first argument, elided ...: expected-warning {{varargs argument missing, but tolerated as an extension}} */
+one_dot(x) /* empty ... argument: expected-warning {{must specify at least one argument for '...' parameter of variadic macro}} */
+one_dot() /* empty first argument, elided ...: expected-warning {{must specify at least one argument for '...' parameter of variadic macro}} */
/* rdar://6816766 - Crash with function-like macro test at end of directive. */
Modified: cfe/trunk/test/SemaCXX/cxx98-compat-pedantic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx98-compat-pedantic.cpp?rev=159054&r1=159053&r2=159054&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx98-compat-pedantic.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx98-compat-pedantic.cpp Fri Jun 22 18:59:08 2012
@@ -9,7 +9,7 @@
#line 32768 // expected-warning {{#line number greater than 32767 is incompatible with C++98}}
#define VA_MACRO(x, ...) x // expected-warning {{variadic macros are incompatible with C++98}}
-VA_MACRO(,x) // expected-warning {{empty macro argument list is incompatible with C++98}}
+VA_MACRO(,x) // expected-warning {{empty macro arguments are incompatible with C++98}}
; // expected-warning {{extra ';' outside of a function is incompatible with C++98}}
More information about the cfe-commits
mailing list