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]

C++ PATCH for for_each_template_parm



As pointed out by Raja Harinath, yesterday's change to
for_each_template_parm was not quite right.  Here's a minor
modification, which should also improve handling of a couple of other
corner cases.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

Index: testsuite/g++.old-deja/g++.pt/spec32.C
===================================================================
RCS file: spec32.C
diff -N spec32.C
--- /dev/null	Sat Dec  5 20:30:03 1998
+++ spec32.C	Sat May 22 18:56:48 1999
@@ -0,0 +1,5 @@
+// Build don't link:
+// Origin: Raja R Harinath <harinath@cs.umn.edu>
+
+template<class T1, class T2> class foo;
+template<class T> struct foo<T,typename T::bar>;
Index: testsuite/g++.old-deja/cp/pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.304
diff -u -p -r1.304 pt.c
--- pt.c	1999/05/22 14:26:55	1.304
+++ pt.c	1999/05/23 01:57:05
@@ -4117,7 +4117,6 @@ for_each_template_parm (t, fn, data)
 
     case FUNCTION_DECL:
     case VAR_DECL:
-      /* ??? What about FIELD_DECLs?  */
       if (DECL_LANG_SPECIFIC (t) && DECL_TEMPLATE_INFO (t)
 	  && for_each_template_parm (DECL_TI_ARGS (t), fn, data))
 	return 1;
@@ -4162,6 +4161,7 @@ for_each_template_parm (t, fn, data)
     case VOID_TYPE:
     case BOOLEAN_TYPE:
     case NAMESPACE_DECL:
+    case FIELD_DECL:
       return 0;
 
       /* constants */
@@ -4192,16 +4192,24 @@ for_each_template_parm (t, fn, data)
     case ALIGNOF_EXPR:
       return for_each_template_parm (TREE_OPERAND (t, 0), fn, data);
 
+    case TYPENAME_TYPE:
+      if (!fn)
+	return 1;
+      return (for_each_template_parm (TYPE_CONTEXT (t), fn, data)
+	      || for_each_template_parm (TYPENAME_TYPE_FULLNAME (t),
+					 fn, data));
+
     case INDIRECT_REF:
     case COMPONENT_REF:
-      /* We assume that the object must be instantiated in order to build
-	 the COMPONENT_REF, so we test only whether the type of the
-	 COMPONENT_REF uses template parms.  On the other hand, if
-	 there's no type, then this thing must be some expression
+      /* If there's no type, then this thing must be some expression
 	 involving template parameters.  */
-      if (TREE_TYPE (t))
-	return for_each_template_parm (TREE_TYPE (t), fn, data);
-      /* Fall through.  */
+      if (!fn && !TREE_TYPE (t))
+	return 1;
+      if (TREE_CODE (t) == COMPONENT_REF)
+	return (for_each_template_parm (TREE_OPERAND (t, 0), fn, data)
+		|| for_each_template_parm (TREE_OPERAND (t, 1), fn, data));
+      else
+	return for_each_template_parm (TREE_OPERAND (t, 0), fn, data);
 
     case MODOP_EXPR:
     case CAST_EXPR:
@@ -4213,7 +4221,6 @@ for_each_template_parm (t, fn, data)
     case DOTSTAR_EXPR:
     case TYPEID_EXPR:
     case LOOKUP_EXPR:
-    case TYPENAME_TYPE:
       if (!fn)
 	return 1;
       /* Fall through.  */


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