Patchwork c-pragma: adding a data field to pragma_handler

login
register
mail settings
Submitter Basile Starynkevitch
Date June 9, 2011, 6:16 a.m.
Message ID <20110609081635.6a3c0ad2.basile@starynkevitch.net>
Download mbox | patch
Permalink /patch/99617/
State New
Headers show

Comments

Basile Starynkevitch - June 9, 2011, 6:16 a.m.
On Wed, 08 Jun 2011 23:26:39 +0200
Pierre Vittet <piervit@pvittet.com> wrote:

> I have written a test for this patch and run it (it works correctly). I 
> guess there is no reason why it should not be accepted now.
> To recap, this patch add a void * data field to the pragma handler, 
> allowing to pass extra data. If we want to use this field, we need to 
> use the function c_register_pragma_with_data or 
> c_register_pragma_with_expansion_and_data. The old 
> c_register_pragma(_with_expansion) is kept compatible.



I hope your patch will be ok-ed with that small change.

Perhaps a future patch would free that registered_pragmas vector, but I
feel that is not necessary, since it is not a big vector in practice.

Regards.

Patch

===================================================================
--- gcc/c-family/c-pragma.c	(revision 174521)
+++ gcc/c-family/c-pragma.c	(working copy)
@@ -1148,12 +1148,12 @@  handle_pragma_float_const_decimal64 (cpp_reader
*A }
 
 /* A vector of registered pragma callbacks.  */
+/* This is never freed as we need it during the whole execution.  */
+DEF_VEC_O (internal_pragma_handler);
+DEF_VEC_ALLOC_O (internal_pragma_handler, heap);

Sorry to be picky Pierre, but that comment is not correct. It should be
instead.

/* A vector of registered pragma callbacks, which is never freed.   */

What I mean is that you are right that the vector is never freed, but
it is not because it is needed during the entire execution, since
middle-end and back-end passes don't know about pragmas.