I get with the testcase I'm about to attach:
[eric@localhost]$ gcc-4.0 -S -Wall pragma_bug.ii
/home/eric/cvs/gcc/libjava/java/lang/natClass.cc:34: warning: ignoring #pragma
With 3.4.3pre, all works fine. This is critical on Solaris because there are
#pragma ident all over the place in the header files. This also prevents libgcj
from building on Solaris.
Created attachment 7385 [details]
Testcase extracted from libgcj.
: Search converges between 2004-09-20-161001-trunk (#551) and 2004-09-21-094824-trunk
Almost certain caused by:
2004-09-20 Matt Austern <firstname.lastname@example.org>
Zack Weinberg <email@example.com>
* decl.c (make_rtl_for_nonlocal_decl, start_preparsed_function):
Apply lbasename to input_filename before passing to get_fileinfo.
* semantics.c (begin_class_definition): Likewise.
* lex.c (handle_pragma_interface): Apply get_fileinfo to the
correct filename. Rename variables to be less confusing.
(handle_pragma_implementation): Likewise. Disable "appears
after file is included" diagnostic.
* parser.c (struct cp_token): Add in_system_header fiag.
(CP_TOKEN_BLOCK_NUM_TOKENS, struct cp_token_block)
Zack, Matt, may I ask you to take a look at this one? This is really critical
on Solaris for the reasons I exposed in my initial filing. And I'd like to have
the sparc*-sun-solaris2* platforms bootstrap before 4.0.0 is branched. TIA.
Subject: Re: [4.0 Regression] #pragma implementation broken in presence of #pragma ident
Matt Austern <firstname.lastname@example.org> writes:
> Never mind, I see that there is a test case. Unfortunately, #pragma
> ident is ignored on both Linux and Darwin, and, as I said, I don't have
> access to a Solaris system. Any suggestions about other systems where
> #pragma ident might do something?
It turns out that #pragma ident is ignored on Solaris, too. The bug
is actually with the logic that issues the (optional, but on with
-Wall) warning for skipping an unknown #pragma. This logic tries to
figure out whether it's in a system header, on the usual theory that
you don't want warnings from the system headers. I'm not exactly sure
how it's doing that, but it is confused by lex-up-front operation,
such that it thinks the last #pragma ident in the test case is _not_
in a system header. Also, the data structures used to _print_ the
diagnostic are not valid in lex-up-front operation either, which is
why it says the nonsensical "ignoring #pragma ident implementation".
The most sensible fix seems to be to not defer unknown pragmas in the
first place. This means cb_def_pragma will be called at a point when
the data structures it's trying to use are still valid, and everything
just works. This also addresses Joseph's comment on the original
#pragma-handling speedup, that unknown pragmas ought to be ignored
wherever they appear.
Due to indentation changes the patch is a lot longer than it ought to
be. The functional change is to move the 'else if (defer_pragmas)'
block inside the 'if (p)' block.
In case anyone is wondering, this should not have any noticeable
effect on -E mode; all pragmas go through cb_def_pragma in that mode,
but it's a different implementation of the callback.
(The change to cb_def_pragma in the patch below is not directly
germane to the bugfix. I thought the code there might be, at least,
the cause of the completely bogus line number in the diagnostic. This
proved not to be so, but what was being done was horrible and just
plain needed killin', anyway.)
Eric, can you test this patch in your Solaris setup? I have not tried
to build libjava on our Solaris machine before, and in any case that
machine is appallingly slow.
Created attachment 7415 [details]
> It turns out that #pragma ident is ignored on Solaris, too.
Yes, the bug is fully reproducible anywhere. That's why I put *-*-* as the
> Eric, can you test this patch in your Solaris setup?
It works just fine (libjava builds and gives decent testsuite results).
> I have not tried to build libjava on our Solaris machine before, and in any
> case that machine is appallingly slow.
You certainly meant libjava is appallingly bloated. ;-) Yes, I confirm.
Thanks for quickly tackling the problem.
Comment on attachment 7415 [details]
fix mime type, mark as patch
Subject: Bug 18075
Module name: gcc
Changes by: email@example.com 2004-10-27 17:29:31
libcpp : ChangeLog directives.c
* directives.c (do_pragma): Do not defer pragmas which are unknown.
(cpp_handle_deferred_pragma): Add cast to silence warning.