[PATCH] D106252: Make simple requirements starting with requires ill-formed in in requirement body

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 24 00:55:24 PDT 2021


cor3ntin updated this revision to Diff 361416.
cor3ntin added a comment.

- Fix typos
- remove the tests about typenames (don't pass yet)
- Mark as partial until P2092 <https://reviews.llvm.org/P2092> is implemented


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106252/new/

https://reviews.llvm.org/D106252

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/Parser/cxx2a-concepts-requires-expr.cpp
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===================================================================
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -934,7 +934,7 @@
       </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 @@
       </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>
Index: clang/test/Parser/cxx2a-concepts-requires-expr.cpp
===================================================================
--- clang/test/Parser/cxx2a-concepts-requires-expr.cpp
+++ clang/test/Parser/cxx2a-concepts-requires-expr.cpp
@@ -134,13 +134,13 @@
 // expected-error at -1 {{expected ';' at end of requirement}}
 
 bool r38 = requires { requires { 1; }; };
-// expected-warning at -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 at -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 at -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 at -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 at -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 at -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 at -1 {{expected expression}}
Index: clang/lib/Parse/ParseExprCXX.cpp
===================================================================
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -3602,7 +3602,7 @@
           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);
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -806,10 +806,10 @@
 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">;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106252.361416.patch
Type: text/x-patch
Size: 4152 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210724/acd8c09e/attachment-0001.bin>


More information about the cfe-commits mailing list