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: nested ttp implementation


Hi

The following patch fills in the missing component in the template 
template parameter implementation.  Template template parameters
having template classes as their parameter are now accepted and
handled correctly.

--Kriang

1999-02-06  Kriang Lerdsuwanakij <lerdsuwa@scf-fs.usc.edu>

	* decl2.c (arg_assoc_type): Handle TEMPLATE_TEMPLATE_PARM.
	* pt.c (coerce_template_template_parms): Handle nested 
	template template parameters.


diff -rcpN gcc-old/cp/decl2.c gcc/cp/decl2.c
*** gcc-old/cp/decl2.c	Sat Feb  6 15:37:55 1999
--- gcc/cp/decl2.c	Sat Feb  6 15:37:18 1999
*************** arg_assoc_type (k, type)
*** 4533,4538 ****
--- 4533,4539 ----
        /* Associate the return type. */
        return arg_assoc_type (k, TREE_TYPE (type));
      case TEMPLATE_TYPE_PARM:
+     case TEMPLATE_TEMPLATE_PARM:
        return 0;
      case LANG_TYPE:
        if (type == unknown_type_node)
diff -rcpN gcc-old/cp/pt.c gcc/cp/pt.c
*** gcc-old/cp/pt.c	Sat Feb  6 15:38:09 1999
--- gcc/cp/pt.c	Sat Feb  6 15:37:22 1999
*************** coerce_template_template_parms (parm_par
*** 2804,2811 ****
  	  /* We encounter instantiations of templates like
  	       template <template <template <class> class> class TT>
  	       class C;  */
! 	  sorry ("nested template template parameter");
! 	  return 0;
  
  	case PARM_DECL:
  	  /* The tsubst call is used to handle cases such as
--- 2804,2818 ----
  	  /* We encounter instantiations of templates like
  	       template <template <template <class> class> class TT>
  	       class C;  */
! 	  {
! 	    tree parmparm = DECL_INNERMOST_TEMPLATE_PARMS (parm);
! 	    tree argparm = DECL_INNERMOST_TEMPLATE_PARMS (arg);
! 
! 	    if (!coerce_template_template_parms (parmparm, argparm, 
! 					         in_decl, outer_args))
! 	      return 0;
! 	  }
! 	  break;
  
  	case PARM_DECL:
  	  /* The tsubst call is used to handle cases such as
diff -rcpN gcc-old/testsuite/g++.old-deja/g++.pt/nttp1.C gcc/testsuite/g++.old-deja/g++.pt/nttp1.C
*** gcc-old/testsuite/g++.old-deja/g++.pt/nttp1.C	Wed Dec 31 16:00:00 1969
--- gcc/testsuite/g++.old-deja/g++.pt/nttp1.C	Sat Feb  6 15:36:48 1999
***************
*** 0 ****
--- 1,21 ----
+ // Test for nested template template parameter feature
+ 
+ template <template<template <class> class> class TTT> struct C
+ {
+ 	int f();
+ };
+ 
+ template <template<template <class> class> class TTT> int C<TTT>::f()
+ {
+ 	return 0;
+ }
+ 
+ template <template <class> class TT> struct D
+ {
+ };
+ 
+ int main()
+ {
+ 	C<D> c;
+ 	c.f();
+ }
diff -rcpN gcc-old/testsuite/g++.old-deja/g++.pt/nttp2.C gcc/testsuite/g++.old-deja/g++.pt/nttp2.C
*** gcc-old/testsuite/g++.old-deja/g++.pt/nttp2.C	Wed Dec 31 16:00:00 1969
--- gcc/testsuite/g++.old-deja/g++.pt/nttp2.C	Sat Feb  6 15:36:53 1999
***************
*** 0 ****
--- 1,30 ----
+ // Test for nested template template parameter feature
+ 
+ template <template<template <class> class> class TTT> struct C
+ {
+ 	int f() { return 0; }
+ };
+ 
+ template <template <class> class TT> struct D
+ {
+ 	int	a;
+ };
+ 
+ template <template <class> class TT> struct E
+ {
+ 	int	a;
+ 	int	b;
+ };
+ 
+ template <template <template <template<class> class> class> class TTT> 
+ int g(TTT<E> t)
+ {
+ 	TTT<D> tt;
+ 	return tt.f();
+ }
+ 
+ int main()
+ {
+ 	C<E> c;
+ 	g(c);
+ }



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