https://github.com/daniel-petrovic created https://github.com/llvm/llvm-project/pull/235341
Fixes: #235252 >From 93bbfb8cc054ffcbda90890c467208fe551217eb Mon Sep 17 00:00:00 2001 From: Daniel Petrovic <[email protected]> Date: Sat, 24 Oct 2026 20:51:26 +0200 Subject: [PATCH] [clang] Reject invalid record declarations in builtin bit_cast checks Fixes: #235252 --- clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp | 2 ++ clang/lib/AST/ExprConstant.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp index 3bec4f3bf1396b..ebaf4ecb2da637 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp @@ -295,6 +295,8 @@ static bool CheckBitcastType(InterpState &S, CodePtr OpPC, QualType T, return diag(E_Volatile); if (const RecordDecl *RD = T->getAsRecordDecl()) { + if (RD->isInvalidDecl()) + return false; if (const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) { for (const CXXBaseSpecifier &BS : CXXRD->bases()) { if (!CheckBitcastType(S, OpPC, BS.getType(), IsToType)) diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 3762bc83c779b0..4a97be3d68a87b 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -8603,7 +8603,10 @@ static bool checkBitCastConstexprEligibilityType(SourceLocation Loc, if (Ty.isVolatileQualified()) return diag(3); + if (RecordDecl *Record = Ty->getAsRecordDecl()) { + if (Record->isInvalidDecl()) + return false; if (auto *CXXRD = dyn_cast<CXXRecordDecl>(Record)) { for (CXXBaseSpecifier &BS : CXXRD->bases()) if (!checkBitCastConstexprEligibilityType(Loc, BS.getType(), Info, Ctx, _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
