[libc] [lld] [flang] [clang] [libcxx] [compiler-rt] [llvm] [clang-tools-extra] [lldb] [Clang][C++23] Implement P2448R2: Relaxing some constexpr restrictions (PR #77753)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 24 03:43:47 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:

> isn't Info.Constexpr always true in c++ mode?

Hmm, then we probably don't need this change at all?

> Haybe calling a comparison function of a class with a non-literal member from a consteval function?

Should the call to such function be allowed? I suppose not due to-literal member. The problem is, there result is same with our without this change. I meant to apply this:

> CheckExplicitlyDefaultedComparison should alwways set the constexpr flag in c++23 mode per https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2448r2.html#pnum_39

Did I misunderstand?

https://github.com/llvm/llvm-project/pull/77753


More information about the cfe-commits mailing list