[patch]: Add push_macro/pop_macro feature for all targets by moving it from C frontent into libcpp

Kai Tietz ktietz70@googlemail.com
Wed Nov 4 17:05:00 GMT 2009


2009/11/4 Tom Tromey <tromey@redhat.com>:
>>>>>> "Kai" == Kai Tietz <ktietz70@googlemail.com> writes:
>
> Tom> I would prefer that all new errors pass an explicit location.
> Tom> This occurs a couple of times.
>
> Kai> This is didn't got. What you mean here about explicit location? You
> Kai> mean special messages for syntactical errors here?
>
> What I meant is, for a new error, use the cpp_error_with_line function
> and pass in the proper location explicitly.  Sometimes (I didn't check
> this code) this is not easy, in which case it is ok to skip it.
>
> Kai> -/* Like lex_macro_node, but read the input from STR.  */
> Kai> -static cpp_hashnode *
> Kai> -lex_macro_node_from_str (cpp_reader *pfile, const char *str)
>
> What is the rationale for this part of the change?

The issue I had here was, that the old code wasn't usable within the
pragma parsing. As I use the internal identifier lex function for
getting the cpp_hashnode for an name, this static function was simply
not used anymore.

> Kai> -static GTY((param_is (struct def_pragma_macro))) htab_t pushed_macro_table;
>
> Do pushed macros work properly with PCH after this patch?

As far as my test have shown for i686-pc-linux, it works now pretty well.

> This is looking pretty good.
>
> Tom
>

I added to the patch the cleanup of the tm.texi part about target
macro HANDLE_PRAGMA_PUSH_POP_MACRO,

ChangeLog for libcpp

2009-11-04  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.

ChangeLog for gcc

2009-11-04  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-04  Kai Tietz  <kai.tietz@onevision.com>

	* g++.dg/torture/pushpop_macro.C: New testcase.
	* gcc.c-torture/execute/pushpop_macro.c: New testcase.


Ok for apply?

Cheers,
Kai

-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mvpushpop.diff
Type: application/octet-stream
Size: 16584 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20091104/7a02cac1/attachment.obj>


More information about the Gcc-patches mailing list