[clang] [clang] Add support for relaxed constexpr evaluation to interpreter (PR #217311)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 19 06:03:07 PDT 2026


================
@@ -2713,9 +2715,13 @@ bool InvalidShuffleVectorIndex(InterpState &S, CodePtr OpPC, uint32_t Index) {
 bool CheckPointerToIntegralCast(InterpState &S, CodePtr OpPC,
                                 const Pointer &Ptr, unsigned BitWidth) {
   SourceInfo E = S.Current->getSource(OpPC);
-  S.CCEDiag(E, diag::note_constexpr_invalid_cast)
-      << 2 << S.getLangOpts().CPlusPlus << S.Current->getRange(OpPC);
 
+  S.CCEDiag(E, diag::note_constexpr_invalid_cast_ptrtoint)
+      << diag::ConstexprInvalidCastKind::ThisConversionOrReinterpret
+      << S.getLangOpts().CPlusPlus << S.Current->getRange(OpPC);
+  APValue V = Ptr.toAPValue(S.getASTContext());
+  if (V.getLValueBase())
+    S.CCEDiag(E, diag::note_constexpr_has_lvalue) << S.Current->getRange(OpPC);
----------------
tbaederr wrote:

It is zero in the latter case. `if (Ptr.isBlockPointer() && !Ptr.isZero())` works.

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


More information about the cfe-commits mailing list