[clang] [clang] Allow C-style casts in constexpr in MS compatible mode (PR #197005)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Fri May 29 11:00:01 PDT 2026


================
@@ -8533,7 +8533,9 @@ class ExprEvaluatorBase
   }
 
   bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E) {
-    CCEDiag(E, diag::note_constexpr_invalid_cast)
+    bool IsPtrToInt = E->getCastKind() == CK_PointerToIntegral;
+    CCEDiag(E, IsPtrToInt ? diag::note_constexpr_invalid_cast_ptrtoint
+                          : diag::note_constexpr_invalid_cast)
----------------
efriedma-quic wrote:

We can pass in a bit denoting that we're not in an SFINAE context, and use that to suppress the normal diagnostic with -fms-compatibility, sure.  But we still need to generate warn_relaxed_constant_fold somewhere.

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


More information about the cfe-commits mailing list