[clang] [Clang][C++23] Implement P2448R2: Relaxing some constexpr restrictions (PR #77753)
Mariya Podchishchaeva via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 5 07:27:33 PST 2024
================
@@ -9108,7 +9123,8 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *FD,
// declaration, it is implicitly considered to be constexpr.
// FIXME: Only applying this to the first declaration seems problematic, as
// simple reorderings can affect the meaning of the program.
- if (First && !FD->isConstexpr() && Info.Constexpr)
+ if ((First && !FD->isConstexpr() && Info.Constexpr) ||
+ getLangOpts().CPlusPlus23)
----------------
Fznamznon wrote:
I'm not sure actually that this change is required.
If the function is marked constexpr then we're all set here.
If the function is not explicitly marked constexpr, we could force it constexpr for c++23, but it is already done if it is Info.Constexpr is true.
If Info.Constexpr is false it means that the function is constexpr only in c++23 and it means it can't be called from real constexpr
context anyway, additionally marking it constexpr doesn't lift more errors.
The point of p2448r2 here is that we can attach constexpr explicitly to it.
https://github.com/llvm/llvm-project/pull/77753
More information about the cfe-commits
mailing list