[PATCH 3/6] Emit macro expansion related diagnostics
Dodji Seketeli
dodji@redhat.com
Tue Dec 14 09:42:00 GMT 2010
Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
[...]
>> I see. Though, some of these functions call below the level error and
>> inform by calling pp_base_set_prefix, pp_verbatim and the like. Are
>> those pp_* calls intended as well?
>
> Yes, that is another dimension to the diagnostic machinery.
> The idea here is that every client (i.e. front-end) may have som
> front-end specific actions to take (e.g. printing template instantiation
> contexts) before the core diagnostic message is printed. That
> is the role of `diagnostic starter' functions (see the comments
> in diagnostic.h). Similarly we have `diagnostic finalizer' functions
> which are supposed to do any sort of `cleanup' after a diagnostic
> is printed.
OK. And front-ends are supposed to be able to provide their own
diagnostics starter and finalizer functions.
> Now, you can consider CPP as a sort of front-end that turns
> raw input file into a stream of tokens which is then handed over
> to the C or C++ parsers -- but I'm not sure that is the way it currently
> works.
A sort of front-end indeed.
[..]
>> Okay, so I guess I will move the macro expansion unwinder into CPP and
>> make it and use the CPP diagnostic routines that in turn use c_cpp_error
>> (via the cpp_reader callbacks) that is at the same level as inform()
>> error() etc.
>
> It is my belief that the macro-expansion related diagnostics specific
> improvements belong there.
>
>>
>> I will still have to make default_diagnostic_finalizer call that
>> unwinder to make macro expansion context be printed implicitely, though.
>
> something you can't do with CPP specific diagnostic finalizer?
Good catch. The thing is CPP is used like a library by the front-end (C,
C++, Fortran) that needs to consume the tokens it generates. As such,
CPP itself doesn't override the diagnostic finalizer. It's the front-end
that does it. And right now the C and Fortran FEs just use the default
diagnostic finalizer.
If I underrstand correctly, I should now provide a specific diagnostic
finalizer for C and Fortran FEs (like what G++ does) and have them call
the macro expansion unwinder (that would be) provided by CPP and leave
default_diagnostic_finalizer alone.
--
Dodji
More information about the Gcc-patches
mailing list