From: Jason Merrill Date: Fri, 28 Feb 2020 22:39:42 +0000 (-0500) Subject: c++: implement C++20 Disambiguating Nested-Requirements (P2092R0) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=117baab87711553e36074f624861c2d034af8b6c;p=gcc.git c++: implement C++20 Disambiguating Nested-Requirements (P2092R0) The rule change in the title matches GCC's current behavior, so no change was needed. But the paper also makes 'typename' optional in a requirement-parameter-list, so this implements that. gcc/cp/ChangeLog 2020-02-28 Jason Merrill Implement P2092R0, Disambiguating Nested-Requirements * parser.c (cp_parser_requirement_parameter_list): Pass CP_PARSER_FLAGS_TYPENAME_OPTIONAL. --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8a8de3237cd..4c87bde5d1c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2020-02-28 Jason Merrill + Implement P2092R0, Disambiguating Nested-Requirements + * parser.c (cp_parser_requirement_parameter_list): Pass + CP_PARSER_FLAGS_TYPENAME_OPTIONAL. + * call.c (build_user_type_conversion_1): Don't look at the second conversion of a non-viable candidate. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index ca85d899427..24f71671469 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -27716,8 +27716,8 @@ cp_parser_requirement_parameter_list (cp_parser *parser) if (!parens.require_open (parser)) return error_mark_node; - tree parms - = cp_parser_parameter_declaration_clause (parser, CP_PARSER_FLAGS_NONE); + tree parms = (cp_parser_parameter_declaration_clause + (parser, CP_PARSER_FLAGS_TYPENAME_OPTIONAL)); if (!parens.require_close (parser)) return error_mark_node; diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-p2092.C b/gcc/testsuite/g++.dg/cpp2a/concepts-p2092.C new file mode 100644 index 00000000000..f293581a75a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-p2092.C @@ -0,0 +1,8 @@ +// P2092R0 +// { dg-do compile { target concepts } } + +template +concept Bar = requires (T::type t) { ++t; }; + +template +concept Foo = requires { requires { T(); }; }; // { dg-error "" }