This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] cpp/c: Add -Wexpansion-to-defined


On 09/08/16 16:59, Paolo Bonzini wrote:
Index: gcc/c-family/c-opts.c
===================================================================
--- gcc/c-family/c-opts.c	(revision 239276)
+++ gcc/c-family/c-opts.c	(working copy)
@@ -1256,6 +1256,10 @@ sanitize_cpp_opts (void)
   cpp_opts->unsigned_char = !flag_signed_char;
   cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;

+  cpp_opts->warn_expansion_to_defined = cpp_warn_expansion_to_defined;
+  if (cpp_warn_expansion_to_defined == -1)
+    cpp_warn_expansion_to_defined = pedantic || extra_warnings;
+

Instead of the above, plase use LangEnabledBy() or EnabledBy() in c.opt. See Wendif-labels and other examples. Then, you do not need Init(-1).

   /* Wlong-long is disabled by default. It is enabled by:
       [-Wpedantic | -Wtraditional] -std=[gnu|c]++98 ; or
       [-Wpedantic | -Wtraditional] -std=non-c99
Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt	(revision 239276)
+++ gcc/c-family/c.opt	(working copy)
@@ -506,6 +506,10 @@ Wdouble-promotion
 C ObjC C++ ObjC++ Var(warn_double_promotion) Warning
 Warn about implicit conversions from \"float\" to \"double\".

+Wexpansion-to-defined
+C ObjC C++ ObjC++ CppReason(CPP_W_EXPANSION_TO_DEFINED) Var(cpp_warn_expansion_to_defined) Init(-1) Warning
+Warn if an undefined macro is used in an #if directive.
+

You are also missing CPP(warn_expansion_to_defined) so that the cpp and gcc sides are in sync even when using pragmas.

Cheers,

	Manuel.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]