Fix PR diagnostic/17594
Matt Kraai
kraai@ftbfs.org
Sun Nov 28 18:29:00 GMT 2004
Howdy,
GCC does not error about unknown options that start with a valid
option because it accepts matches against options that are a prefix of
the input, even if they do not allow joined arguments, as a switch
meant for another language.
The attached patch makes it require that the switch match exactly or
accept a joined argument in order to accept it as meant for another
language. Tested on powerpc-unknown-linux-gnu. OK to commit?
--
Matt
(For gcc)
* opts.c (find_opt): Require that the input match a switch
exactly or that the switch take a joined option to be
interpreted as a match for another language.
(For gcc/testsuite)
* gcc.dg/funroll-loops-all.c: New.
Index: gcc/opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.c,v
retrieving revision 1.88
diff -u -c -3 -p -r1.88 opts.c
*** gcc/opts.c 18 Nov 2004 06:39:47 -0000 1.88
--- gcc/opts.c 28 Nov 2004 17:49:51 -0000
*************** find_opt (const char *input, int lang_ma
*** 176,188 ****
{
const struct cl_option *opt = &cl_options[mn];
! /* Is this switch a prefix of the input? */
! if (!strncmp (input, opt->opt_text + 1, opt->opt_len))
{
! /* If language is OK, and the match is exact or the switch
! takes a joined argument, return it. */
! if ((opt->flags & lang_mask)
! && (input[opt->opt_len] == '\0' || (opt->flags & CL_JOINED)))
return mn;
/* If we haven't remembered a prior match, remember this
--- 176,188 ----
{
const struct cl_option *opt = &cl_options[mn];
! /* Is the input either an exact match or a prefix that takes a
! joined argument? */
! if (!strncmp (input, opt->opt_text + 1, opt->opt_len)
! && (input[opt->opt_len] == '\0' || (opt->flags & CL_JOINED)))
{
! /* If language is OK, return it. */
! if (opt->flags & lang_mask)
return mn;
/* If we haven't remembered a prior match, remember this
/* PR 17594 */
/* { dg-do compile } */
/* { dg-options "-funroll-loops-all" } */
/* { dg-error "unrecognized command line option \"-funroll-loops-all\"" "" { target *-*-* } 0 } */
More information about the Gcc-patches
mailing list