]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/45012 (Invalid ambiguity on partial class specialization matching)
authorJason Merrill <jason@redhat.com>
Tue, 27 Sep 2011 02:13:00 +0000 (22:13 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 27 Sep 2011 02:13:00 +0000 (22:13 -0400)
PR c++/45102
* pt.c (tsubst_copy_and_build) [CONST_DECL]: Don't pull out
constant value if we're still in a template.

From-SVN: r179230

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/partial13.C [new file with mode: 0644]

index abde58c856e48dbc24fa04cee718f66138a49b59..22f3ddebd865d95cbf3d3b066e425a12e7f9f840 100644 (file)
@@ -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.
 
index cac45f9feb574c2b4480ba4245e8e3461842b1ed..4d57f94d2b141b5171a56e444403d480b7f1825a 100644 (file)
@@ -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);
index 32cf9600ca6117000660bcafbfcd69e4e0da0d75..3c12f6113199b13d342420996921a959e545a5ac 100644 (file)
@@ -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 (file)
index 0000000..bfbe2e0
--- /dev/null
@@ -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;