Patch for enum's as template parameters
Mark Mitchell
mmitchell@usa.net
Tue Jan 27 22:56:00 GMT 1998
Here's a patch for the problem that was reported recently regarding
the fact that enum's could no longer be used as template parameters.
--
Mark Mitchell mmitchell@usa.net
Stanford University http://www.stanford.edu
Tue Jan 27 17:48:22 1998 Mark Mitchell <mmitchell@usa.net>
* pt.c (convert_nontype_argument): Note that CONST_DECLS are
constant.
Index: gcc/cp/pt.c
===================================================================
RCS file: /home/mitchell/Repository/egcs/gcc/cp/pt.c,v
retrieving revision 1.15
diff -c -p -r1.15 pt.c
*** pt.c 1998/01/28 01:32:52 1.15
--- pt.c 1998/01/28 01:38:33
*************** convert_nontype_argument (type, expr)
*** 1417,1422 ****
--- 1417,1423 ----
|| TYPE_PTRMEMFUNC_P (expr_type))
{
if (!TREE_CONSTANT (expr)
+ && !(TREE_CODE (expr) == CONST_DECL)
/* FIXME: Should this case be handled by fold()? Why not? */
&& !(TREE_CODE (expr) == VAR_DECL && TREE_READONLY (expr)))
{
Index: gcc/testsuite/g++.old-deja/g++.pt/enum3.C
===================================================================
RCS file: enum3.C
diff -N enum3.C
*** /dev/null Mon Dec 31 20:00:00 1979
--- enum3.C Tue Jan 27 17:41:32 1998
***************
*** 0 ****
--- 1,14 ----
+ struct S { enum en { s0, s1, s2 }; };
+
+ template<typename S::en e>
+ int val( )
+ {
+ return e;
+ }
+
+
+ int main()
+ {
+ return val<S::s0>( );
+ }
+
More information about the Gcc-bugs
mailing list