macros used in non-function context, if -Wtraditional.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34183
138bc75d-0d04-0410-961f-
82ee72b054a4
+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>
* recog.c (peephole2_optimize): Use INSN_P.
not_macro_call:
if (macbuf_whitespace)
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;
}
}
--- /dev/null
+/* 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" } */
+}