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
* dumpfile.c (opt_info_switch_p_1): Ignore '-' if it appears
after the '='.
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;
signature.asc
Description: OpenPGP digital signature