PR c++/85133 - ICE with missing concept initializer.
authorJason Merrill <jason@redhat.com>
Wed, 4 Apr 2018 16:42:50 +0000 (12:42 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 4 Apr 2018 16:42:50 +0000 (12:42 -0400)
* decl.c (cp_finish_decl): If a concept initializer is missing, use
true.

From-SVN: r259091

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/concepts/var-concept7.C [new file with mode: 0644]

index f0927e8..0f85744 100644 (file)
@@ -1,5 +1,9 @@
 2018-04-04  Jason Merrill  <jason@redhat.com>
 
+       PR c++/85133 - ICE with missing concept initializer.
+       * decl.c (cp_finish_decl): If a concept initializer is missing, use
+       true.
+
        PR c++/85118 - wrong error with generic lambda and std::bind.
        * call.c (add_template_conv_candidate): Disable if there are any
        call operators.
index c8ae72f..1cc2cd1 100644 (file)
@@ -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 (file)
index 0000000..0df4a49
--- /dev/null
@@ -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;