GTY as attribute

Taras Glek tglek@mozilla.com
Wed Jul 9 21:01:00 GMT 2008


Hello,
I found GTY annotations to be a useful tool for my work. However the
fact that they are not included in the AST is unfortunate. Turns out GTY
can be defined as an attribute with
#define GTY(x) __attribute__((user (("gty:"#x))))
Then all of the handy GTY annotations are reflected in the AST. This
works in most cases except for struct declaration syntax used by GTY is
incompatible with that of attributes.
gengtype requires
  struct name GTY{
syntax whereas attributes require
  struct GTY name {
syntax.

This patch modifies gengtype to accept the attribute declaration style
and modifies GCC headers such that they compile with the above macro.

Please consider this for inclusion in GCC. I think it's conceptually
cleaner to have GTY and attribute conventions match and it opens way to
possibly using GCC itself instead of gengtype's hacky parser for future
GTY revisions.
This will also significantly reduce the maintenance burden for my
project: http://developer.mozilla.org/en/docs/Treehydra where GTY
annotations are used to generate all code to reflect GIMPLE into JavaScript.

Thanks,
Taras

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gty.diff
Type: text/x-diff
Size: 43343 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080709/95fb38a9/attachment.bin>


More information about the Gcc-patches mailing list