https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/179087
Fixes https://github.com/llvm/llvm-project/issues/179020 >From 2d725d567892b38c27adffac18aa592ed67e7c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Sun, 1 Feb 2026 06:52:53 +0100 Subject: [PATCH] [clang][bytecode] Reject CK_BitCast nodes with errors early Fixes https://github.com/llvm/llvm-project/issues/179020 --- clang/lib/AST/ByteCode/Compiler.cpp | 2 ++ clang/test/AST/ByteCode/invalid.cpp | 5 +++++ 2 files changed, 7 insertions(+) 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
