GTY as attributes

Taras Glek tglek@mozilla.com
Sat Feb 23 01:05:00 GMT 2008


Hey Geoff,
I've learned that you are the author of gengtype/GTY stuff from #gcc.

Would you consider restructuring GTY markers to be more like GCC 
attributes? I'm writing code to generate code to convert GCC trees to 
JavaScript objects for my GCC plugin. Clearly this is similar to what 
gengtype does. However, I would like to reuse GTY markers without using 
the gengtype parser. Since I already use the GCC asts, it would be handy 
if GTYs were just gnu attributes.

I think it was also be beneficial to do GTYs as gcc attributes for 
consistency instead of having yet another language extension.

So far I've defined GTY as
#define GTY(x) __attribute__((user (#x)))

Which appears to work for most cases except for numerous cases of

typedef struct Name GTY(()) {
};

These would parse fine as attributes if they were more like

typedef struct GTY(()) Name  {
};

Would you be willing to accept such a change?

Another possible benefit of raising GTYs to attribute status would be 
that other projects could do compile-time reflection similar to what GCC 
does in a semi-formal way.

Thanks,
Taras

ps. For more info on my plugin see http://wiki.mozilla.org/Dehydra_GCC



More information about the Gcc mailing list