[PATCH] D111400: [Clang] Implement P2242R3

Hubert Tong via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 15 09:55:09 PDT 2022


hubert.reinterpretcast added a comment.

@aaron.ballman @cor3ntin, are we confident that testing the non-lambda cases is sufficient to cover the lambda cases as well?

I suggest using a pattern such as:

  int (*test_cxx2b_constexpr_label_in_body())() {
    auto qq = []() {
      label: return 42;
    };
    const int x = qq();
    auto ff = [] { return x; }; // passes in C++2b; error in C++20
    return ff;
  }

For each of the cases.



================
Comment at: clang/lib/AST/ExprConstant.cpp:5010
+  // through a declaration of a variable with static or thread storage duration.
+  if (VD->isLocalVarDecl() && !VD->isConstexpr() && VD->isStaticLocal()) {
+    Info.CCEDiag(VD->getLocation(), diag::note_constexpr_static_local)
----------------
I don't see anything in the wording exempting `constexpr static` (although I suppose it makes sense to, but GCC does not make such an exemption in its C++2b mode). @cor3ntin, can you open a discussion on the reflector?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111400



More information about the cfe-commits mailing list