PATCH template template parameter & template function overloading

Kriang Lerdsuwanakij lerdsuwa@scf-fs.usc.edu
Thu Jun 25 22:39:00 GMT 1998


Hi

This patch corrects problem with certain template functions overloading with
template template parameters.  Without the patch, an incorrect error message 
(about the same function is defined twice) is produced for the testcase
provided below.

--Kriang

	* typeck.c (comptypes, case TEMPLATE_TEMPLATE_PARM): Add parameter 
	comparison.

diff -crNp gcc-old/cp/typeck.c gcc/cp/typeck.c
*** gcc-old/cp/typeck.c	Thu Jun 25 04:33:51 1998
--- gcc/cp/typeck.c	Thu Jun 25 04:33:27 1998
*************** comptypes (type1, type2, strict)
*** 804,809 ****
--- 804,812 ----
        if (TEMPLATE_TYPE_IDX (t1) != TEMPLATE_TYPE_IDX (t2)
  	  || TEMPLATE_TYPE_LEVEL (t1) != TEMPLATE_TYPE_LEVEL (t2))
  	return 0;
+       if (! comp_template_parms (DECL_TEMPLATE_PARMS (TYPE_NAME (t1)),
+ 				 DECL_TEMPLATE_PARMS (TYPE_NAME (t2))))
+ 	return 0;
        if (! CLASSTYPE_TEMPLATE_INFO (t1) && ! CLASSTYPE_TEMPLATE_INFO (t2))
  	return 1;
        /* Don't check inheritance.  */
diff -crNp gcc-old/testsuite/g++.old-deja/g++.pt/ttp46.C gcc/testsuite/g++.old-deja/g++.pt/ttp46.C
*** gcc-old/testsuite/g++.old-deja/g++.pt/ttp46.C	Wed Dec 31 16:00:00 1969
--- gcc/testsuite/g++.old-deja/g++.pt/ttp46.C	Thu Jun 25 04:27:30 1998
***************
*** 0 ****
--- 1,4 ----
+ // Build don't link:
+ 
+ template <template<class> class TT> void f() {}
+ template <template<class,class> class TT> void f() {}




More information about the Gcc-patches mailing list