Commit a5fbf76d by Marek Polacek Committed by Marek Polacek

re PR driver/71063 (ICE: Segmentation fault with --help="^")

	PR driver/71063
	* opts.c (common_handle_option): Detect missing argument for --help^.

	* gcc.dg/opts-7.c: New test.

From-SVN: r236170
parent 5acc47a4
2016-05-12 Marek Polacek <polacek@redhat.com>
PR driver/71063
* opts.c (common_handle_option): Detect missing argument for --help^.
2016-05-12 Kyrylo Tkachov <kyrylo.tkachov@arm.com> 2016-05-12 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR target/70830 PR target/70830
......
...@@ -1595,7 +1595,7 @@ common_handle_option (struct gcc_options *opts, ...@@ -1595,7 +1595,7 @@ common_handle_option (struct gcc_options *opts,
case OPT__help_: case OPT__help_:
{ {
const char * a = arg; const char *a = arg;
unsigned int include_flags = 0; unsigned int include_flags = 0;
/* Note - by default we include undocumented options when listing /* Note - by default we include undocumented options when listing
specific classes. If you only want to see documented options specific classes. If you only want to see documented options
...@@ -1612,11 +1612,11 @@ common_handle_option (struct gcc_options *opts, ...@@ -1612,11 +1612,11 @@ common_handle_option (struct gcc_options *opts,
arg = [^]{word}[,{arg}] arg = [^]{word}[,{arg}]
word = {optimizers|target|warnings|undocumented| word = {optimizers|target|warnings|undocumented|
params|common|<language>} */ params|common|<language>} */
while (* a != 0) while (*a != 0)
{ {
static const struct static const struct
{ {
const char * string; const char *string;
unsigned int flag; unsigned int flag;
} }
specifics[] = specifics[] =
...@@ -1631,19 +1631,24 @@ common_handle_option (struct gcc_options *opts, ...@@ -1631,19 +1631,24 @@ common_handle_option (struct gcc_options *opts,
{ "common", CL_COMMON }, { "common", CL_COMMON },
{ NULL, 0 } { NULL, 0 }
}; };
unsigned int * pflags; unsigned int *pflags;
const char * comma; const char *comma;
unsigned int lang_flag, specific_flag; unsigned int lang_flag, specific_flag;
unsigned int len; unsigned int len;
unsigned int i; unsigned int i;
if (* a == '^') if (*a == '^')
{ {
++ a; ++a;
pflags = & exclude_flags; if (*a == '\0')
{
error_at (loc, "missing argument to %qs", "--help=^");
break;
}
pflags = &exclude_flags;
} }
else else
pflags = & include_flags; pflags = &include_flags;
comma = strchr (a, ','); comma = strchr (a, ',');
if (comma == NULL) if (comma == NULL)
...@@ -1680,7 +1685,7 @@ common_handle_option (struct gcc_options *opts, ...@@ -1680,7 +1685,7 @@ common_handle_option (struct gcc_options *opts,
if (specific_flag != 0) if (specific_flag != 0)
{ {
if (lang_flag == 0) if (lang_flag == 0)
* pflags |= specific_flag; *pflags |= specific_flag;
else else
{ {
/* The option's argument matches both the start of a /* The option's argument matches both the start of a
...@@ -1689,7 +1694,7 @@ common_handle_option (struct gcc_options *opts, ...@@ -1689,7 +1694,7 @@ common_handle_option (struct gcc_options *opts,
specified "--help=c", but otherwise we have to issue specified "--help=c", but otherwise we have to issue
a warning. */ a warning. */
if (strncasecmp (a, "c", len) == 0) if (strncasecmp (a, "c", len) == 0)
* pflags |= lang_flag; *pflags |= lang_flag;
else else
warning_at (loc, 0, warning_at (loc, 0,
"--help argument %q.*s is ambiguous, " "--help argument %q.*s is ambiguous, "
...@@ -1698,7 +1703,7 @@ common_handle_option (struct gcc_options *opts, ...@@ -1698,7 +1703,7 @@ common_handle_option (struct gcc_options *opts,
} }
} }
else if (lang_flag != 0) else if (lang_flag != 0)
* pflags |= lang_flag; *pflags |= lang_flag;
else else
warning_at (loc, 0, warning_at (loc, 0,
"unrecognized argument to --help= option: %q.*s", "unrecognized argument to --help= option: %q.*s",
......
2016-05-12 Marek Polacek <polacek@redhat.com>
PR driver/71063
* gcc.dg/opts-7.c: New test.
2016-05-12 Kyrylo Tkachov <kyrylo.tkachov@arm.com> 2016-05-12 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR target/70830 PR target/70830
......
/* PR driver/71063 */
/* Test we don't ICE. */
/* { dg-do compile } */
/* { dg-options "--help=^" } */
/* { dg-error "missing argument to" "" { target *-*-* } 0 } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment