From a52cdecf114f4f1e5acbdeeb28b9381875a4b9a8 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 8 Oct 2018 09:02:55 +0000 Subject: [PATCH] re PR c++/71128 ([concepts] ICE on ill-formed explicit instantiation of a function concept) /cp 2018-10-08 Paolo Carlini PR c++/71128 * pt.c (do_decl_instantiation): Per 12.6.8/5, a concept cannot be explicitly instantiated. /testsuite 2018-10-08 Paolo Carlini PR c++/71128 * g++.dg/concepts/pr71128.C: New. From-SVN: r264914 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 8 ++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/concepts/pr71128.C | 10 ++++++++++ 4 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/g++.dg/concepts/pr71128.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 97d7e8d83c3..9a0a5ea5d3f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-10-08 Paolo Carlini + + PR c++/71128 + * pt.c (do_decl_instantiation): Per 12.6.8/5, a concept cannot be + explicitly instantiated. + 2018-10-05 David Malcolm PR c++/56856 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b8b6545434b..aced6f2d721 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -23127,6 +23127,14 @@ do_decl_instantiation (tree decl, tree storage) error ("explicit instantiation of non-template %q#D", decl); return; } + else if (DECL_DECLARED_CONCEPT_P (decl)) + { + if (VAR_P (decl)) + error ("explicit instantiation of variable concept %q#D", decl); + else + error ("explicit instantiation of function concept %q#D", decl); + return; + } bool var_templ = (DECL_TEMPLATE_INFO (decl) && variable_template_p (DECL_TI_TEMPLATE (decl))); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7b8bdc73766..5a9141d1623 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-10-08 Paolo Carlini + + PR c++/71128 + * g++.dg/concepts/pr71128.C: New. + 2018-10-08 Richard Sandiford PR c/87286 diff --git a/gcc/testsuite/g++.dg/concepts/pr71128.C b/gcc/testsuite/g++.dg/concepts/pr71128.C new file mode 100644 index 00000000000..8b4eb41f7ad --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/pr71128.C @@ -0,0 +1,10 @@ +// { dg-do compile { target c++14 } } +// { dg-additional-options "-fconcepts" } + +template +concept bool C() { return true; } +template bool C(); // { dg-error "explicit instantiation of function concept" } + +template +concept bool D = true; +template bool D; // { dg-error "explicit instantiation of variable concept" } -- 2.30.2