diff mbox series

C++ PATCH for c++/85133, ICE with missing concept initializer

Message ID CADzB+2mbmH45YpugFER8rLs5QR7jTTi8r9Z9M8L=cfdKAo=BoQ@mail.gmail.com
State New
Headers show
Series C++ PATCH for c++/85133, ICE with missing concept initializer | expand

Commit Message

Jason Merrill April 4, 2018, 3:33 p.m. UTC
Making the concept always satisfied seems good for error recovery.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox series

Patch

commit c2e6a2a7e163f285891620e64144b45e1418870a
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 3 16:40:02 2018 -0400

            PR c++/85133 - ICE with missing concept initializer.
    
            * decl.c (cp_finish_decl): If a concept initializer is missing, use
            true.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 6ddbe2343f4..c8309979a4d 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7010,7 +7010,10 @@  cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
       if (!VAR_P (decl) || type_dependent_p)
 	/* We can't do anything if the decl has dependent type.  */;
       else if (!init && is_concept_var (decl))
-        error ("variable concept has no initializer");
+	{
+	  error ("variable concept has no initializer");
+	  init = boolean_true_node;
+	}
       else if (init
 	       && init_const_expr_p
 	       && TREE_CODE (type) != REFERENCE_TYPE
diff --git a/gcc/testsuite/g++.dg/concepts/var-concept7.C b/gcc/testsuite/g++.dg/concepts/var-concept7.C
new file mode 100644
index 00000000000..0df4a498a0d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/concepts/var-concept7.C
@@ -0,0 +1,8 @@ 
+// PR c++/85133
+// { dg-additional-options "-std=c++17 -fconcepts" }
+
+template<typename> concept bool C; // { dg-error "no initializer" }
+
+template<C...> struct A {};
+
+A<int> a;