OSDN Git Service

* search.c (dfs_record_inheritance): Ignore template type parms.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Nov 1997 19:36:41 +0000 (19:36 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Nov 1997 19:36:41 +0000 (19:36 +0000)
Fixes 13688.

* friend.c (do_friend): Warn about non-template friends in templates.

* call.c (build_op_delete_call): Fix handling of inherited delete.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@16551 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/friend.c
gcc/cp/search.c

index 0349d52..a480eba 100644 (file)
@@ -1,3 +1,11 @@
+Mon Nov 17 02:01:28 1997  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * friend.c (do_friend): Warn about non-template friends in templates.
+
+       * call.c (build_op_delete_call): Fix handling of inherited delete.
+
+       * search.c (dfs_record_inheritance): Ignore template type parms.
+
 Sat Nov 15 00:30:51 1997  Jason Merrill  <jason@yorick.cygnus.com>
 
        * call.c (build_new_op): Fix copy error.
index ed40a07..d4ecb62 100644 (file)
@@ -5125,15 +5125,17 @@ build_op_delete_call (code, addr, size, flags)
   fnname = ansi_opname[code];
 
   if (IS_AGGR_TYPE (type) && ! (flags & LOOKUP_GLOBAL))
-    /* Here we make assumptions about how instantiate_type works.  This comes
-       out as a simple TREE_LIST, so it looks like overloaded globals to
-       instantiate_type; this works out fine.  If something changes we
-       might have to build this up like build_offset_ref does.  */
     fns = lookup_fnfields (TYPE_BINFO (type), fnname, 0);
   else
     fns = NULL_TREE;
 
-  if (fns == NULL_TREE)
+  if (fns)
+    {
+      /* Build this up like build_offset_ref does.  */
+      fns = build_tree_list (error_mark_node, fns);
+      TREE_TYPE (fns) = build_offset_type (type, unknown_type_node);
+    }
+  else
     fns = lookup_name_nonclass (fnname);
 
   /* We can recognize a placement delete because of LOOKUP_SPECULATIVELY;
@@ -5182,7 +5184,7 @@ build_op_delete_call (code, addr, size, flags)
     {
       if (TREE_PURPOSE (fns))
        /* TREE_PURPOSE is only set for lists of member functions.  */
-       enforce_access (TREE_PURPOSE (fns), fn);
+       enforce_access (TREE_PURPOSE (TREE_VALUE (fns)), fn);
       return build_function_call (fn, expr_tree_cons (NULL_TREE, addr, args));
     }
 
index fbfffe7..28c0bb4 100644 (file)
@@ -381,10 +381,26 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
        DECL_CLASS_CONTEXT (decl) = current_class_type;
 
       if (! DECL_USE_TEMPLATE (decl))
-       /* We can call pushdecl here, because the TREE_CHAIN of this
-          FUNCTION_DECL is not needed for other purposes.  Don't do this
-          for a template instantiation. */
-       decl = pushdecl (decl);
+       {
+         /* We can call pushdecl here, because the TREE_CHAIN of this
+            FUNCTION_DECL is not needed for other purposes.  Don't do this
+            for a template instantiation. */
+         decl = pushdecl (decl);
+
+         if (! funcdef_flag && ! flag_guiding_decls
+             && current_template_parms && uses_template_parms (decl))
+           {
+             static int explained;
+             cp_warning ("friend declaration `%#D'", decl);
+             warning ("  will not be treated as a template instantiation");
+             if (! explained)
+               {
+                 warning ("  unless you compile with -fguiding-decls");
+                 warning ("  or add <> after the function name");
+                 explained = 1;
+               }
+           }
+       }
 
       make_decl_rtl (decl, NULL_PTR, 1);
       add_friend (current_class_type, decl);
index d75fe62..03e00fa 100644 (file)
@@ -3134,6 +3134,10 @@ dfs_record_inheritance (binfo)
       tree baseclass = BINFO_TYPE (base_binfo);
       mi_boolean *base_row = BINFO_DERIVES_FROM_STAR (base_binfo);
 
+      if (TREE_CODE (baseclass) == TEMPLATE_TYPE_PARM)
+       continue;
+      my_friendly_assert (CLASSTYPE_CID (baseclass) != 0, 2365);
+
       /* Don't search if there's nothing there!  MI_SIZE can be
         zero as a result of parse errors.  */
       if (TYPE_BINFO_BASETYPES (baseclass) && mi_size > 0)