From 2fd578afc55f426c84b2fe0274ea5569bacde128 Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 26 Oct 2015 21:17:50 +0000 Subject: [PATCH] DR 2179 * pt.c (process_partial_specialization): Handle error_mark_node from most_specialized_partial_spec. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229395 138bc75d-0d04-0410-961f-82ee72b054a4 --- 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 5434dd2..e900e29 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 ffe02da..2745b40 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 0000000..c5f83bd --- /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.7.4