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

Mariya Podchishchaeva via flang-commits flang-commits at lists.llvm.org
Wed Jan 24 08:31:45 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?
C++23, sorry

Not sure it is always true even for C++23, I think it is true when the operator produces constexpr. Otherwise we would have never emitted warn_cxx23_compat_defaulted_comparison_constexpr_mismatch a bit earlier than my change, and we do.

> The error message should be different though, right? something like "the call to operator== is not a constant expression" ?

In both cases it says "non-literal type 'ComparisonNonConstexpr' cannot be used in a constant expression".

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


More information about the flang-commits mailing list