From 02ca53f25b250c563338e123c070ec5dfc83c6c8 Mon Sep 17 00:00:00 2001 From: bernie Date: Fri, 14 Nov 2003 04:51:21 +0000 Subject: [PATCH] PR c++/2094 * pt.c (unify): Add support for PTRMEM_CST and FIELD_DECL unification. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73577 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7f8402d..7e036b3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-11-14 Giovanni Bajo + + PR c++/2094 + * pt.c (unify): Add support for PTRMEM_CST and + FIELD_DECL unification. + 2003-11-13 Richard Earnshaw * decl.c (grokfndecl): Change OK to type tree. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index cd93423..4afe974 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9617,6 +9617,27 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict) TREE_VEC_ELT (targs, idx) = arg; return 0; + case PTRMEM_CST: + { + /* A pointer-to-member constant can be unified only with + another constant. */ + if (TREE_CODE (arg) != PTRMEM_CST) + return 1; + + /* Just unify the class member. It would be useless (and possibly + wrong, depending on the strict flags) to unify also + PTRMEM_CST_CLASS, because we want to be sure that both parm and + arg refer to the same variable, even if through different + classes. For instance: + + struct A { int x; }; + struct B : A { }; + + Unification of &A::x and &B::x must succeed. */ + return unify (tparms, targs, PTRMEM_CST_MEMBER (parm), + PTRMEM_CST_MEMBER (arg), strict); + } + case POINTER_TYPE: { if (TREE_CODE (arg) != POINTER_TYPE) @@ -9805,6 +9826,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict) return 1; return 0; + case FIELD_DECL: case TEMPLATE_DECL: /* Matched cases are handled by the ARG == PARM test above. */ return 1; -- 2.7.4