Re: [PATCH] Honour DriverOnly for enum values in error messages.
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
Re: [PATCH] Honour DriverOnly for enum values in error messages.
On 07/27/2015 01:45 PM, Dominik Vogt wrote: /gcc/ChangeLog * opts-common.c (read_cmdline_option): List DriverOnly enum values as valid only in the error message of the driver, not in the messages of the language compilers. Applied. Thanks! -Andreas-
Re: [PATCH] Honour DriverOnly for enum values in error messages.
On 07/27/2015 05:45 AM, Dominik Vogt wrote: The attached patch fixes a glicht in the error message generated for invalid values of enum options. When a "DriverOnly" option was passed directoy top the compiler, it would still list that as valid in the error message, e.g. on s390: $ cc1 <...> -march=native cc1: error: unrecognized argument in option ‘-march=native’ cc1: note: valid arguments to ‘-march=’ are: g5 g6 native z10 z13 z196 z9-109 z9-ec z900 z990 zEC12 The patched code prints DriverOnly enum values only when the driver generates the error message. Ciao Dominik ^_^ ^_^ -- Dominik Vogt IBM Germany 0001-ChangeLog /gcc/ChangeLog * opts-common.c (read_cmdline_option): List DriverOnly enum values as valid only in the error message of the driver, not in the messages of the language compilers. OK. jeff
[PATCH] Honour DriverOnly for enum values in error messages.
The attached patch fixes a glicht in the error message generated for invalid values of enum options. When a "DriverOnly" option was passed directoy top the compiler, it would still list that as valid in the error message, e.g. on s390: $ cc1 <...> -march=native cc1: error: unrecognized argument in option ‘-march=native’ cc1: note: valid arguments to ‘-march=’ are: g5 g6 native z10 z13 z196 z9-109 z9-ec z900 z990 zEC12 The patched code prints DriverOnly enum values only when the driver generates the error message. Ciao Dominik ^_^ ^_^ -- Dominik Vogt IBM Germany /gcc/ChangeLog * opts-common.c (read_cmdline_option): List DriverOnly enum values as valid only in the error message of the driver, not in the messages of the language compilers. >From 6d59f56f33804e70ab5be6ced734ed2e95eeea7b Mon Sep 17 00:00:00 2001 From: Dominik Vogt Date: Mon, 27 Jul 2015 12:39:30 +0100 Subject: [PATCH] Honour DriverOnly for enum values in error messages. --- gcc/opts-common.c | 2 ++ 1 file changed, 2 insertions(+) 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] = ' '; -- 2.3.0