[PATCH] D111400: [Clang] Implement P2242R3

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 15 07:42:24 PDT 2022


aaron.ballman added inline comments.


================
Comment at: clang/test/SemaCXX/constant-expression-cxx2b.cpp:60-61
+
+constexpr int ke = k_evaluated(1); //expected-error {{constexpr variable 'ke' must be initialized by a constant expression}} \
+                                   //expected-note {{in call}}
+
----------------
cor3ntin wrote:
> aaron.ballman wrote:
> > This error seems suspect to me. If we made flowing through a thread_local into an extension (line 54), then this code should be accepted. However, I think we're getting the error because the constant expression evaluator produces the note on line 55 and that usually will cause the evaluator to claim it wasn't a constant expression.
> We can not evaluate at compile time a thread_local or static, even if we allow them to appear in a `constexpr` function. So this is the behavior I'd expect
Yes, you're right, I lost that context before. Sorry for the noise, I think the error here is correct. But I also worry that users may get confused in the same way I just did. That said, I can't think of a better diagnostic wording and I think the behavior in situ will be fine because the note will be "attached" to the error in the diagnostic output, which makes the error more clear than reading the code statically in the review.


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