Commit 476f2869 by Zack Weinberg Committed by Zack Weinberg

cpplex.c (maybe_macroexpand): Warn about function-like macros used in…

cpplex.c (maybe_macroexpand): Warn about function-like macros used in non-function context, if -Wtraditional.

	* cpplex.c (maybe_macroexpand): Warn about function-like
	macros used in non-function context, if -Wtraditional.

From-SVN: r34183
parent 40aaba2b
2000-05-25 Zack Weinberg <zack@wolery.cumb.org>
* cpplex.c (maybe_macroexpand): Warn about function-like
macros used in non-function context, if -Wtraditional.
2000-05-25 Mark Mitchell <mark@codesourcery.com> 2000-05-25 Mark Mitchell <mark@codesourcery.com>
* recog.c (peephole2_optimize): Use INSN_P. * recog.c (peephole2_optimize): Use INSN_P.
...@@ -1687,6 +1687,12 @@ maybe_macroexpand (pfile, written) ...@@ -1687,6 +1687,12 @@ maybe_macroexpand (pfile, written)
not_macro_call: not_macro_call:
if (macbuf_whitespace) if (macbuf_whitespace)
CPP_PUTC (pfile, ' '); CPP_PUTC (pfile, ' ');
/* K+R treated this as a hard error. */
if (CPP_OPTION (pfile, warn_traditional))
cpp_warning (pfile,
"traditional C rejects function macro %s in non-function context",
hp->name);
return 0; return 0;
} }
} }
......
/* K+R rejects use of function-like macros in non-function context.
ANSI C explicitly permits this (the macro is not expanded). */
/* { dg-do compile } */
/* { dg-options -Wtraditional } */
enum { SIGN_EXTEND = 23 };
#define SIGN_EXTEND(v) (((v) < 0) ? -1 : 0)
int fun(void)
{
return SIGN_EXTEND; /* { dg-warning "in non-function context" } */
}
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