This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 09/11] Support "gcc" namespace in gengtype


This patch adds enough special-casing to gengtype to allow it to cope
with types that are within the gcc namespace.

gcc/

	* gengtype.c (type_for_name): Add special-case support for
	locating types within the "gcc::" namespace.
	(open_base_files): Emit a "using namespace gcc" directive.
---
 gcc/gengtype.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/gcc/gengtype.c b/gcc/gengtype.c
index 2085496..50efa9b 100644
--- a/gcc/gengtype.c
+++ b/gcc/gengtype.c
@@ -604,6 +604,16 @@ static type_p
 type_for_name (const char *s)
 {
   pair_p p;
+
+  /* Special-case support for types within a "gcc::" namespace.  Rather
+     than fully-supporting namespaces, simply strip off the "gcc::" prefix
+     where present.  This allows us to have GTY roots of this form:
+         extern GTY(()) gcc::some_type *some_ptr;
+     where the autogenerated functions will refer to simply "some_type",
+     where they can be resolved into their namespace.  */
+  if (0 == strncmp(s, "gcc::", 5))
+    s += 5;
+
   for (p = typedefs; p != NULL; p = p->next)
     if (strcmp (p->name, s) == 0)
       return p->type;
@@ -1735,6 +1745,13 @@ open_base_files (void)
     /* Make sure we handle "cfun" specially.  */
     oprintf (gtype_desc_c, "\n/* See definition in function.h.  */\n");
     oprintf (gtype_desc_c, "#undef cfun\n");
+
+    oprintf (gtype_desc_c,
+	     "\n"
+	     "/* Types with a \"gcc::\" prefix have the prefix stripped\n"
+	     "   during gengtype parsing.  Provide a \"using\" directive\n"
+	     "   to ensure that the fully-qualified types are found.  */\n"
+	     "using namespace gcc;\n");
   }
 }
 
-- 
1.7.11.7


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]