From 117baab87711553e36074f624861c2d034af8b6c Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 28 Feb 2020 17:39:42 -0500 Subject: [PATCH] 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. --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/parser.c | 4 ++-- gcc/testsuite/g++.dg/cpp2a/concepts-p2092.C | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-p2092.C 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 "" } -- 2.30.2