Dominik Vogt schrieb:
> The attached patch fixes a glicht in the error message generated
> for invalid values of enum options.

IMHO, the patch is incomplete.

> diff --git a/gcc/opts-common.c b/gcc/opts-common.c
> index 8e51974..3bcbaf1 100644
> --- a/gcc/opts-common.c
> +++ b/gcc/opts-common.c
> @@ -1079,6 +1079,8 @@ read_cmdline_option (struct gcc_options *opts,
>        p = s;
>        for (i = 0; e->values[i].arg != NULL; i++)
>    {
> +    if (!enum_arg_ok_for_language (&e->values[i], lang_mask))
> +      continue;
>      size_t arglen = strlen (e->values[i].arg);
>      memcpy (p, e->values[i].arg, arglen);
>      p[arglen] = ' ';

The invalid values are skipped with that change, but there is still
space allocated for them. I propose the following additional patch
if only the space for valid values should be allocated:

-- cut --
diff -up a/gcc/opts-common.c b/gcc/opts-common.c
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -1001,7 +1001,10 @@ read_cmdline_option (struct gcc_options

       len = 0;
       for (i = 0; e->values[i].arg != NULL; i++)
-       len += strlen (e->values[i].arg) + 1;
+       {
+         if (enum_arg_ok_for_language (&e->values[i], lang_mask))
+           len += strlen (e->values[i].arg) + 1;
+       }

       s = XALLOCAVEC (char, len);
       p = s;
-- cut --


Regards,
Gunther

Reply via email to