summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2014-08-19 22:37:49 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2014-08-19 22:37:49 +0000
commit43f9a13cee34bbf3f007469d4dd3c3a67e6d8e6d (patch)
tree75764dc68d3b47da1315519f474d62d5a2262f04
parentcd0059f55fc3e14c2b24a4db084064e0da3295a8 (diff)
downloadgcc-43f9a13cee34bbf3f007469d4dd3c3a67e6d8e6d.tar.gz
re PR preprocessor/60975 (-Wvariadic-macros does not print warning)
gcc/ChangeLog: 2014-08-20 Manuel López-Ibáñez <manu@gcc.gnu.org> PR c/60975 PR c/53063 * doc/options.texi (CPP): Document it. * doc/invoke.texi (Wvariadic-macros): Fix documentation. * optc-gen.awk: Handle CPP. * opth-gen.awk: Likewise. gcc/c-family/ChangeLog: 2014-08-20 Manuel López-Ibáñez <manu@gcc.gnu.org> PR c/60975 PR c/53063 * c.opt (Wvariadic-macros): Use CPP and LangEnabledBy. * c-opts.c (c_common_handle_option): Call cpp_handle_option_auto. (c_common_post_options): Call init_global_opts_from_cpp. (sanitize_cpp_opts): Do not handle Wvariadic-macros here. gcc/testsuite/ChangeLog: 2014-08-20 Manuel López-Ibáñez <manu@gcc.gnu.org> PR c/60975 PR c/53063 * gcc.dg/cpp/Wvariadic-1p.c: New test. From-SVN: r214200
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/c-family/ChangeLog9
-rw-r--r--gcc/c-family/c-opts.c9
-rw-r--r--gcc/c-family/c.opt6
-rw-r--r--gcc/doc/invoke.texi7
-rw-r--r--gcc/doc/options.texi5
-rw-r--r--gcc/optc-gen.awk51
-rw-r--r--gcc/opth-gen.awk4
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/cpp/Wvariadic-1p.c8
10 files changed, 104 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ef0673d405a..91c4a1fda95 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2014-08-20 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR c/60975
+ PR c/53063
+ * doc/options.texi (CPP): Document it.
+ * doc/invoke.texi (Wvariadic-macros): Fix documentation.
+ * optc-gen.awk: Handle CPP.
+ * opth-gen.awk: Likewise.
+
2014-08-19 David Malcolm <dmalcolm@redhat.com>
* rtl.h (unlink_insn_chain): Strengthen return type from rtx to
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index e458f5e2250..34a91c8a74c 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,12 @@
+2014-08-20 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR c/60975
+ PR c/53063
+ * c.opt (Wvariadic-macros): Use CPP and LangEnabledBy.
+ * c-opts.c (c_common_handle_option): Call cpp_handle_option_auto.
+ (c_common_post_options): Call init_global_opts_from_cpp.
+ (sanitize_cpp_opts): Do not handle Wvariadic-macros here.
+
2014-08-19 Marek Polacek <polacek@redhat.com>
PR c++/62153
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index b0cad20b4f9..2b423e2174b 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -794,7 +794,8 @@ c_common_handle_option (size_t scode, const char *arg, int value,
default:
gcc_unreachable ();
}
-
+
+ cpp_handle_option_auto (&global_options, scode, cpp_opts);
return result;
}
@@ -1030,6 +1031,7 @@ c_common_post_options (const char **pfilename)
cb->file_change = cb_file_change;
cb->dir_change = cb_dir_change;
cpp_post_options (parse_in);
+ init_global_opts_from_cpp (&global_options, cpp_get_options (parse_in));
input_location = UNKNOWN_LOCATION;
@@ -1310,11 +1312,6 @@ sanitize_cpp_opts (void)
&& (c_dialect_cxx () ? cxx_dialect == cxx98 : !flag_isoc99));
cpp_opts->cpp_warn_long_long = warn_long_long;
- /* Similarly with -Wno-variadic-macros. No check for c99 here, since
- this also turns off warnings about GCCs extension. */
- cpp_opts->warn_variadic_macros
- = cpp_warn_variadic_macros && (pedantic || warn_traditional);
-
/* If we're generating preprocessor output, emit current directory
if explicitly requested or if debugging information is enabled.
??? Maybe we should only do it for debugging formats that
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index f97a11a19cc..f33a42578f8 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -838,9 +838,13 @@ C ObjC C++ ObjC++ Var(warn_unused_result) Init(1) Warning
Warn if a caller of a function, marked with attribute warn_unused_result, does not use its return value
Wvariadic-macros
-C ObjC C++ ObjC++ Var(cpp_warn_variadic_macros) Init(1) Warning
+C ObjC C++ ObjC++ CPP(warn_variadic_macros) Var(cpp_warn_variadic_macros) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic)
Warn about using variadic macros
+Wvariadic-macros
+LangEnabledBy(C ObjC C++ ObjC++,Wtraditional)
+;
+
Wvarargs
C ObjC C++ ObjC++ Warning Var(warn_varargs) Init(1)
Warn about questionable usage of the macros used to retrieve variable arguments
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index b8e42949f21..f8499bc046a 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -5127,9 +5127,10 @@ modes. To inhibit the warning messages, use @option{-Wno-long-long}.
@item -Wvariadic-macros
@opindex Wvariadic-macros
@opindex Wno-variadic-macros
-Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU
-alternate syntax when in pedantic ISO C99 mode. This is default.
-To inhibit the warning messages, use @option{-Wno-variadic-macros}.
+Warn if variadic macros are used in ISO C90 mode, or if the GNU
+alternate syntax is used in ISO C99 mode. This is enabled by either
+@option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
+messages, use @option{-Wno-variadic-macros}.
@item -Wvarargs
@opindex Wvarargs
diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi
index 938017adeac..ac4452e6ff4 100644
--- a/gcc/doc/options.texi
+++ b/gcc/doc/options.texi
@@ -482,4 +482,9 @@ The option is omitted from the producer string written by
@item PchIgnore
Even if this is a target option, this option will not be recorded / compared
to determine if a precompiled header file matches.
+
+@item CPP(@var{var})
+The state of this option should be kept in sync with the preprocessor
+option @var{var}.
+
@end table
diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk
index b70e4fe3aad..ef80c99b6dc 100644
--- a/gcc/optc-gen.awk
+++ b/gcc/optc-gen.awk
@@ -480,4 +480,55 @@ for (i = 0; i < n_langs; i++) {
print "} "
}
+#Handle CPP()
+print "\n"
+print "#include " quote "cpplib.h" quote;
+print "void"
+print "cpp_handle_option_auto (const struct gcc_options * opts, "
+print " size_t scode, struct cpp_options * cpp_opts)"
+print "{ "
+print " enum opt_code code = (enum opt_code) scode; "
+print " "
+print " switch (code) "
+print " { "
+for (i = 0; i < n_opts; i++) {
+ # With identical flags, pick only the last one. The
+ # earlier loop ensured that it has all flags merged,
+ # and a nonempty help text if one of the texts was nonempty.
+ while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
+ i++;
+ }
+
+ cpp_option = nth_arg(0, opt_args("CPP", flags[i]));
+ opt_var_name = var_name(flags[i]);
+ if (cpp_option != "" && opt_var_name != "") {
+ print " case " opt_enum(opts[i]) ":"
+ print " cpp_opts->" cpp_option " = opts->x_" opt_var_name ";"
+ print " break;"
+ }
}
+print " default: "
+print " break; "
+print " } "
+print "}\n"
+print "void"
+print "init_global_opts_from_cpp(struct gcc_options * opts, "
+print " const struct cpp_options * cpp_opts)"
+print "{ "
+for (i = 0; i < n_opts; i++) {
+ # With identical flags, pick only the last one. The
+ # earlier loop ensured that it has all flags merged,
+ # and a nonempty help text if one of the texts was nonempty.
+ while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
+ i++;
+ }
+ cpp_option = nth_arg(0, opt_args("CPP", flags[i]));
+ opt_var_name = var_name(flags[i]);
+ if (cpp_option != "" && opt_var_name != "") {
+ print " opts->x_" opt_var_name " = cpp_opts->" cpp_option ";"
+ }
+}
+print "} "
+
+}
+
diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk
index 45aee342ed3..4e8f21f406b 100644
--- a/gcc/opth-gen.awk
+++ b/gcc/opth-gen.awk
@@ -315,6 +315,10 @@ for (i = 0; i < n_langs; i++) {
print " const struct cl_option_handlers *handlers, "
print " diagnostic_context *dc); "
}
+print "void cpp_handle_option_auto (const struct gcc_options * opts, size_t scode,"
+print " struct cpp_options * cpp_opts);"
+print "void init_global_opts_from_cpp(struct gcc_options * opts, "
+print " const struct cpp_options * cpp_opts);"
print "#endif";
print "#endif";
print "";
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c0d28556127..94f04227a9f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2014-08-20 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR c/60975
+ PR c/53063
+ * gcc.dg/cpp/Wvariadic-1p.c: New test.
+
2014-08-19 Janis Johnson <janisjo@codesourcery.com>
* lib/target-supports.exp
diff --git a/gcc/testsuite/gcc.dg/cpp/Wvariadic-1p.c b/gcc/testsuite/gcc.dg/cpp/Wvariadic-1p.c
new file mode 100644
index 00000000000..84a71082e62
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/Wvariadic-1p.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 " } */
+#pragma GCC diagnostic error "-Wpedantic"
+
+#define f(x,...) /* { dg-error "variadic" } */
+#define g(x,y...) /* { dg-error "variadic" } */
+int not_empty;
+/* { dg-message "warnings being treated as errors" "" { target *-*-* } 0 } */