DR 2179
authorJason Merrill <jason@redhat.com>
Mon, 26 Oct 2015 21:17:50 +0000 (17:17 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 26 Oct 2015 21:17:50 +0000 (17:17 -0400)
DR 2179
* pt.c (process_partial_specialization): Handle error_mark_node
from most_specialized_partial_spec.

From-SVN: r229395

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

index 5434dd27795b99770c79e59c3fefc7daaa81167f..e900e2974944e2fd712b06f3fd4bbc3c5498c81d 100644 (file)
@@ -1,3 +1,9 @@
+2015-10-25  Jason Merrill  <jason@redhat.com>
+
+       DR 2179
+       * pt.c (process_partial_specialization): Handle error_mark_node
+       from most_specialized_partial_spec.
+
 2015-10-23  Jason Merrill  <jason@redhat.com>
 
        DR 1518
index ffe02da00db4b5fb4bcc2b73062a03311c7f01cf..2745b40fd7e3b64967e937616ea65c5381a69710 100644 (file)
@@ -4690,14 +4690,18 @@ process_partial_specialization (tree decl)
          : DECL_TEMPLATE_INSTANTIATION (instance))
        {
          tree spec = most_specialized_partial_spec (instance, tf_none);
-         if (spec && TREE_VALUE (spec) == tmpl)
-           {
-             tree inst_decl = (DECL_P (instance)
-                               ? instance : TYPE_NAME (instance));
-             permerror (input_location,
-                        "partial specialization of %qD after instantiation "
-                        "of %qD", decl, inst_decl);
-           }
+         tree inst_decl = (DECL_P (instance)
+                           ? instance : TYPE_NAME (instance));
+         if (!spec)
+           /* OK */;
+         else if (spec == error_mark_node)
+           permerror (input_location,
+                      "declaration of %qD ambiguates earlier template "
+                      "instantiation for %qD", decl, inst_decl);
+         else if (TREE_VALUE (spec) == tmpl)
+           permerror (input_location,
+                      "partial specialization of %qD after instantiation "
+                      "of %qD", decl, inst_decl);
        }
     }
 
diff --git a/gcc/testsuite/g++.dg/template/partial-specialization3.C b/gcc/testsuite/g++.dg/template/partial-specialization3.C
new file mode 100644 (file)
index 0000000..c5f83bd
--- /dev/null
@@ -0,0 +1,7 @@
+// DR 2179
+
+template <class T1, class T2> class A;
+template <class T> struct A<T, void> { void f(); };
+template <class T> void g(T) { A<char, void>().f(); }   // #1
+template<typename T> struct A<char, T> {};             // { dg-error "" }
+A<char, void> f;   // #2