Classes containing access-control keywords such as "public:"
confuse struct_field_seq, leading it to call consume_until_eos
i.e. ignore text until after the next semicolon.

This leads to the first field after an access-control keyword
being ignored by gengtype.  This can be seen in:
  http://gcc.gnu.org/ml/gcc-patches/2013-09/msg01532.html
where the autogenerated marking function erroneously omitted the
traversal of the "callees" field of cgraph_node *.

This patch fixes up struct_field_seq to gracefully ignore such
keywords, thus fixing gengtype so that it does not erroneouly omit
fields of such a class.

        * gengtype-parse.c (struct_field_seq): Ignore access-control
        keywords ("public:" etc).
---
 gcc/gengtype-parse.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gcc/gengtype-parse.c b/gcc/gengtype-parse.c
index 68d372e..e5204c1 100644
--- a/gcc/gengtype-parse.c
+++ b/gcc/gengtype-parse.c
@@ -733,6 +733,17 @@ struct_field_seq (void)
     {
       ty = type (&opts, true);
 
+      /* Ignore access-control keywords ("public:" etc).  */
+      while (!ty && token () == IGNORABLE_CXX_KEYWORD)
+       {
+         const char *keyword = advance ();
+         if (strcmp (keyword, "public:") != 0
+             && strcmp (keyword, "private:") != 0
+             && strcmp (keyword, "protected:") != 0)
+           break;
+         ty = type (&opts, true);
+       }
+
       if (!ty || token () == ':')
        {
          consume_until_eos ();
-- 
1.7.11.7

Reply via email to