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]

[C++ PATCH] Bug fix for template template parm


Hi

The following patch fix a bug recently reported at

http://gcc.gnu.org/ml/gcc-bugs/1999-12/msg00446.html

The patch convert the TEMPLATE_DECL node that is a
template template parameter to a TEMPLATE_TEMPLATE_PARM
during the parsing stage rather than in 
convert_template_argument() so that tsubst_* functions
can substitute them properly when template argument
list is stored as either a TREE_VEC or a chain of TREE_LIST.  

Without the patch, tsubst_* can fail on the TREE_LIST case 
such as explicit template function specification (as seen
in the test case).   That because convert_template_argument() 
is not called before tsubst.

I believe the approach in the patch is good.  It is 
consistent with template type parameter case for which 
the TYPE_DECL to TEMPLATE_TYPE_PARM conversion is handled by 
groktypename() in the type_id rule.

--Kriang  (use the address lerdsuwa@scf.usc.edu for reply)


1999-12-27  Kriang Lerdsuwanakij  <lerdsuwa@scf.usc.edu>

	* parse.y (template_arg): Convert TEMPLATE_DECL
	that is a template template paramter to
	TEMPLATE_TEMPLATE_PARM here.


diff -crpN gcc-old/cp/parse.y gcc/cp/parse.y
*** gcc-old/cp/parse.y	Mon Dec 27 18:24:42 1999
--- gcc/cp/parse.y	Mon Dec 27 18:24:38 1999
*************** template_arg:
*** 964,970 ****
  	  type_id
  		{ $$ = groktypename ($1.t); }
  	| PTYPENAME
! 		{ $$ = lastiddecl; }
  	| expr_no_commas  %prec ARITHCOMPARE
  	;
  
--- 964,974 ----
  	  type_id
  		{ $$ = groktypename ($1.t); }
  	| PTYPENAME
! 		{
! 		  $$ = lastiddecl;
! 		  if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
! 		    $$ = TREE_TYPE ($$);
! 		}
  	| expr_no_commas  %prec ARITHCOMPARE
  	;
  
diff -crpN gcc-old/testsuite/g++.old-deja/g++.pt/ttp59.C gcc/testsuite/g++.old-deja/g++.pt/ttp59.C
*** gcc-old/testsuite/g++.old-deja/g++.pt/ttp59.C	Wed Dec 31 16:00:00 1969
--- gcc/testsuite/g++.old-deja/g++.pt/ttp59.C	Mon Dec 27 18:24:48 1999
***************
*** 0 ****
--- 1,13 ----
+ // Build don't link:
+ // Origin: Marcin Kowalczyk <qrczak@knm.org.pl>
+ 
+ template<template<typename> class t1, typename t0> void single()
+ {
+     single<t1,t0>();
+ }
+ 
+ template<typename a> class T1 {};
+ int main()
+ {
+     single<T1,int>();
+ }


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