Author: Timm Baeder Date: 2026-01-13T09:28:02+01:00 New Revision: b0445a1ee6d1c7166408180bd8471e43493beb3b
URL: https://github.com/llvm/llvm-project/commit/b0445a1ee6d1c7166408180bd8471e43493beb3b DIFF: https://github.com/llvm/llvm-project/commit/b0445a1ee6d1c7166408180bd8471e43493beb3b.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; }; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
