From: Jason Merrill Date: Thu, 14 Mar 2019 19:53:04 +0000 (-0400) Subject: Don't require 'bool' in a concept definition. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f869f40780836d1744ec973e6d0e9d948947d509;p=gcc.git Don't require 'bool' in a concept definition. * parser.c (cp_parser_decl_specifier_seq): Support C++20 concept-definition syntax without 'bool'. From-SVN: r269692 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 054a891bcef..6c96c24430f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-03-14 Jason Merrill + + * parser.c (cp_parser_decl_specifier_seq): Support C++20 + concept-definition syntax without 'bool'. + 2019-03-14 Jakub Jelinek PR c++/89512 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 14da1a14501..b8a0245ce57 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -13964,6 +13964,15 @@ cp_parser_decl_specifier_seq (cp_parser* parser, case RID_CONCEPT: ds = ds_concept; cp_lexer_consume_token (parser->lexer); + /* In C++20 a concept definition is just 'concept name = expr;' + Support that syntax by pretending we've seen 'bool'. */ + if (cp_lexer_next_token_is (parser->lexer, CPP_NAME) + && cp_lexer_nth_token_is (parser->lexer, 2, CPP_EQ)) + { + cp_parser_set_decl_spec_type (decl_specs, boolean_type_node, + token, /*type_definition*/false); + decl_specs->any_type_specifiers_p = true; + } break; /* function-specifier: diff --git a/gcc/testsuite/g++.dg/concepts/no-bool1.C b/gcc/testsuite/g++.dg/concepts/no-bool1.C new file mode 100644 index 00000000000..be9b73a0689 --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/no-bool1.C @@ -0,0 +1,4 @@ +// { dg-do compile { target c++14 } } +// { dg-additional-options -fconcepts } + +template concept True = true;