This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 10845


Here's a patch for another regresssion; this time one involving member
template classes.  In that case, we need to go all the way back to the
original template before we start comparing the arguments.

Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2003-06-20  Mark Mitchell  <mark@codesourcery.com>

	PR c++/10845
	* pt.c (try_class_unification): Correct handling of member class
	templates.

2003-06-20  Mark Mitchell  <mark@codesourcery.com>

	PR c++/10845
	* g++.dg/template/member3.C: New test.

Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.703
diff -c -5 -p -r1.703 pt.c
*** cp/pt.c	20 Jun 2003 05:52:41 -0000	1.703
--- cp/pt.c	20 Jun 2003 15:21:55 -0000
*************** static tree
*** 9076,9086 ****
  try_class_unification (tree tparms, tree targs, tree parm, tree arg)
  {
    tree copy_of_targs;
  
    if (!CLASSTYPE_TEMPLATE_INFO (arg)
!       || CLASSTYPE_TI_TEMPLATE (arg) != CLASSTYPE_TI_TEMPLATE (parm))
      return NULL_TREE;
  
    /* We need to make a new template argument vector for the call to
       unify.  If we used TARGS, we'd clutter it up with the result of
       the attempted unification, even if this class didn't work out.
--- 9076,9087 ----
  try_class_unification (tree tparms, tree targs, tree parm, tree arg)
  {
    tree copy_of_targs;
  
    if (!CLASSTYPE_TEMPLATE_INFO (arg)
!       || (most_general_template (CLASSTYPE_TI_TEMPLATE (arg)) 
! 	  != most_general_template (CLASSTYPE_TI_TEMPLATE (parm))))
      return NULL_TREE;
  
    /* We need to make a new template argument vector for the call to
       unify.  If we used TARGS, we'd clutter it up with the result of
       the attempted unification, even if this class didn't work out.
Index: testsuite/g++.dg/template/member3.C
===================================================================
RCS file: testsuite/g++.dg/template/member3.C
diff -N testsuite/g++.dg/template/member3.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/member3.C	20 Jun 2003 15:21:56 -0000
***************
*** 0 ****
--- 1,19 ----
+ template<typename T>
+ struct A {
+   template<typename L> struct SubA { };
+ 
+   template<typename T1,typename L> void f(T1 & t1, SubA<L> & t2) { }
+   template<typename U> void g(SubA<U> & suba) { }
+   template<typename U> void h(SubA<U> & suba) { }
+ };
+ 
+ int main(void) {
+   int i;
+   A<int> a;
+   A<int>::SubA<int> suba;
+ 
+   a.f(i,suba);
+   a.g(suba);
+   a.h(suba);
+ }
+ 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]