C++ PATCH for typenames/template template parms

Mark Mitchell mark@codesourcery.com
Mon Jul 5 14:04:00 GMT 1999


This patch fixes a few bugs reported in the last few days.

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

1999-07-05  Mark Mitchell  <mark@codesourcery.com>

	* cp-tree.h (IS_AGGR_TYPE): Include instantiated template template
	parameters.
	(IMPLICIT_TYPENAME_TYPE_DECL_P): New macro.
	* decl.c (push_class_binding): Use it.
	(lookup_name_real): Likewise.

Index: testsuite/g++.old-deja/g++.oliva/template2.C
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/g++.old-deja/g++.oliva/template2.C,v
retrieving revision 1.1
diff -u -p -r1.1 template2.C
--- template2.C	1999/07/01 22:13:36	1.1
+++ template2.C	1999/07/05 21:00:52
@@ -11,4 +11,4 @@ template <template <typename> class C, t
 };
 
 template <template <typename> class C, typename T> foo<C,T>::foo(bar)
-{} // gets bogus error - C<T> not a class - XFAIL *-*-*
+{} // gets bogus error - C<T> not a class
Index: testsuite/g++.old-deja/g++.oliva/typename1.C
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/g++.old-deja/g++.oliva/typename1.C,v
retrieving revision 1.1
diff -u -p -r1.1 typename1.C
--- typename1.C	1999/07/05 09:36:05	1.1
+++ typename1.C	1999/07/05 20:16:44
@@ -5,8 +5,6 @@
 // by Alexandre Oliva <oliva@dcc.unicamp.br>
 // based on bug report by Nick Rasmussen <nick@jive.org>
 
-// crash test - XFAIL *-*-*
-
 template <class T> struct foo;
 
 template <class T> struct bar {
@@ -14,6 +12,6 @@ template <class T> struct bar {
 };
 
 template <class T> struct baz {
-  typedef bar<T>::foo foo; // ERROR - missing typename
+  typedef bar<T>::foo foo; // ERROR - missing typename - XFAIL *-*-*
   void m(foo);
 };
Index: testsuite/g++.old-deja/g++.oliva/typename2.C
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/testsuite/g++.old-deja/g++.oliva/typename2.C,v
retrieving revision 1.1
diff -u -p -r1.1 typename2.C
--- typename2.C	1999/07/05 09:36:05	1.1
+++ typename2.C	1999/07/05 20:14:55
@@ -24,5 +24,5 @@ template <class T> struct bar {
 
 template <class T> struct baz {
   typedef bar<T>::foo foo; // ERROR - implicit typename - XFAIL *-*-*
-  void m(foo); // gets bogus error - dependent base class - XFAIL *-*-*
+  void m(foo); 
 };
Index: cp/cp-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.238
diff -u -p -r1.238 cp-tree.h
--- cp-tree.h	1999/06/15 16:42:40	1.238
+++ cp-tree.h	1999/07/05 20:14:59
@@ -586,13 +586,16 @@ enum languages { lang_c, lang_cplusplus,
 #define TYPE_MAIN_DECL(NODE) (TYPE_STUB_DECL (TYPE_MAIN_VARIANT (NODE)))
 
 /* Nonzero if T is a class (or struct or union) type.  Also nonzero
-   for template type parameters and typename types.  Despite its name,
+   for template type parameters, typename types, and instantiated
+   template template parameters.  Despite its name,
    this macro has nothing to do with the definition of aggregate given
    in the standard.  Think of this macro as MAYBE_CLASS_TYPE_P.  */
 #define IS_AGGR_TYPE(t)				\
-  (TREE_CODE (t) == TEMPLATE_TYPE_PARM 		\
-   || TREE_CODE (t) == TYPENAME_TYPE 		\
+  (TREE_CODE (t) == TEMPLATE_TYPE_PARM		\
+   || TREE_CODE (t) == TYPENAME_TYPE		\
    || TREE_CODE (t) == TYPEOF_TYPE		\
+   || (TREE_CODE (t) == TEMPLATE_TEMPLATE_PARM	\
+       && TYPE_TEMPLATE_INFO (t))		\
    || TYPE_LANG_FLAG_5 (t))
 
 /* Set IS_AGGR_TYPE for T to VAL.  T must be a class, struct, or 
@@ -1515,6 +1518,13 @@ struct lang_decl
 /* Nonzero if NODE is an implicit typename.  */
 #define IMPLICIT_TYPENAME_P(NODE) \
   (TREE_CODE (NODE) == TYPENAME_TYPE && TREE_TYPE (NODE))
+
+/* Nonzero if NODE is a TYPE_DECL that should not be visible because
+   it is from a dependent base class.  */
+#define IMPLICIT_TYPENAME_TYPE_DECL_P(NODE) 	\
+  (TREE_CODE (NODE) == TYPE_DECL		\
+   && DECL_ARTIFICIAL (NODE)			\
+   && IMPLICIT_TYPENAME_P (TREE_TYPE (NODE)))
 
 /* Nonzero in INTEGER_CST means that this int is negative by dint of
    using a twos-complement negated operand.  */
Index: cp/decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.376
diff -u -p -r1.376 decl.c
--- decl.c	1999/07/01 16:36:59	1.376
+++ decl.c	1999/07/05 20:15:07
@@ -1248,8 +1248,7 @@ push_class_binding (id, decl)
 	 context for an implicit typename declaration is always
 	 the derived class in which the lookup was done, so the checks
 	 based on the context of DECL below will not trigger.  */
-      if (TREE_CODE (decl) == TYPE_DECL 
-	  && IMPLICIT_TYPENAME_P (TREE_TYPE (decl)))
+      if (IMPLICIT_TYPENAME_TYPE_DECL_P (decl))
 	INHERITED_VALUE_BINDING_P (binding) = 1;
       else
 	{
@@ -5869,15 +5868,13 @@ lookup_name_real (name, prefer_type, non
 	binding = NULL_TREE;
 
       if (binding
-	  && (!val || !(TREE_CODE (binding) == TYPE_DECL
-			&& IMPLICIT_TYPENAME_P (TREE_TYPE (binding)))))
+	  && (!val || !IMPLICIT_TYPENAME_TYPE_DECL_P (binding)))
 	{
 	  if (val_is_implicit_typename && !yylex)
 	    warn_about_implicit_typename_lookup (val, binding);
 	  val = binding;
 	  val_is_implicit_typename 
-	    = (TREE_CODE (val) == TYPE_DECL
-	       && IMPLICIT_TYPENAME_P (TREE_TYPE (val)));
+	    = IMPLICIT_TYPENAME_TYPE_DECL_P (val);
 	  if (!val_is_implicit_typename)
 	    break;
 	}


More information about the Gcc-patches mailing list