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]: Add push_macro/pop_macro feature for all targets by moving it from C frontent into libcpp


2009/11/5 Kai Tietz <ktietz70@googlemail.com>:
> 2009/11/5 Paolo Bonzini <bonzini@gnu.org>:
>> On 11/04/2009 05:25 PM, Tom Tromey wrote:
>>>
>>> Kai> ?-static GTY((param_is (struct def_pragma_macro))) htab_t
>>> pushed_macro_table;
>>>
>>> Do pushed macros work properly with PCH after this patch?
>>
>> I don't think so. ?There is nothing that saves the state, so placing
>>
>> --- test.h ---
>> #define FOO bar
>> #pragma push_macro("FOO")
>> #define FOO baz
>>
>> --- test.c ---
>> #include "test.h"
>> #pragma pop_macro("FOO")
>>
>>
>> would fail because pop_macro would not find FOO on the stack. ?It is
>> extremely unlikely to happen in practice, but it is still a bug. ?You need
>> to modify libcpp/pch.c to fix this.
>>
>> Paolo
>>
>>
>
> Thanks Paolo for pointing this out. It is right that this case should
> be extremely unlikely, but it would be a bug too. So here the patch
> treating the pch case, too.
>
> ChangeLog for libcpp
>
> 2009-11-03 ?Kai Tietz ?<kai.tietz@onevision.com>
>
> ? ? ? ?* directives.c (do_pragma_push_macro): New pragma handler.
> ? ? ? ?(do_pragma_pop_macro): Likewise.
> ? ? ? ?(_cpp_init_internal_pragmas): Add push_macro and
> ? ? ? ?pop_macro handler to internal pragmas.
> ? ? ? ?(lex_macro_node_from_str): Removed.
> ? ? ? ?(cpp_push_definition): Replace lex_macro_node_from_str
> ? ? ? ?by _cpp_lex_identifier.
> ? ? ? ?(cpp_pop_definition): Likewise.
> ? ? ? ?* internal.h (_cpp_lex_identifier): New prototype.
> ? ? ? ?(def_pragma_macro): New structure.
> ? ? ? ?(cpp_reader): New member pushed_macros.
> ? ? ? ?* lex.c (_cpp_lex_identifier): New function.
> ? ? ? ?(lex_identifier_intern): New function.
> ? ? ? ?* init.c (cpp_create_reader): Initialize pushed_macros
> ? ? ? ?member.
> ? ? ? ?(cpp_destroy): Free elements in pushed_macros member.
> ? ? ? ?* pch.c (_cpp_save_pushed_macros): New function.
> ? ? ? ?(_cpp_restore_pushed_macros): Likewise.
> ? ? ? ?(_cpp_restore_pushed_macros): Use _cpp_restore_pushed_macros.
> ? ? ? ?(cpp_read_state): Use _cpp_save_pushed_macros.
>
> ChangeLog for gcc
>
> 2009-11-03 ?Kai Tietz ?<kai.tietz@onevision.com>
>
> ? ? ? ?* config/i386/cygming.h (HANDLE_PRAGMA_PUSH_POP_MACRO):
> ? ? ? ?Removed.
> ? ? ? ?* c-pragma.c (def_pragma_macro_value): Likewise.
> ? ? ? ?(def_pragma_macro): Likewise.
> ? ? ? ?(pushed_macro_table): Likewise.
> ? ? ? ?(HANDLE_PRAGMA_PUSH_POP_MACRO): Remove guarded
> ? ? ? ?code.
> ? ? ? ?* doc/tm.texi (HANDLE_PRAGMA_PUSH_POP_MACRO):
> ? ? ? ?Removed.
>
> ChangeLog for gcc/testsuite
>
> 2009-11-03 ?Kai Tietz ?<kai.tietz@onevision.com>
>
> ? ? ? ?* g++.dg/torture/pushpop_macro.C: New testcase.
> ? ? ? ?* gcc.c-torture/execute/pushpop_macro.c: New testcase.
>
>
> Tested for i686-pc-mingw32, i686-pc-linux, x86_64-pc-mingw32, and for
> i686-pc-cygwin. Ok for applying to trunk and 4.4 branch?
>
> Cheers,
> Kai

Sorry, just noticed that I attached an old patch (which wasn't
tested). Here is the version I've tested.

Kai


-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination

Attachment: mvpushpop.diff
Description: Binary data


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