From 6337bd75e256c0d0901d37178b26b273dcbb1078 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 26 Oct 2015 17:17:50 -0400 Subject: [PATCH] DR 2179 DR 2179 * pt.c (process_partial_specialization): Handle error_mark_node from most_specialized_partial_spec. From-SVN: r229395 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 20 +++++++++++-------- .../g++.dg/template/partial-specialization3.C | 7 +++++++ 3 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/partial-specialization3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5434dd27795..e900e297494 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-10-25 Jason Merrill + + DR 2179 + * pt.c (process_partial_specialization): Handle error_mark_node + from most_specialized_partial_spec. + 2015-10-23 Jason Merrill DR 1518 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ffe02da00db..2745b40fd7e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 index 00000000000..c5f83bd9f1c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/partial-specialization3.C @@ -0,0 +1,7 @@ +// DR 2179 + +template class A; +template struct A { void f(); }; +template void g(T) { A().f(); } // #1 +template struct A {}; // { dg-error "" } +A f; // #2 -- 2.30.2