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]

PATCH for templates/enums yet again



Here's another tweak to the enum handling in the presence of
templates. 

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com

1998-09-03  Mark Mitchell  <mark@markmitchell.com>

	* decl.c (finish_enum): Don't resolve CONST_DECLs to their
	corresponding INTEGER_CSTs when processing_template_decl.
	* pt.c (tsubst_enum): Tweak accordingly.

Index: testsuite/g++.old-deja/g++.pt/enum12.C
===================================================================
RCS file: enum12.C
diff -N enum12.C
*** /dev/null	Mon Dec 31 20:00:00 1979
--- enum12.C	Thu Sep  3 12:45:42 1998
***************
*** 0 ****
--- 1,16 ----
+ // Build don't link:
+ 
+ template <int I>
+ struct S1 { };
+ 
+ template <class T>
+ struct S2 {
+   enum { x = 3 };
+ 
+   void f(S1<x>&);
+ };
+ 
+ template <class T>
+ void S2<T>::f(S1<x>&)
+ {
+ }
Index: cp/decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.201
diff -c -p -r1.201 decl.c
*** decl.c	1998/09/01 11:51:32	1.201
--- decl.c	1998/09/03 19:46:27
*************** finish_enum (enumtype)
*** 11914,11922 ****
  		minnode = value;
  	    }
  
! 	  /* In the list we're building up, we want the enumeration
! 	     values, not the CONST_DECLs.  */
! 	  TREE_VALUE (pair) = value;
  	}
      }
    else
--- 11914,11928 ----
  		minnode = value;
  	    }
  
! 	  if (processing_template_decl) 
! 	    /* If this is just a template, leave the CONST_DECL
! 	       alone.  That way tsubst_copy will find CONST_DECLs for
! 	       CONST_DECLs, and not INTEGER_CSTs.  */
! 	    ;
! 	  else
! 	    /* In the list we're building up, we want the enumeration
! 	       values, not the CONST_DECLs.  */
! 	    TREE_VALUE (pair) = value;
  	}
      }
    else
Index: cp/pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.195
diff -c -p -r1.195 pt.c
*** pt.c	1998/09/02 16:57:17	1.195
--- pt.c	1998/09/03 19:46:51
*************** tsubst_enum (tag, newtag, args)
*** 8205,8211 ****
      {
        tree elt
  	= build_enumerator (TREE_PURPOSE (e), 
! 			    tsubst_expr (TREE_VALUE (e), args,
  					 NULL_TREE),
  			    newtag); 
  
--- 8205,8215 ----
      {
        tree elt
  	= build_enumerator (TREE_PURPOSE (e), 
! 			    /* Note that in a template enum, the
! 			       TREE_VALUE is the CONST_DECL, not the
! 			       corresponding INTEGER_CST.  */
! 			    tsubst_expr (DECL_INITIAL (TREE_VALUE (e)), 
! 					 args,
  					 NULL_TREE),
  			    newtag); 
  


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