summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2011-09-27 02:13:00 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2011-09-27 02:13:00 +0000
commita1fc193d6720cf482c0327e71ad9beaf2624a300 (patch)
tree6b5c05b831d06418be10d3a2edb54708d1dfc3cd
parentec4670869159db6c647a0d5a524a9d3473e3412d (diff)
downloadgcc-a1fc193d6720cf482c0327e71ad9beaf2624a300.tar.gz
PR c++/45102
* pt.c (tsubst_copy_and_build) [CONST_DECL]: Don't pull out constant value if we're still in a template. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179230 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/pt.c2
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/template/partial13.C25
4 files changed, 33 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index abde58c856e..22f3ddebd86 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2011-09-26 Jason Merrill <jason@redhat.com>
+ PR c++/45102
+ * pt.c (tsubst_copy_and_build) [CONST_DECL]: Don't pull out
+ constant value if we're still in a template.
+
PR c++/46105
* typeck.c (structural_comptypes): Ignore cv-quals on typename scope.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index cac45f9feb5..4d57f94d2b1 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -13916,7 +13916,7 @@ tsubst_copy_and_build (tree t,
t = tsubst_copy (t, args, complain, in_decl);
/* As in finish_id_expression, we resolve enumeration constants
to their underlying values. */
- if (TREE_CODE (t) == CONST_DECL)
+ if (TREE_CODE (t) == CONST_DECL && !processing_template_decl)
{
used_types_insert (TREE_TYPE (t));
return DECL_INITIAL (t);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 32cf9600ca6..3c12f611319 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2011-09-26 Jason Merrill <jason@redhat.com>
+ PR c++/45012
+ * g++.dg/template/partial13.C: New.
+
PR c++/46105
* g++.dg/template/partial12.C: New.
diff --git a/gcc/testsuite/g++.dg/template/partial13.C b/gcc/testsuite/g++.dg/template/partial13.C
new file mode 100644
index 00000000000..bfbe2e02864
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/partial13.C
@@ -0,0 +1,25 @@
+// PR c++/45012
+
+template <bool B, class T=void> struct enable_if;
+
+template <class T>
+struct enable_if<true,T>
+{
+ typedef T type;
+};
+
+enum { RUNTIME = 0 };
+// it compiles with the previous line commented out and the next commented in
+// static const int RUNTIME=0;
+
+template <class T, class U, class EN=void> struct foo;
+
+template <template<int> class V, int M>
+struct foo<V<M>,V<M>, typename enable_if<M==RUNTIME||M==2>::type> {};
+
+template <template<int> class V1, template<int> class V2, int M>
+struct foo<V1<M>,V2<M>, typename enable_if<M==RUNTIME||M==2>::type> {};
+
+template <int M> struct bar {};
+
+foo<bar<2>,bar<2> > x;