[gcc(refs/vendors/redhat/heads/gcc-10-branch)] c++: implement C++20 Disambiguating Nested-Requirements (P2092R0)

Jakub Jelinek jakub@gcc.gnu.org
Wed Mar 11 22:57:46 GMT 2020


https://gcc.gnu.org/g:117baab87711553e36074f624861c2d034af8b6c

commit 117baab87711553e36074f624861c2d034af8b6c
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Feb 28 17:39:42 2020 -0500

    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  <jason@redhat.com>
    
            Implement P2092R0, Disambiguating Nested-Requirements
            * parser.c (cp_parser_requirement_parameter_list): Pass
            CP_PARSER_FLAGS_TYPENAME_OPTIONAL.

Diff:
---
 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(-)

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  <jason@redhat.com>
 
+	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 <class T>
+concept Bar = requires (T::type t) { ++t; };
+
+template <class T>
+concept Foo = requires { requires { T(); }; }; // { dg-error "" }


More information about the Gcc-cvs mailing list