C++ PATCH: definitions of member templates of partialspecializations

Mark Mitchell mark@codesourcery.com
Sat Mar 25 19:04:00 GMT 2000


I fixed this little buglet on the plane -- we weren't allowing code
like in the test-case.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2000-03-25  Mark Mitchell  <mark@codesourcery.com>

	* decl.c (grokdeclarator): Count partial specializations when
	keeping track of how many template classes have been seen.

	* dump.c (dequeue_and_dump): Dump DECL_TEMPLATE_RESULT.
	
Index: testsuite/g++.old-deja/g++.pt/memtemp95.C
===================================================================
RCS file: memtemp95.C
diff -N memtemp95.C
*** /dev/null	Tue May  5 13:32:27 1998
--- memtemp95.C	Sat Mar 25 18:59:45 2000
***************
*** 0 ****
--- 1,20 ----
+ // Build don't link:
+ // Origin: Mark Mitchell <mitchell@codesourcery.com>
+ 
+ template <class T, class V>
+ struct S
+ {
+ };
+ 
+ template <class T>
+ struct S<T, int>
+ {
+   template <class U>
+   void f (U);
+ };
+ 
+ template <class T>
+ template <class U>
+ void S<T, int>::f (U)
+ {
+ }
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.577
diff -c -p -r1.577 decl.c
*** decl.c	2000/03/25 16:38:49	1.577
--- decl.c	2000/03/26 03:00:14
*************** grokdeclarator (declarator, declspecs, d
*** 10647,10655 ****
  	    t = ctype;
  	    while (t != NULL_TREE && CLASS_TYPE_P (t))
  	      {
! 		if (CLASSTYPE_TEMPLATE_INFO (t) &&
! 		    !CLASSTYPE_TEMPLATE_SPECIALIZATION (t))
  		  template_count += 1;
  		t = TYPE_MAIN_DECL (t);
  		if (DECL_LANG_SPECIFIC (t))
  		  t = DECL_CONTEXT (t);
--- 10647,10667 ----
  	    t = ctype;
  	    while (t != NULL_TREE && CLASS_TYPE_P (t))
  	      {
! 		/* You're supposed to have one `template <...>' 
! 		   for every template class, but you don't need one
! 		   for a full specialization.  For example:
! 
! 		     template <class T> struct S{};
! 		     template <> struct S<int> { void f(); };
! 		     void S<int>::f () {}
! 
! 		   is correct; there shouldn't be a `template <>' for
! 		   the definition of `S<int>::f'.  */
! 		if (CLASSTYPE_TEMPLATE_INFO (t)
! 		    && (CLASSTYPE_TEMPLATE_INSTANTIATION (t)
! 			|| uses_template_parms (CLASSTYPE_TI_ARGS (t))))
  		  template_count += 1;
+ 
  		t = TYPE_MAIN_DECL (t);
  		if (DECL_LANG_SPECIFIC (t))
  		  t = DECL_CONTEXT (t);
Index: cp/dump.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/dump.c,v
retrieving revision 1.38
diff -c -p -r1.38 dump.c
*** dump.c	2000/03/25 16:38:49	1.38
--- dump.c	2000/03/26 03:00:15
*************** dequeue_and_dump (di)
*** 609,614 ****
--- 609,615 ----
        break;
  
      case TEMPLATE_DECL:
+       dump_child ("rslt", DECL_TEMPLATE_RESULT (t));
        dump_child ("inst", DECL_TEMPLATE_INSTANTIATIONS (t));
        dump_child ("spcs", DECL_TEMPLATE_SPECIALIZATIONS (t));
        break;


More information about the Gcc-patches mailing list