aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@markmitchell.com>1998-09-03 14:15:35 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1998-09-03 14:15:35 +0000
commit72f2bd784e4c2bb765e3e228bdb377e8978b8350 (patch)
tree02a7f95ebe7334bfc7a8aca834eb55d45f64ab70
parenta0d9f322521bf9754fd701fcf43656c975968d74 (diff)
downloadgcc-72f2bd784e4c2bb765e3e228bdb377e8978b8350.zip
gcc-72f2bd784e4c2bb765e3e228bdb377e8978b8350.tar.gz
gcc-72f2bd784e4c2bb765e3e228bdb377e8978b8350.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c12
-rw-r--r--gcc/cp/pt.c6
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/enum12.C16
4 files changed, 36 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b3133bb..9d57cd7 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 6fb4c14..75538c4 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 abb954e..ab9332a 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 0000000..b1c2b16
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.pt/enum12.C
@@ -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>&)
+{
+}