[PATCH] Fix crash with --help=^ (PR driver/71063)
Marek Polacek
polacek@redhat.com
Wed May 11 20:40:00 GMT 2016
We crashed when given --help=^ and Kyrill explained why in the PR
(<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71063#c2>). The following
seems as good a fix as any, I think.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2016-05-11 Marek Polacek <polacek@redhat.com>
PR driver/71063
* opts.c (common_handle_option): Detect missing argument for --help^.
* gcc.dg/opts-7.c: New test.
diff --git gcc/opts.c gcc/opts.c
index 0f9431a..71e0779 100644
--- gcc/opts.c
+++ gcc/opts.c
@@ -1640,6 +1640,11 @@ common_handle_option (struct gcc_options *opts,
if (* a == '^')
{
++ a;
+ if (*a == '\0')
+ {
+ error_at (loc, "missing argument to %qs", "--help=^");
+ break;
+ }
pflags = & exclude_flags;
}
else
diff --git gcc/testsuite/gcc.dg/opts-7.c gcc/testsuite/gcc.dg/opts-7.c
index e69de29..c54d0b8 100644
--- gcc/testsuite/gcc.dg/opts-7.c
+++ gcc/testsuite/gcc.dg/opts-7.c
@@ -0,0 +1,6 @@
+/* PR driver/71063 */
+/* Test we don't ICE. */
+/* { dg-do compile } */
+/* { dg-options "--help=^" } */
+
+/* { dg-error "missing argument to" "" { target *-*-* } 0 } */
Marek
More information about the Gcc-patches
mailing list