From: Mark Mitchell Date: Thu, 3 Sep 1998 14:15:35 +0000 (+0000) Subject: decl.c (finish_enum): Don't resolve CONST_DECLs to their corresponding INTEGER_CSTs... X-Git-Tag: prereleases/libgcj-0.1~3234 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=72f2bd784e4c2bb765e3e228bdb377e8978b8350;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b3133bb03be1..9d57cd772bb0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +1998-09-03 Mark Mitchell + + * 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 * decl.c (pushdecl_class_level): Add warning here. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 6fb4c148e153..75538c4a4150 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index abb954e8def2..ab9332ac8ad9 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum12.C b/gcc/testsuite/g++.old-deja/g++.pt/enum12.C new file mode 100644 index 000000000000..b1c2b169d577 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum12.C @@ -0,0 +1,16 @@ +// Build don't link: + +template +struct S1 { }; + +template +struct S2 { + enum { x = 3 }; + + void f(S1&); +}; + +template +void S2::f(S1&) +{ +}