c++: implement C++20 Disambiguating Nested-Requirements (P2092R0)
authorJason Merrill <jason@redhat.com>
Fri, 28 Feb 2020 22:39:42 +0000 (17:39 -0500)
committerJason Merrill <jason@redhat.com>
Sat, 29 Feb 2020 05:43:23 +0000 (00:43 -0500)
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.

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/cpp2a/concepts-p2092.C [new file with mode: 0644]

index 8a8de3237cd8c077dbc93189f65d99635bdb92a0..4c87bde5d1c3abfc0f956e24aac46e900dc62389 100644 (file)
@@ -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.
 
index ca85d899427d3b4b33c543834eb3703c1ee5abc6..24f716714692512908de2810ad503c107a034785 100644 (file)
@@ -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 (file)
index 0000000..f293581
--- /dev/null
@@ -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 "" }