Patch

Mark Mitchell mmitchell@usa.net
Tue Sep 9 10:12:00 GMT 1997


Here's a patch for another template problem uncovered by the Blitz++
library.  With this patch, most of the example programs provided in
that library compile successfully.

If anyone (Jason?) is getting lost with the number of patches I've
posted recently, but wants my latest fixes, I'll be happy to send you
a patch consisting of all my changes against 970907.

Thanks,

-- 
Mark Mitchell		mmitchell@usa.net
Stanford University	http://www.stanford.edu

Index: gcc/cp/error.c
===================================================================
RCS file: /home/mitchell/Repository/egcs/gcc/cp/error.c,v
retrieving revision 1.7
diff -c -p -r1.7 error.c
*** error.c	1997/09/08 16:52:43	1.7
--- error.c	1997/09/09 16:27:51
*************** dump_expr (t, nop)
*** 1366,1394 ****
        }
  
      case TEMPLATE_CONST_PARM:
!       if (current_template_parms)
! 	{
! 	  int i;
! 	  int l = list_length (current_template_parms);
! 	  tree parms = current_template_parms;
! 	  tree r;
  
! 	  for (i = 0; i < l - TEMPLATE_CONST_LEVEL (t); ++i)
! 	    {
! 	      parms = TREE_CHAIN (parms);
! 	      my_friendly_assert (parms != NULL_TREE, 0);
! 	    }
! 
! 	  r = TREE_VEC_ELT (TREE_VALUE (parms),
! 			    TEMPLATE_CONST_IDX (t));
! 	  dump_decl (TREE_VALUE (r), -1);
! 	}
!       else
! 	{
! 	  OB_PUTS ("<tparm ");
! 	  OB_PUTI (TEMPLATE_CONST_IDX (t));
! 	  OB_PUTS (">");
! 	}
        break;
  
      case IDENTIFIER_NODE:
--- 1366,1398 ----
        }
  
      case TEMPLATE_CONST_PARM:
!       {
! 	int l = current_template_parms ? 
! 	  list_length (current_template_parms) : 0;
  
! 	if (l >= TEMPLATE_CONST_LEVEL (t))
! 	  {
! 	    int i;
! 	    tree parms = current_template_parms;
! 	    tree r;
! 	    
! 	    for (i = 0; i < l - TEMPLATE_CONST_LEVEL (t); ++i)
! 	      {
! 		parms = TREE_CHAIN (parms);
! 		my_friendly_assert (parms != NULL_TREE, 0);
! 	      }
! 	    
! 	    r = TREE_VEC_ELT (TREE_VALUE (parms),
! 			      TEMPLATE_CONST_IDX (t));
! 	    dump_decl (TREE_VALUE (r), -1);
! 	  }
! 	else
! 	  {
! 	    OB_PUTS ("<tparm ");
! 	    OB_PUTI (TEMPLATE_CONST_IDX (t));
! 	    OB_PUTS (">");
! 	  }
!       }
        break;
  
      case IDENTIFIER_NODE:
Index: gcc/testsuite/g++.old-deja/g++.pt/memtemp59.C
===================================================================
RCS file: memtemp59.C
diff -N memtemp59.C
*** /dev/null	Mon Dec 31 20:00:00 1979
--- memtemp59.C	Tue Sep  9 10:09:58 1997
***************
*** 0 ****
--- 1,22 ----
+ // Build don't link:
+ // GROUPS passed templates membertemplates
+ template <int N>
+ struct IndexPlaceholder {};
+ 
+ template <int N1, int N2, int N3>
+ struct ArrayIndexMapping {};
+ 
+ template <class T_numtype, int N_rank>
+ struct Array
+ {
+   template<int N0, int N1>
+   ArrayIndexMapping<N_rank, N0, N1> 
+   f(IndexPlaceholder<N0>, IndexPlaceholder<N1>);
+ };
+ 
+ 
+ template <class T_numtype>
+ void foo(T_numtype)
+ {
+   Array<T_numtype, 1> t;
+ }



More information about the Gcc mailing list