[PATCH preprocessor, diagnostics] PR preprocessor/53229 - Fix diagnostics location when pasting tokens

Dodji Seketeli dodji@redhat.com
Mon May 21 14:15:00 GMT 2012


Tom Tromey <tromey@redhat.com> writes:

>>>>>> "Dodji" == Dodji Seketeli <dodji@redhat.com> writes:
>
> Dodji> To properly fix this, I think libcpp should keep the token of the
> Dodji> pasting operator '##', instead of representing it with flag on the LHS
> Dodji> operand's token.  That way, it could use its location.
>
> Originally I had thought that a pasted token should have a special
> virtual location, pointing to the locations of its source tokens.
> This would let later code "undo" the paste, if need be.
>
> I don't know any more if this idea makes sense or not.

I think this makes sense, at least in the grand scheme of things.

The same underlying mechanism that would associate one or several
locations (for instance, the locations of the two operands of the
pasting operator) to a given location (for instance the location for the
token resulting from the pasting operation) could be used to e.g, make a
token carry two locations: one for the beginning of the token, and
another one for the end of the token.

cpp_get_token_with_location would just return the location for the
beginning of the token, like it does today, and we'd be able to retrieve
the second token by mean of the earlier association.

This whole shebang would be then used for the mighty range based
diagnostic[1].

Does that make sense?

[1]: http://gcc.gnu.org/wiki/Better_Diagnostics

-- 
		Dodji



More information about the Gcc-patches mailing list