Hi.

The patch is about proper error message for situations where
user give a wrong argument to -flto option.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

2019-07-29  Martin Liska  <mli...@suse.cz>

        * opts.c (common_handle_option): Error for an invalid argument
        to -flto=.

gcc/testsuite/ChangeLog:

2019-07-29  Martin Liska  <mli...@suse.cz>

        * gcc.dg/spellcheck-options-21.c: New test.
---
 gcc/opts.c                                   | 8 ++++++++
 gcc/testsuite/gcc.dg/spellcheck-options-21.c | 3 +++
 2 files changed, 11 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/spellcheck-options-21.c


diff --git a/gcc/opts.c b/gcc/opts.c
index 296f0f61802..3639edf4cd7 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -2821,6 +2821,14 @@ common_handle_option (struct gcc_options *opts,
       opts->x_flag_lto = value ? "" : NULL;
       break;
 
+    case OPT_flto_:
+      if (strcmp (arg, "none") != 0
+	  && strcmp (arg, "jobserver") != 0
+	  && atoi (arg) == 0)
+	error_at (loc,
+		  "unrecognized argument to %<-flto=%> option: %qs", arg);
+      break;
+
     case OPT_w:
       dc->dc_inhibit_warnings = true;
       break;
diff --git a/gcc/testsuite/gcc.dg/spellcheck-options-21.c b/gcc/testsuite/gcc.dg/spellcheck-options-21.c
new file mode 100644
index 00000000000..3e0e8a8ebaf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/spellcheck-options-21.c
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+/* { dg-options "-flto=sparta" } */
+/* { dg-error "unrecognized argument to '-flto=' option: 'sparta'" "" { target *-*-* } 0 } */

Reply via email to