From 6173fb512fca3ae6595c584e9af3765400c5a3de Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 4 Apr 2018 12:42:50 -0400 Subject: [PATCH] PR c++/85133 - ICE with missing concept initializer. * decl.c (cp_finish_decl): If a concept initializer is missing, use true. From-SVN: r259091 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/decl.c | 5 ++++- gcc/testsuite/g++.dg/concepts/var-concept7.C | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/concepts/var-concept7.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f0927e82b36..0f857449b8f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2018-04-04 Jason Merrill + 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. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index c8ae72faeae..1cc2cd16ccc 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 concept bool C; // { dg-error "no initializer" } + +template struct A {}; + +A a; -- 2.30.2