[4.5] Make cpplib use compiler's diagnostic.c
Manuel López-Ibáñez
lopezibanez@gmail.com
Wed Feb 11 05:15:00 GMT 2009
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.
More information about the Gcc-patches
mailing list