This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
PATCH for explicit instantiation of member template constructors
- To: Jason Merrill <jason at cygnus dot com>
- Subject: PATCH for explicit instantiation of member template constructors
- From: Mark Mitchell <mmitchell at usa dot net>
- Date: Tue, 21 Apr 1998 12:22:10 -0700
- Cc: egcs-bugs at cygnus dot com
- Reply-to: mmitchell at usa dot net
This didn't use to work:
template <class T>
struct S
{
S(const T&) {}
S(int, long);
};
template S<double>::S(const double&);
This patch fixes the problem.
--
Mark Mitchell <mmitchell@usa.net>
http://home.earthlink.net/~mbmitchell
Consulting Services Available
Tue Apr 21 12:10:18 1998 Mark Mitchell <mmitchell@usa.net>
* pt.c (check_explicit_specialization): Handle overloaded
constructors correctly.
Index: gcc/cp/pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.117
diff -c -p -r1.117 pt.c
*** pt.c 1998/04/17 21:25:37 1.117
--- pt.c 1998/04/21 19:07:05
*************** check_explicit_specialization (declarato
*** 1039,1047 ****
return decl;
}
! fns = TREE_VEC_ELT(CLASSTYPE_METHOD_VEC (ctype),
! is_constructor ? 0 : 1);
}
else
fns = lookup_fnfields (TYPE_BINFO (ctype), name,
--- 1077,1095 ----
return decl;
}
+
+ fns = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (ctype),
+ is_constructor ? 0 : 1);
! if (is_constructor)
! /* The constructor might well be overloaded. But, the
! entry in the CLASSTYPE_METHOD_VEC is not a
! TREE_LIST node. We build a TREE_LIST here so that
! in further processing we can tree the constructors
! just like any other set of overloaded functions. */
! fns = scratch_tree_cons (NULL_TREE,
! fns,
! NULL_TREE);
}
else
fns = lookup_fnfields (TYPE_BINFO (ctype), name,
Index: gcc/testsuite/g++.old-deja/g++.pt/instantiate3.C
===================================================================
RCS file: instantiate3.C
diff -N instantiate3.C
*** /dev/null Mon Dec 31 20:00:00 1979
--- instantiate3.C Tue Apr 21 12:07:05 1998
***************
*** 0 ****
--- 1,10 ----
+ // Build don't link:
+
+ template <class T>
+ struct S
+ {
+ S(const T&) {}
+ S(int, long);
+ };
+
+ template S<double>::S(const double&);