Dodji Seketeli <do...@redhat.com> writes:

> Jason Merrill <ja...@redhat.com> writes:
>
>> On 05/24/2012 01:41 PM, Dodji Seketeli wrote:
>
> [...]
>
>>> Another way of seeing it is to say that, from the beginning of
>>> enter_macro_context, we are in a state of "about to expand a macro"
>>> until we actually push the macro context.  So it seems to make sense to
>>> flip the flag where the the macro context push happens, IMHO.
>>
>> Sure, that makes sense.  It just seems better to me to have the flag
>> set a little longer than necessary in order to keep the setting and
>> unsetting closer together for maintainability.
>
> Like the below?  Bootstrap is under way.

FWIW, the patch passed bootstrap and testing on x86_64-unknown-linux-gnu
against trunk.

>     
>     libcpp/
>     
>       PR preprocessor/53229
>       * internal.h (cpp_reader::set_invocation_location): Remove.
>       (cpp_reader::about_to_expand_macro_p): New member flag.
>       * directives.c (do_pragma):  Remove Kludge as
>       pfile->set_invocation_location is no more.
>       * macro.c (cpp_get_token_1): Do away with the use of
>       cpp_reader::set_invocation_location.  Just collect the macro
>       expansion point when we are about to expand the top-most macro.
>       Do not override cpp_reader::about_to_expand_macro_p.
>       This fixes gcc.dg/cpp/paste12.c by making get_token_no_padding
>       properly handle locations of expansion points.
>       (cpp_get_token_with_location): Adjust, as
>       cpp_reader::set_invocation_location is no more.
>       (paste_tokens): Take a virtual location parameter for
>       the LHS of the pasting operator.  Use it in diagnostics.  Update
>       comments.
>       (paste_all_tokens): Tighten the assert.  Propagate the location of
>       the expansion point when no virtual locations are available.
>       Pass the virtual location to paste_tokens.
>       (in_macro_expansion_p): New static function.
>       (enter_macro_context): Set the cpp_reader::about_to_expand_macro_p
>       flag until we really start expanding the macro.
>     
>     gcc/testsuite/
>     
>       PR preprocessor/53229
>       * gcc.dg/cpp/paste6.c: Force to run without
>       -ftrack-macro-expansion.
>       * gcc.dg/cpp/paste8.c: Likewise.
>       * gcc.dg/cpp/paste8-2.c: New test, like paste8.c but run with
>       -ftrack-macro-expansion.
>       * gcc.dg/cpp/paste12.c: Force to run without
>       -ftrack-macro-expansion.
>       * gcc.dg/cpp/paste12-2.c: New test, like paste12.c but run with
>       -ftrack-macro-expansion.
>       * gcc.dg/cpp/paste13.c: Likewise.
>       * gcc.dg/cpp/paste14.c: Likewise.
>       * gcc.dg/cpp/paste14-2.c: New test, like paste14.c but run with
>       -ftrack-macro-expansion.
>       * gcc.dg/cpp/paste18.c: New test.

Thanks.

-- 
                Dodji

Reply via email to