From fb2675cb4683a430fb63af44713cd9d2fcd77b97 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 23 Nov 2016 10:06:07 +0000 Subject: system.h (HAVE_DESIGNATED_INITIALIZERS, [...]): Do not use "defined" in macros. gcc: 2016-11-23 Paolo Bonzini * system.h (HAVE_DESIGNATED_INITIALIZERS, HAVE_DESIGNATED_UNION_INITIALIZERS): Do not use "defined" in macros. * doc/cpp.texi (Defined): Mention -Wexpansion-to-defined. * doc/cppopts.texi (Invocation): Document -Wexpansion-to-defined. * doc/invoke.texi (Warning Options): Document -Wexpansion-to-defined. gcc/c-family: 2016-11-23 Paolo Bonzini * c.opt (Wexpansion-to-defined): New. gcc/testsuite: 2016-11-23 Paolo Bonzini * gcc.dg/cpp/defined.c: Mark newly introduced warnings and adjust for warning->pedwarn change. * gcc.dg/cpp/defined-syshdr.c, gcc.dg/cpp/defined-Wexpansion-to-defined.c, gcc.dg/cpp/defined-Wextra-Wno-expansion-to-defined.c, gcc.dg/cpp/defined-Wextra.c, gcc.dg/cpp/defined-Wno-expansion-to-defined.c: New testcases. libcpp: 2016-11-23 Paolo Bonzini * include/cpplib.h (struct cpp_options): Add new member warn_expansion_to_defined. (CPP_W_EXPANSION_TO_DEFINED): New enum member. * expr.c (parse_defined): Warn for all uses of "defined" in macros, and tie warning to CPP_W_EXPANSION_TO_DEFINED. Make it a pedwarning instead of a warning. * system.h (HAVE_DESIGNATED_INITIALIZERS): Do not use "defined" in macros. From-SVN: r242743 --- gcc/doc/cppopts.texi | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/doc/cppopts.texi') diff --git a/gcc/doc/cppopts.texi b/gcc/doc/cppopts.texi index c5f919a..e349555 100644 --- a/gcc/doc/cppopts.texi +++ b/gcc/doc/cppopts.texi @@ -120,6 +120,12 @@ Warn whenever an identifier which is not a macro is encountered in an @samp{#if} directive, outside of @samp{defined}. Such identifiers are replaced with zero. +@item -Wexpansion-to-defined +@opindex Wexpansion-to-defined +Warn whenever @samp{defined} is encountered in the expansion of a macro +(including the case where the macro is expanded by an @samp{#if} directive). +Such usage is not portable. + @item -Wunused-macros @opindex Wunused-macros Warn about macros defined in the main file that are unused. A macro -- cgit v1.1