aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc/gty.texi
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@gcc.gnu.org>2012-10-12 11:17:17 -0400
committerDiego Novillo <dnovillo@gcc.gnu.org>2012-10-12 11:17:17 -0400
commit313465bbbd04019184339161f0e30a46a5c0e4ab (patch)
tree3f1c4b6afbebcb24454c2dce4ca0c8c5934987c0 /gcc/doc/gty.texi
parentb09e6a7074c0ff5ee74dd0735d5fb10ac450976a (diff)
downloadgcc-313465bbbd04019184339161f0e30a46a5c0e4ab.zip
gcc-313465bbbd04019184339161f0e30a46a5c0e4ab.tar.gz
gcc-313465bbbd04019184339161f0e30a46a5c0e4ab.tar.bz2
Add more C++ support in gengtype.
This patch combines the changes from http://gcc.gnu.org/ml/gcc-patches/2012-08/msg02016.html with other additions to support C++ inside GTY'd structures. The main changes wrt Aaron's original patch are: - Support for function declarations inside classes. - Support scoping in identifiers. This does not mean that gengtype supports scopes, it just knows that 'Foo::id' is a single entity. - Explicit non-support for typedef and enum inside class/struct. Since gengtype does not really know about scopes, it cannot understand these types, but it knows enough to recognize and reject them. GTY'd struct/class that need to typedef their own types should use GTY((user)). - Documentation on what is and is not supported. There is one check I needed to remove that gave me some trouble. When a ctor is detected, we have already parsed the name of the ctor as a type, which is then registered in the list of structures. We go on to recognize it as a ctor *after* the type has been registered. We reject the field in declarator() and it is never added to the list of fields for the class. However, when we reach the end of the class, we find that the type we created while parsing the ctor has line number information in it (the line where the ctor was) and gengtype thinks that it is a duplicate structure definition. I took out this check for two reasons: (a) It is actually unnecessary because if there were really duplicate definitions of this structure, the code would not compile, and (b) all the other alternatives required making the parser much more convoluted and I'm trying hard not to make gengtype parser too smart. 2012-10-12 Aaron Gray <aaronngray.lists@gmail.com> Diego Novillo <dnovillo@google.com> * gengtype-lex.l: Support for C++ single line comments. Support for classes. (CXX_KEYWORD): New. Support C++ keywords inline, public, protected, private, template, operator, friend, &, ~. (TYPEDEF): New. Support typedef. * gengtype-parser.c: updated 'token_names[]' (direct_declarator): Add support for parsing functions and ctors. 2012-10-12 Diego Novillo <dnovillo@google.com> * doc/gty.texi: Document C++ limitations in gengtype. * gengtype-lex.l (CID): Rename from ID. (ID): Include scoping '::' as part of the identifier name. * gengtype-parse.c (token_names): Update. (token_value_format): Update. (consume_until_eos): Rename from consume_until_semi. Remove unused argument IMMEDIATE. Update all callers. Also consider '}' as a finalizer. (consume_until_comma_or_eos): Rename from consume_until_comma_or_semi. Remove unused argument IMMEDIATE. Update all callers. Also consider '}' as a finalizer. (direct_declarator): Add documentation on ctor support. Add argument IN_STRUCT. If the token following ID is a '(', consider ID a function and return NULL. If the token following '(' is not a '*', and IN_STRUCT is true, conclude that this is a ctor and return NULL. If the token is IGNORABLE_CXX_KEYWORD, return NULL. (inner_declarator): Add argument IN_STRUCT. Update all callers. (declarator): Add argument IN_STRUCT with default value false. Update all callers. (type): Document argument NESTED. Skip over C++ inheritance specifiers. If a token TYPEDEF is found, emit an error. If an enum is found inside a class/structure, emit an error. (typedefs, structures, param_structs, variables): Initialize. (new_structure): Do not complain about duplicate structures if S has a line location set. * gengtype-state.c (write_state_type): Remove default handler. Add handler for TYPE_NONE. (read_state_scalar_char_type): * gengtype.c: Fix spacing. * gengtype.h (enum gty_token): Add name. Add token IGNORABLE_CXX_KEYWORD. From-SVN: r192405
Diffstat (limited to 'gcc/doc/gty.texi')
-rw-r--r--gcc/doc/gty.texi21
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/doc/gty.texi b/gcc/doc/gty.texi
index b2214b8..ea1a928 100644
--- a/gcc/doc/gty.texi
+++ b/gcc/doc/gty.texi
@@ -65,6 +65,27 @@ The parser understands simple typedefs such as
@code{typedef int @var{name};}.
These don't need to be marked.
+Since @code{gengtype}'s understanding of C++ is limited, there are
+several constructs and declarations that are not supported inside
+classes/structures marked for automatic GC code generation. The
+following C++ constructs produce a @code{gengtype} error on
+structures/classes marked for automatic GC code generation:
+
+@itemize @bullet
+@item
+Type definitions inside classes/structures are not supported.
+@item
+Enumerations inside classes/structures are not supported.
+@end itemize
+
+If you have a class or structure using any of the above constructs,
+you need to mark that class as @code{GTY ((user))} and provide your
+own marking routines (see section @ref{User GC} for details).
+
+It is always valid to include function definitions inside classes.
+Those are always ignored by @code{gengtype}, as it only cares about
+data members.
+
@menu
* GTY Options:: What goes inside a @code{GTY(())}.
* GGC Roots:: Making global variables GGC roots.