[llvm-branch-commits] [clang] fa656d9 - [clang][bytecode] Diagnose regular CK_LValueBitCast cast nodes (#175721)
Cullen Rhodes via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jan 13 02:21:16 PST 2026
Author: Timm Baeder
Date: 2026-01-13T10:18:55Z
New Revision: fa656d9cd4b04b3ced5fb628256bb565fa4895fd
URL: https://github.com/llvm/llvm-project/commit/fa656d9cd4b04b3ced5fb628256bb565fa4895fd
DIFF: https://github.com/llvm/llvm-project/commit/fa656d9cd4b04b3ced5fb628256bb565fa4895fd.diff
LOG: [clang][bytecode] Diagnose regular CK_LValueBitCast cast nodes (#175721)
We already do this similarly for CXXReinterpretCastExprs, except in that
case we try harder to make things work.
Added:
Modified:
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/AST/ByteCode/cxx11.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index a67648aa2aff9..0a0a5dd5c47c8 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -779,6 +779,9 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
// a diagnostic if appropriate.
return this->delegate(SubExpr);
+ case CK_LValueBitCast:
+ return this->emitInvalidCast(CastKind::ReinterpretLike, /*Fatal=*/true, CE);
+
default:
return this->emitInvalid(CE);
}
diff --git a/clang/test/AST/ByteCode/cxx11.cpp b/clang/test/AST/ByteCode/cxx11.cpp
index 9a61321f67a40..e1fb5948b7708 100644
--- a/clang/test/AST/ByteCode/cxx11.cpp
+++ b/clang/test/AST/ByteCode/cxx11.cpp
@@ -33,6 +33,10 @@ constexpr int b = b; // both-error {{must be initialized by a constant expressio
// both-note {{declared here}}
+ void func();
+ constexpr int (&fp4)() = (int(&)())func; // both-error {{constant expression}} \
+ // both-note {{reinterpret_cast}}
+
struct S {
int m;
};
More information about the llvm-branch-commits
mailing list