Commit 56941bf2 by Neil Booth Committed by Neil Booth

cppmacro.c: Don't warn about function-like macros without '(' during pre-expandion.

	* cppmacro.c: Don't warn about function-like macros without
	'(' during pre-expandion.
testsuite:
	* gcc.dg/cpp/tr-warn2.c: Update.

From-SVN: r57366
parent 66a0dfeb
2002-09-20 Neil Booth <neil@daikokuya.co.uk>
* cppmacro.c: Don't warn about function-like macros without
'(' during pre-expandion.
2002-09-20 Jim Wilson <wilson@redhat.com> 2002-09-20 Jim Wilson <wilson@redhat.com>
* config/v850/v850.c (current_function_anonymous_args): Delete. * config/v850/v850.c (current_function_anonymous_args): Delete.
...@@ -1032,10 +1032,15 @@ expand_arg (pfile, arg) ...@@ -1032,10 +1032,15 @@ expand_arg (pfile, arg)
macro_arg *arg; macro_arg *arg;
{ {
unsigned int capacity; unsigned int capacity;
bool saved_warn_trad;
if (arg->count == 0) if (arg->count == 0)
return; return;
/* Don't warn about funlike macros when pre-expanding. */
saved_warn_trad = CPP_WTRADITIONAL (pfile);
CPP_WTRADITIONAL (pfile) = 0;
/* Loop, reading in the arguments. */ /* Loop, reading in the arguments. */
capacity = 256; capacity = 256;
arg->expanded = (const cpp_token **) arg->expanded = (const cpp_token **)
...@@ -1062,6 +1067,8 @@ expand_arg (pfile, arg) ...@@ -1062,6 +1067,8 @@ expand_arg (pfile, arg)
} }
_cpp_pop_context (pfile); _cpp_pop_context (pfile);
CPP_WTRADITIONAL (pfile) = saved_warn_trad;
} }
/* Pop the current context off the stack, re-enabling the macro if the /* Pop the current context off the stack, re-enabling the macro if the
......
2002-09-20 Neil Booth <neil@daikokuya.co.uk>
* gcc.dg/cpp/tr-warn2.c: Update.
2002-09-20 Richard Earnshaw <rearnsha@arm.com> 2002-09-20 Richard Earnshaw <rearnsha@arm.com>
* gcc.c-torture/execute/20020720-1.x: Skip test on ARM-based systems. * gcc.c-torture/execute/20020720-1.x: Skip test on ARM-based systems.
......
/* K+R rejects use of function-like macros in non-function context. /* K+R rejects use of function-like macros in non-function context.
ANSI C explicitly permits this (the macro is not expanded). */ ANSI C explicitly permits this (the macro is not expanded).
/* { dg-do compile } */ We should not warn about this during pre-expansion of arguments,
/* { dg-options -Wtraditional } */ since traditional preprocessors don't do pre-expansion, and we get
the warning anyway during the re-scan pass if and only if it is
enum { SIGN_EXTEND = 23 }; appropriate. */
#define SIGN_EXTEND(v) (((v) < 0) ? -1 : 0) /* { dg-do preprocess } */
/* { dg-options -Wtraditional } */
int fun() #define f(x) x
{ #define g(x) x / 2
return SIGN_EXTEND; /* { dg-warning "must be used with arguments" } */ f(g) (3) /* { dg-bogus "must be used with arguments" } */
} f 2 /* { dg-warning "must be used with arguments" } */
f(g) 3 /* { dg-warning "must be used with arguments" } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment