Author: Timm Baeder Date: 2026-02-01T10:08:06+01:00 New Revision: 68850427ba1e2788824843d735d8fb363f4539bd
URL: https://github.com/llvm/llvm-project/commit/68850427ba1e2788824843d735d8fb363f4539bd DIFF: https://github.com/llvm/llvm-project/commit/68850427ba1e2788824843d735d8fb363f4539bd.diff LOG: [clang][bytecode] Reject CK_BitCast nodes with errors early (#179087) Fixes https://github.com/llvm/llvm-project/issues/179020 Added: Modified: clang/lib/AST/ByteCode/Compiler.cpp clang/test/AST/ByteCode/invalid.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index da1db48c55a07..af076f90733df 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -477,6 +477,8 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) { return this->delegate(SubExpr); case CK_BitCast: { + if (CE->containsErrors()) + return false; QualType CETy = CE->getType(); // Reject bitcasts to atomic types. if (CETy->isAtomicType()) { diff --git a/clang/test/AST/ByteCode/invalid.cpp b/clang/test/AST/ByteCode/invalid.cpp index f7f2da2769d65..bfb33d0cc6dce 100644 --- a/clang/test/AST/ByteCode/invalid.cpp +++ b/clang/test/AST/ByteCode/invalid.cpp @@ -132,3 +132,8 @@ namespace RetVoidInInvalidFunc { }; X<foo()> x; // both-error {{non-type template argument is not a constant expression}} } + +namespace BitCastWithErrors { + template<class T> int f(); // both-note {{candidate template ignored}} + static union { char *x = f(); }; // both-error {{no matching function for call to 'f'}} +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
