decl.c (finish_enum): Don't resolve CONST_DECLs to their corresponding INTEGER_CSTs when...

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

From-SVN: r22211
This commit is contained in:
Mark Mitchell 1998-09-03 14:15:35 +00:00 committed by Mark Mitchell
parent a0d9f32252
commit 72f2bd784e
4 changed files with 36 additions and 4 deletions

View File

@ -1,3 +1,9 @@
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.
1998-09-03 Benjamin Kosnik <bkoz@rhino.cygnus.com>
* decl.c (pushdecl_class_level): Add warning here.

View File

@ -11926,9 +11926,15 @@ finish_enum (enumtype)
minnode = value;
}
/* In the list we're building up, we want the enumeration
values, not the CONST_DECLs. */
TREE_VALUE (pair) = 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

View File

@ -8205,7 +8205,11 @@ tsubst_enum (tag, newtag, args)
{
tree elt
= build_enumerator (TREE_PURPOSE (e),
tsubst_expr (TREE_VALUE (e), args,
/* 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);

View File

@ -0,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>&)
{
}