* [PATCH v2 1/2] PR c/65403 - Ignore -Wno-error=<some-future-warning>
@ 2019-03-20 4:08 Alex Henrie
2019-03-20 4:09 ` [PATCH v2 2/2] PR c/65403 - Add tests for -Wno-error=<some-future-option> Alex Henrie
0 siblings, 1 reply; 2+ messages in thread
From: Alex Henrie @ 2019-03-20 4:08 UTC (permalink / raw)
To: gcc-patches, manu, mliska, joseph
From: Manuel López-Ibáñez <manu@gcc.gnu.org>
* opts.c: Ignore -Wno-error=<some-future-warning> except if there are
other diagnostics.
---
gcc/opts-common.c | 2 ++
gcc/opts-global.c | 10 +++++++---
gcc/opts.c | 5 ++++-
gcc/opts.h | 2 ++
4 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index edbb3ac9b6d..36e06e2372a 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -26,6 +26,8 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic.h"
#include "spellcheck.h"
+vec<const char *> ignored_wnoerror_options;
+
static void prune_options (struct cl_decoded_option **, unsigned int *);
/* An option that is undocumented, that takes a joined argument, and
diff --git a/gcc/opts-global.c b/gcc/opts-global.c
index a5e9ef0237a..bef020a4c46 100644
--- a/gcc/opts-global.c
+++ b/gcc/opts-global.c
@@ -132,12 +132,16 @@ print_ignored_options (void)
{
while (!ignored_options.is_empty ())
{
- const char *opt;
-
- opt = ignored_options.pop ();
+ const char * opt = ignored_options.pop ();
warning_at (UNKNOWN_LOCATION, 0,
"unrecognized command line option %qs", opt);
}
+ while (!ignored_wnoerror_options.is_empty ())
+ {
+ const char * opt = ignored_wnoerror_options.pop ();
+ warning_at (UNKNOWN_LOCATION, 0,
+ "%<-Werror=%s%>: no option -W%s", opt, opt);
+ }
}
/* Handle an unknown option DECODED, returning true if an error should
diff --git a/gcc/opts.c b/gcc/opts.c
index 02f6b4656e1..492a50ba326 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -3087,7 +3087,10 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask,
strcpy (new_option + 1, arg);
option_index = find_opt (new_option, lang_mask);
if (option_index == OPT_SPECIAL_unknown)
- error_at (loc, "%<-Werror=%s%>: no option -%s", arg, new_option);
+ if (value)
+ error_at (loc, "%<-Werror=%s%>: no option -%s", arg, new_option);
+ else
+ ignored_wnoerror_options.safe_push (arg);
else if (!(cl_options[option_index].flags & CL_WARNING))
error_at (loc, "%<-Werror=%s%>: -%s is not an option that controls "
"warnings", arg, new_option);
diff --git a/gcc/opts.h b/gcc/opts.h
index f14d9bcb896..b18504e0bc3 100644
--- a/gcc/opts.h
+++ b/gcc/opts.h
@@ -456,4 +456,6 @@ extern bool parse_and_check_align_values (const char *flag,
bool report_error,
location_t loc);
+extern vec<const char *> ignored_wnoerror_options;
+
#endif
--
2.21.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH v2 2/2] PR c/65403 - Add tests for -Wno-error=<some-future-option>
2019-03-20 4:08 [PATCH v2 1/2] PR c/65403 - Ignore -Wno-error=<some-future-warning> Alex Henrie
@ 2019-03-20 4:09 ` Alex Henrie
0 siblings, 0 replies; 2+ messages in thread
From: Alex Henrie @ 2019-03-20 4:09 UTC (permalink / raw)
To: gcc-patches, manu, mliska, joseph; +Cc: Alex Henrie
---
gcc/testsuite/c-c++-common/pr65403-1.c | 10 ++++++++++
gcc/testsuite/c-c++-common/pr65403-2.c | 15 +++++++++++++++
2 files changed, 25 insertions(+)
create mode 100644 gcc/testsuite/c-c++-common/pr65403-1.c
create mode 100644 gcc/testsuite/c-c++-common/pr65403-2.c
diff --git a/gcc/testsuite/c-c++-common/pr65403-1.c b/gcc/testsuite/c-c++-common/pr65403-1.c
new file mode 100644
index 00000000000..fbe004a1f78
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr65403-1.c
@@ -0,0 +1,10 @@
+/* PR c/65403 */
+/* Test an unrecognized -Wno-error option in the absence of any other
+ diagnostics. The -Wno-error option should be ignored. */
+
+/* { dg-options "-Werror -Wno-error=some-future-warning" } */
+
+int main(int argc, char **argv)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/pr65403-2.c b/gcc/testsuite/c-c++-common/pr65403-2.c
new file mode 100644
index 00000000000..128d4f694a6
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr65403-2.c
@@ -0,0 +1,15 @@
+/* PR c/65403 */
+/* Test a warning, treated as an error, that some future -Wno-error option
+ might downgrade back to a warning. The -Wno-error option should produce a
+ warning in this case. */
+
+/* { dg-options "-Wunused-variable -Werror -Wno-error=some-future-warning" } */
+
+int main(int argc, char **argv)
+{
+ int foo; /* { dg-error "unused variable 'foo'" } */
+ return 0;
+}
+
+/* { dg-error "no option -Wsome-future-warning" "" { target *-*-* } 0 } */
+/* { dg-message "all warnings being treated as errors" "" { target *-*-* } 0 } */
--
2.21.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-20 4:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-20 4:08 [PATCH v2 1/2] PR c/65403 - Ignore -Wno-error=<some-future-warning> Alex Henrie
2019-03-20 4:09 ` [PATCH v2 2/2] PR c/65403 - Add tests for -Wno-error=<some-future-option> Alex Henrie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).