pt.c (tsubst, [...]): Fix getting complete args for a member template specialization.
authorJason Merrill <jason@yorick.cygnus.com>
Fri, 17 Jul 1998 06:19:07 +0000 (06:19 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 17 Jul 1998 06:19:07 +0000 (02:19 -0400)
* pt.c (tsubst, case FUNCTION_DECL): Fix getting complete args for
a member template specialization.
* tree.c (ovl_member): Use decls_match to compare functions.
* decl.c (decls_match): Check the context of a function.

From-SVN: r21248

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/pt.c
gcc/cp/tree.c

index e5cfc5edf3c898534896b092d580372e93cf4838..d58646e644259735ab964ea4974a8a52530b47dd 100644 (file)
@@ -1,5 +1,11 @@
 1998-07-17  Jason Merrill  <jason@yorick.cygnus.com>
 
+       * pt.c (tsubst, case FUNCTION_DECL): Fix getting complete args for
+       a member template specialization.
+
+       * tree.c (ovl_member): Use decls_match to compare functions.
+       * decl.c (decls_match): Check the context of a function.
+
        * parse.y (primary): Use notype_unqualified_id instead of IDENTIFIER
        in Koenig lookup support rules.
        * semantics.c (finish_call_expr): Handle the new cases.
index 38c967a962291a34dcafa0aa486da977122c97b3..274e875fbeb106cd31faee0902aed078177c061e 100644 (file)
@@ -2464,6 +2464,11 @@ decls_match (newdecl, olddecl)
       tree p1 = TYPE_ARG_TYPES (f1);
       tree p2 = TYPE_ARG_TYPES (f2);
 
+      if (DECL_REAL_CONTEXT (newdecl) != DECL_REAL_CONTEXT (olddecl)
+         && ! (DECL_LANGUAGE (newdecl) == lang_c
+               && DECL_LANGUAGE (olddecl) == lang_c))
+       return 0;
+
       /* When we parse a static member function definition,
         we put together a FUNCTION_DECL which thinks its type
         is METHOD_TYPE.  Change that to FUNCTION_TYPE, and
index 5d1d5811394de09b16b11ee38ac109578ede77ec..e982c92822e35220f8cf003a4c196b0ed9e41363 100644 (file)
@@ -4642,7 +4642,10 @@ tsubst (t, args, in_decl)
            tmpl = DECL_TI_TEMPLATE (t);
 
            /* Start by getting the innermost args.  */
-           argvec = tsubst (DECL_TI_ARGS (t), args, in_decl);
+           if (DECL_TEMPLATE_SPECIALIZATION (tmpl))
+             argvec = args;
+           else
+             argvec = tsubst (DECL_TI_ARGS (t), args, in_decl);
 
            if (DECL_TEMPLATE_INFO (tmpl))
              argvec = complete_template_args (tmpl, argvec, 0);
@@ -5728,11 +5731,11 @@ instantiate_template (tmpl, targ_ptr)
 
   my_friendly_assert (TREE_CODE (tmpl) == TEMPLATE_DECL, 283);
 
-  /* FIXME this won't work with member templates; we only have one level
-     of args here.  */
+  /* Check to see if we already have this specialization.  This does work
+     for member template specializations; the list is set up from the
+     tsubst TEMPLATE_DECL case when the containing class is instantiated.  */
   if (DECL_FUNCTION_TEMPLATE_P (tmpl))
     {
-      /* Check to see if we already have this specialization.  */
       tree spec = retrieve_specialization (tmpl, targ_ptr);
       
       if (spec != NULL_TREE)
index 87a64a3d9693d3a133638b5095f7851889d31d04..2a5ad2b6d59a6c532df45098fefe9c0a50764089 100644 (file)
@@ -1412,7 +1412,7 @@ ovl_member (fn, ovl)
   if (!ovl || TREE_CODE (ovl) != OVERLOAD)
     return 0;
   for (; ovl; ovl = OVL_CHAIN (ovl))
-    if (OVL_FUNCTION (ovl) == fn)
+    if (decls_match (OVL_FUNCTION (ovl), fn))
       return 1;
   return 0;
 }