public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* incorrect parsing of -fopt-info
@ 2019-01-21 11:31 Ulrich Drepper
  2019-01-28 12:09 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Ulrich Drepper @ 2019-01-21 11:31 UTC (permalink / raw)
  To: gcc-patches


[-- Attachment #1.1.1: Type: text/plain, Size: 1020 bytes --]

There is a problem with parsing the second part of the -fopt-info
command line parameter in case there is an equal sign followed by a
filename with a dash:

$ g++ -c -O -fopt-info-all=some-file u.cc
cc1plus: warning: unknown option ‘all=some’ in ‘-fopt-info-all=some-file’
cc1plus: error: unrecognized command line option ‘-fopt-info-all=some-file’

The code looks for a '-' and a '=' concurrently but does not ignore the
'-' if it is part of the filename specified after the '='.  The patch
below fixes this.  I also changed the second 'if' into 'else if' which
is clearly always the case but the current code makes it unnecessarily
cumbersome to understand.

This is a highly annoying bug in the right circumstance. I have file
names generated based in the source file name and those include in some
situations dashes.

OK for trunk?

gcc/ChangeLog
2019-01-21  Ulrich Drepper  <drepper@redhat.com>

	* dumpfile.c (opt_info_switch_p_1): Ignore '-' if it appears
	after the '='.



[-- Attachment #1.1.2: d-gcc-opt-info-param --]
[-- Type: text/plain, Size: 505 bytes --]

diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c
index c92bba8efd1..14b6dfea75e 100644
--- a/gcc/dumpfile.c
+++ b/gcc/dumpfile.c
@@ -1915,10 +1915,9 @@ opt_info_switch_p_1 (const char *arg, dump_flags_t *flags,
       end_ptr = strchr (ptr, '-');
       eq_ptr = strchr (ptr, '=');
 
-      if (eq_ptr && !end_ptr)
+      if (eq_ptr && (!end_ptr || eq_ptr < end_ptr))
         end_ptr = eq_ptr;
-
-      if (!end_ptr)
+      else if (!end_ptr)
 	end_ptr = ptr + strlen (ptr);
       length = end_ptr - ptr;
 

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: incorrect parsing of -fopt-info
  2019-01-21 11:31 incorrect parsing of -fopt-info Ulrich Drepper
@ 2019-01-28 12:09 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2019-01-28 12:09 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: GCC Patches

On Mon, Jan 21, 2019 at 12:31 PM Ulrich Drepper <drepper@redhat.com> wrote:
>
> There is a problem with parsing the second part of the -fopt-info
> command line parameter in case there is an equal sign followed by a
> filename with a dash:
>
> $ g++ -c -O -fopt-info-all=some-file u.cc
> cc1plus: warning: unknown option ‘all=some’ in ‘-fopt-info-all=some-file’
> cc1plus: error: unrecognized command line option ‘-fopt-info-all=some-file’
>
> The code looks for a '-' and a '=' concurrently but does not ignore the
> '-' if it is part of the filename specified after the '='.  The patch
> below fixes this.  I also changed the second 'if' into 'else if' which
> is clearly always the case but the current code makes it unnecessarily
> cumbersome to understand.
>
> This is a highly annoying bug in the right circumstance. I have file
> names generated based in the source file name and those include in some
> situations dashes.
>
> OK for trunk?

OK.

Richard.

>
> gcc/ChangeLog
> 2019-01-21  Ulrich Drepper  <drepper@redhat.com>
>
>         * dumpfile.c (opt_info_switch_p_1): Ignore '-' if it appears
>         after the '='.
>
>

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

end of thread, other threads:[~2019-01-28 12:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-21 11:31 incorrect parsing of -fopt-info Ulrich Drepper
2019-01-28 12:09 ` Richard Biener

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