diff mbox series

[C++] PR 71128 ("[concepts] ICE on ill-formed explicit instantiation of a function concept")

Message ID fad34628-267c-d884-8e09-98dbb9b7c2c9@oracle.com
State New
Headers show
Series [C++] PR 71128 ("[concepts] ICE on ill-formed explicit instantiation of a function concept") | expand

Commit Message

Paolo Carlini Oct. 5, 2018, 2:07 p.m. UTC
Hi,

another simple issue: here we ICE at the beginning of instantiate_decl 
when we try to explicitly instantiate a concept. Tested x86_64-linux.

Thanks, Paolo.

/////////////////////
/cp
2018-10-05  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/71128
	* pt.c (do_decl_instantiation): Per 12.6.8/5, a concept cannot be
	explicitly instantiated.

/testsuite
2018-10-05  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/71128
	* g++.dg/concepts/pr71128.C: New.

Comments

Jason Merrill Oct. 5, 2018, 2:14 p.m. UTC | #1
OK.
On Fri, Oct 5, 2018 at 10:07 AM Paolo Carlini <paolo.carlini@oracle.com> wrote:
>
> Hi,
>
> another simple issue: here we ICE at the beginning of instantiate_decl
> when we try to explicitly instantiate a concept. Tested x86_64-linux.
>
> Thanks, Paolo.
>
> /////////////////////
>
diff mbox series

Patch

Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 264862)
+++ cp/pt.c	(working copy)
@@ -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)));
Index: testsuite/g++.dg/concepts/pr71128.C
===================================================================
--- testsuite/g++.dg/concepts/pr71128.C	(nonexistent)
+++ testsuite/g++.dg/concepts/pr71128.C	(working copy)
@@ -0,0 +1,10 @@ 
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+template<typename T>
+concept bool C() { return true; }
+template bool C<int>();  // { dg-error "explicit instantiation of function concept" }
+
+template<typename T>
+concept bool D = true;
+template bool D<int>;  // { dg-error "explicit instantiation of variable concept" }