This is the mail archive of the gcc-bugs@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]

Re: Patch for enum's as template parameters


I prefer this fix:

Wed Jan 28 10:55:47 1998  Jason Merrill  <jason@yorick.cygnus.com>

	* pt.c (convert_nontype_argument): Use decl_constant_value.

Index: pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.53
diff -c -p -r1.53 pt.c
*** pt.c	1998/01/27 20:47:54	1.53
--- pt.c	1998/01/28 18:57:30
*************** convert_nontype_argument (type, expr)
*** 1412,1424 ****
       
       --a pointer to member expressed as described in _expr.unary.op_.  */
  
    if (INTEGRAL_TYPE_P (expr_type) 
        || TYPE_PTRMEM_P (expr_type) 
        || TYPE_PTRMEMFUNC_P (expr_type))
      {
!       if (!TREE_CONSTANT (expr) 
! 	  /* FIXME: Should this case be handled by fold()?  Why not?  */
! 	  && !(TREE_CODE (expr) == VAR_DECL && TREE_READONLY (expr)))
  	{
  	  cp_error ("non-constant `%E' cannot be used as template argument",
  		    expr);
--- 1412,1425 ----
       
       --a pointer to member expressed as described in _expr.unary.op_.  */
  
+   if (TREE_READONLY_DECL_P (expr))
+     expr = decl_constant_value (expr);
+ 
    if (INTEGRAL_TYPE_P (expr_type) 
        || TYPE_PTRMEM_P (expr_type) 
        || TYPE_PTRMEMFUNC_P (expr_type))
      {
!       if (! TREE_CONSTANT (expr))
  	{
  	  cp_error ("non-constant `%E' cannot be used as template argument",
  		    expr);


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