]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (finish_enum): Don't resolve CONST_DECLs to their corresponding INTEGER_CSTs...
authorMark Mitchell <mark@markmitchell.com>
Thu, 3 Sep 1998 14:15:35 +0000 (14:15 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 3 Sep 1998 14:15:35 +0000 (14:15 +0000)
* 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

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/pt.c
gcc/testsuite/g++.old-deja/g++.pt/enum12.C [new file with mode: 0644]

index b3133bb03be19db25ccd7bdbfc1a37556cf1636c..9d57cd772bb04a73e54260f684d7ffa3f6e0d0d1 100644 (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.
index 6fb4c148e153f1032bfa9d7793e1f23ab651bc57..75538c4a41501d87b49b658b7846b4d776768203 100644 (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
index abb954e8def2fb1a52283c21200263718cb76ab0..ab9332ac8ad91a2b4f7339b8fa99ff1cfb473ffb 100644 (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); 
 
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 (file)
index 0000000..b1c2b16
--- /dev/null
@@ -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>&)
+{
+}