This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Permit static constexpr variables in constexpr functions
ClosedPublic

Authored by cor3ntin on Nov 28 2022, 12:05 PM.

Details

Summary

This implement the C++23 paper P2647R1 (adopted in Kona)

Diff Detail

Event Timeline

cor3ntin created this revision.Nov 28 2022, 12:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2022, 12:05 PM
cor3ntin requested review of this revision.Nov 28 2022, 12:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2022, 12:05 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
cor3ntin added a reviewer: Restricted Project.Nov 28 2022, 12:06 PM

Can you add some tests that do meaningful things with the static variable? Particularly during constexpr evaluation time?

cor3ntin updated this revision to Diff 478321.Nov 28 2022, 12:16 PM

Add an evaluation test.

erichkeane accepted this revision.Nov 28 2022, 12:20 PM
This revision is now accepted and ready to land.Nov 28 2022, 12:20 PM
This revision was landed with ongoing or failed builds.Nov 28 2022, 12:38 PM
This revision was automatically updated to reflect the committed changes.
shafik added a subscriber: shafik.Jan 12 2023, 9:43 AM
shafik added inline comments.
clang/test/SemaCXX/constant-expression-cxx2b.cpp
246

Can we also add the test from the proposal as well for completeness sake:

constexpr char test() {
   static const int x = 5;
   static constexpr char c[] = "Hello World";
   return *(c+x);
}
static_assert(' ' == test());