friend.c (make_friend_class): Robustify.
authorMark Mitchell <mark@codesourcery.com>
Thu, 7 Oct 1999 16:41:48 +0000 (16:41 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 7 Oct 1999 16:41:48 +0000 (16:41 +0000)
* friend.c (make_friend_class): Robustify.

* semantics.c (finish_object_call_expr): Reject calls to template
types.

From-SVN: r29855

gcc/cp/ChangeLog
gcc/cp/friend.c
gcc/cp/semantics.c

index 0a64b4d..526edb1 100644 (file)
@@ -1,3 +1,10 @@
+1999-10-07  Mark Mitchell  <mark@codesourcery.com>
+
+       * friend.c (make_friend_class): Robustify.
+
+       * semantics.c (finish_object_call_expr): Reject calls to template
+       types.
+
 1999-10-06  Mark Mitchell  <mark@codesourcery.com>
 
        * dump.c (dequeue_and_dump): Dump all three operands to a COND_EXPR.
index 410eaf5..d2325f3 100644 (file)
@@ -277,7 +277,8 @@ make_friend_class (type, friend_type)
     is_template_friend = 0;
 
   if (is_template_friend 
-      && TREE_CODE (friend_type) == TYPENAME_TYPE)
+      && (TREE_CODE (friend_type) == TYPENAME_TYPE
+         || TREE_CODE (friend_type) == TEMPLATE_TYPE_PARM))
     {
       /* [temp.friend]
 
@@ -290,9 +291,17 @@ make_friend_class (type, friend_type)
 
           template <class T> friend typename S<T>::X;
 
+        or:
+
+          template <class T> friend class T;
+
         which isn't any of these.  */
-      cp_error ("typename type `%T' declared `friend'",
-               friend_type);
+      if (TREE_CODE (friend_type) == TYPENAME_TYPE)
+       cp_error ("typename type `%T' declared `friend'",
+                 friend_type);
+      else
+       cp_error ("template parameter type `%T' declared `friend'",
+                 friend_type);
       return;
     }
 
index eb94da0..da17d3b 100644 (file)
@@ -1480,7 +1480,7 @@ finish_object_call_expr (fn, object, args)
   tree real_fn = build_component_ref (object, fn, NULL_TREE, 1);
   return finish_call_expr (real_fn, args);
 #else
-  if (TREE_CODE (fn) == TYPE_DECL)
+  if (DECL_DECLARES_TYPE_P (fn))
     {
       if (processing_template_decl)
        /* This can happen on code like: