[Bug c/57653] filename information discarded when using -imacros
manu at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jun 25 17:54:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57653
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
--- Comment #18 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
Thanks!
I think I know the reason why it is failing, but I am not sure about the proper
fix.
For some reason unknown to me, push_commandline_include should not be called
while processing -imacros. -imacros tries to achieve this but playing tricks
with include_cursor, but that doesn't stop the pre-included files. Calling
cpp_push_include (or cpp_push_default_include) seems to mess up everything
(again, no idea why!). This code is really a mess but the simple patch below
seems to work. Could you test it?
Index: gcc/c-family/c-opts.c
===================================================================
--- gcc/c-family/c-opts.c (revision 200330)
+++ gcc/c-family/c-opts.c (working copy)
@@ -1338,10 +1338,14 @@ c_finish_options (void)
/* Give CPP the next file given by -include, if any. */
static void
push_command_line_include (void)
{
+ // This can happen if disabled by -imacros for example.
+ if (include_cursor > deferred_count)
+ return;
+
if (!done_preinclude)
{
done_preinclude = true;
if (flag_hosted && std_inc && !cpp_opts->preprocessed)
{
More information about the Gcc-bugs
mailing list