From c5a6fc4557d005e18da25fbc5c9d44bf36a12289 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 17 Jul 1998 06:19:07 +0000 Subject: [PATCH] pt.c (tsubst, [...]): Fix getting complete args for a member template specialization. * 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 | 6 ++++++ gcc/cp/decl.c | 5 +++++ gcc/cp/pt.c | 11 +++++++---- gcc/cp/tree.c | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e5cfc5edf3c..d58646e6442 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 1998-07-17 Jason Merrill + * 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. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 38c967a9622..274e875fbeb 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5d1d5811394..e982c92822e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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) diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 87a64a3d969..2a5ad2b6d59 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -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; } -- 2.30.2