This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [4.5] Make cpplib use compiler's diagnostic.c
- From: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Wed, 11 Feb 2009 04:24:08 +0100
- Subject: Re: [4.5] Make cpplib use compiler's diagnostic.c
- References: <Pine.LNX.4.64.0902110104410.6547@digraph.polyomino.org.uk>
2009/2/11 Joseph S. Myers <joseph@codesourcery.com>:
>
> Always determining the system-header property based on the location of
> the diagnostic runs into an issue with the warning about the previous
> definition of a macro being redefined. If the redefinition was in a
> system header (so the warning was suppressed) but the previous
> definition was not you could get only the warning about the previous
> definition (this affected one libstdc++ test, with the previous
> definition reported as on the command line). (cpplib used its notion
> of the current location being in a system header rather than the
> location at which the diagnostic is being reported.) This patch
> changes that message to a "note" rather than a pedwarn, as with such
> cases in the compiler, and arranges for the callbacks to check whether
> diagnostics would be reported at input_location. This isn't ideal,
> but an ideal approach might require further changes to the diagnostic
> infrastructure to be able to say "output this note iff the previous
> warning was output, without regard to the location assigned to the
> note".
The diagnostic functions in diagnostic.c already do this, they return
a boolean that is true only if the message was emitted. So you can do
things like:
bool warned = warning();
if(warned) inform();
or even:
warning() &&
inform();
The cpp callback could do the same by propagating the boolean returned
by report_diagnostic.
Cheers,
Manuel.