Author: Corentin Jabot Date: 2021-08-03T07:42:29-04:00 New Revision: 977bdf6f44edabb857bdff9ca249aa6eccb98e96
URL: https://github.com/llvm/llvm-project/commit/977bdf6f44edabb857bdff9ca249aa6eccb98e96 DIFF: https://github.com/llvm/llvm-project/commit/977bdf6f44edabb857bdff9ca249aa6eccb98e96.diff LOG: Make simple requirements starting with requires ill-formed in in requirement body This patch implements P2092 Simple requirements in requirement body shall not start with requires. A warning was already in place so we just turn this warning into an error. In addition, we add tests to make sure typename is optional in requirement-parameter-list as per the same paper. Added: Modified: clang/include/clang/Basic/DiagnosticParseKinds.td clang/lib/Parse/ParseExprCXX.cpp clang/test/Parser/cxx2a-concepts-requires-expr.cpp clang/www/cxx_status.html Removed: ################################################################################ diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index 7e4b0841e06b1..a4aa7fec4d557 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -806,10 +806,10 @@ def err_requires_expr_expected_type_constraint : Error< def err_requires_expr_simple_requirement_noexcept : Error< "'noexcept' can only be used in a compound requirement (with '{' '}' around " "the expression)">; -def warn_requires_expr_in_simple_requirement : Warning< - "this requires expression will only be checked for syntactic validity; did " +def err_requires_expr_in_simple_requirement : Error< + "requires expression in requirement body; did " "you intend to place it in a nested requirement? (add another 'requires' " - "before the expression)">, InGroup<DiagGroup<"requires-expression">>; + "before the expression)">; def err_missing_dependent_template_keyword : Error< "use 'template' keyword to treat '%0' as a dependent template name">; diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index f3d10b4a08895..3f357233f9bb4 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -3602,7 +3602,7 @@ ExprResult Parser::ParseRequiresExpression() { break; } if (!Expression.isInvalid() && PossibleRequiresExprInSimpleRequirement) - Diag(StartLoc, diag::warn_requires_expr_in_simple_requirement) + Diag(StartLoc, diag::err_requires_expr_in_simple_requirement) << FixItHint::CreateInsertion(StartLoc, "requires"); if (auto *Req = Actions.ActOnSimpleRequirement(Expression.get())) Requirements.push_back(Req); diff --git a/clang/test/Parser/cxx2a-concepts-requires-expr.cpp b/clang/test/Parser/cxx2a-concepts-requires-expr.cpp index d1a31b4f93ef1..d22f21b786f44 100644 --- a/clang/test/Parser/cxx2a-concepts-requires-expr.cpp +++ b/clang/test/Parser/cxx2a-concepts-requires-expr.cpp @@ -134,13 +134,13 @@ void r37(bool b) requires requires { 1 } {} // expected-error@-1 {{expected ';' at end of requirement}} bool r38 = requires { requires { 1; }; }; -// expected-warning@-1 {{this requires expression will only be checked for syntactic validity; did you intend to place it in a nested requirement? (add another 'requires' before the expression)}} +// expected-error@-1 {{requires expression in requirement body; did you intend to place it in a nested requirement? (add another 'requires' before the expression)}} bool r39 = requires { requires () { 1; }; }; -// expected-warning@-1 {{this requires expression will only be checked for syntactic validity; did you intend to place it in a nested requirement? (add another 'requires' before the expression)}} +// expected-error@-1 {{requires expression in requirement body; did you intend to place it in a nested requirement? (add another 'requires' before the expression)}} bool r40 = requires { requires (int i) { i; }; }; -// expected-warning@-1 {{this requires expression will only be checked for syntactic validity; did you intend to place it in a nested requirement? (add another 'requires' before the expression)}} +// expected-error@-1 {{requires expression in requirement body; did you intend to place it in a nested requirement? (add another 'requires' before the expression)}} bool r41 = requires { requires (); }; // expected-error@-1 {{expected expression}} diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html index 2ad2047f68d00..0e78d63220e49 100755 --- a/clang/www/cxx_status.html +++ b/clang/www/cxx_status.html @@ -934,7 +934,7 @@ <h2 id="cxx20">C++20 implementation status</h2> </tr> <tr> <!-- from Belfast --> <td><a href="https://wg21.link/p1972r0">P1972R0</a></td> - <td rowspan="5" class="none" align="center">No</td> + <td rowspan="3" class="none" align="center">No</td> </tr> <tr> <td><a href="https://wg21.link/p1980r0">P1980R0</a></td> @@ -944,9 +944,11 @@ <h2 id="cxx20">C++20 implementation status</h2> </tr> <tr> <td><a href="https://wg21.link/p2092r0">P2092R0</a></td> + <td rowspan="1" class="partial" align="center">Clang 13</td> </tr> <tr> <td><a href="https://wg21.link/p2113r0">P2113R0</a></td> + <td rowspan="1" class="none" align="center">No</td> </tr> <!-- Albuquerque papers --> <tr> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits