This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Patch for enum's as template parameters
- To: mmitchell at usa dot net
- Subject: Re: Patch for enum's as template parameters
- From: Jason Merrill <jason at cygnus dot com>
- Date: 28 Jan 1998 10:59:36 -0800
- Cc: egcs-bugs at cygnus dot com, pooh at msu dot ru, mlawson at drfmc dot ceng dot cea dot fr
- References: <199801280149.RAA22592@smtp.earthlink.net>
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);