public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Honour DriverOnly for enum values in error messages.
@ 2015-07-27 12:41 Dominik Vogt
  2015-07-27 17:29 ` Jeff Law
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dominik Vogt @ 2015-07-27 12:41 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andreas Krebbel

[-- Attachment #1: Type: text/plain, Size: 603 bytes --]

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

[-- Attachment #2: 0001-ChangeLog --]
[-- Type: text/plain, Size: 183 bytes --]

/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.

[-- Attachment #3: 0001-Honour-DriverOnly-for-enum-values-in-error-messages.patch --]
[-- Type: text/x-diff, Size: 754 bytes --]

From 6d59f56f33804e70ab5be6ced734ed2e95eeea7b Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Honour DriverOnly for enum values in error messages.
  2015-07-27 12:41 [PATCH] Honour DriverOnly for enum values in error messages Dominik Vogt
@ 2015-07-27 17:29 ` Jeff Law
  2015-07-28  6:52 ` Andreas Krebbel
  2015-07-30 19:13 ` Gunther Nikl
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2015-07-27 17:29 UTC (permalink / raw)
  To: gcc-patches, Andreas Krebbel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Honour DriverOnly for enum values in error messages.
  2015-07-27 12:41 [PATCH] Honour DriverOnly for enum values in error messages Dominik Vogt
  2015-07-27 17:29 ` Jeff Law
@ 2015-07-28  6:52 ` Andreas Krebbel
  2015-07-30 19:13 ` Gunther Nikl
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Krebbel @ 2015-07-28  6:52 UTC (permalink / raw)
  To: gcc-patches, vogt

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-

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Honour DriverOnly for enum values in error messages.
  2015-07-27 12:41 [PATCH] Honour DriverOnly for enum values in error messages Dominik Vogt
  2015-07-27 17:29 ` Jeff Law
  2015-07-28  6:52 ` Andreas Krebbel
@ 2015-07-30 19:13 ` Gunther Nikl
  2 siblings, 0 replies; 4+ messages in thread
From: Gunther Nikl @ 2015-07-30 19:13 UTC (permalink / raw)
  To: vogt; +Cc: Jeff Law, gcc-patches

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-07-30 17:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-27 12:41 [PATCH] Honour DriverOnly for enum values in error messages Dominik Vogt
2015-07-27 17:29 ` Jeff Law
2015-07-28  6:52 ` Andreas Krebbel
2015-07-30 19:13 ` Gunther Nikl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).