This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/6] Emit macro expansion related diagnostics


On Tue, Dec 14, 2010 at 12:54 AM, Dodji Seketeli <dodji@redhat.com> wrote:
> The macro expansion context is unwound implicitly. That is, the client
> code calls e.g:
>
> ? ?error_at (some_location, "An error occured")
>
> and if some_location appears to be the location of a token resulting
> from macro expansion the diagnostic machinery unwinds the expansion
> context and displays it to the user, regardless of what the diagnostic
> kind was. ?So the context lines are not prefixed with "<locus> note:" as
> the context is generated implicitely. ?This is similar to what G++ does
> when it displays template instantiation contexts.

Let me add some background about this aspect of the diagnostic
machinery.  The functions inform(), error(), error_at(), etc. are
offered as some `high-level' building blocks for constructing more
advanced diagnostic functions.  It is just that we have not been
very disciplined at factorizing things correctly, and instead we
tend to go for the easier road of `inlining' calls to error() or
inform().   However, models to look for are print_candidates(),
cxx_print_error_function, the newly introduced qualified_name_lookup_errorr,
etc.

The point here is that I would expect CPP to define its own error print
diagnostic function that tracks macro expansion context
(at bit like what what we do with template instantiation contexts)
and combine calls to error_at() and inform().

Note also that we don't capitalize diagnostic messages (and they don't end
with periods either.)

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]