[PATCH] D99489: [clang] [PR49736] [C++2b] Correctly reject lambdas with requires clause and no parameter list

Marek Kurdej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 30 00:32:52 PDT 2021


curdeius added inline comments.


================
Comment at: clang/test/Parser/cxx2a-template-lambdas.cpp:17
+#endif
+auto L7 = []<auto> requires true {}; // ?
+auto L8 = []<auto> requires true noexcept {};
----------------
aaron.ballman wrote:
> This seems grammatically valid to me, was there a reason for the `// ?`?
Ooops, a WIP remnant.


================
Comment at: clang/test/Parser/cxx2a-template-lambdas.cpp:25-29
+auto L11 = []<auto> requires true(){};
+auto L12 = []<auto> requires true() noexcept {};
+auto L13 = []<auto> requires true() noexcept requires true {};
+auto L14 = []<auto>() noexcept requires true {};
+auto L15 = []<auto> requires true(){};
----------------
rsmith wrote:
> I'd find these examples easier to read with a space between `true` and `()`.
I've just clang-formatted the code. Isn't it the way to go?
I can format manually if desired though.


================
Comment at: clang/test/Parser/cxx2a-template-lambdas.cpp:33-36
+#if __cplusplus <= 202002L
+// expected-warning at -3 {{is a C++2b extension}}
+// expected-warning at -3 {{is a C++2b extension}}
+#endif
----------------
aaron.ballman wrote:
> It seems odd to warn the user about use of an extension they're not really using, but I don't think this is strictly wrong as opposed to just not being ideal. I don't think this will be trivial to improve the behavior, so I think it's fine for the moment.
I agree that having an error **and** a warning is strange, but IMO the extension is used here.
Without the extension, you couldn't have `noexcept` without `()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99489



More information about the cfe-commits mailing list