https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/242231
None >From fc2bd68eace65974ad3b60bd290464689577d8bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Fri, 13 Nov 2026 11:00:45 +0100 Subject: [PATCH] [clang][bytecode] Reject CXXTypeIdExprs with errors --- clang/lib/AST/ByteCode/Compiler.cpp | 3 +++ clang/test/AST/ByteCode/typeid.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index e3232d943ee4d..5044656e3afff 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -4583,6 +4583,9 @@ bool Compiler<Emitter>::VisitBlockExpr(const BlockExpr *E) { template <class Emitter> bool Compiler<Emitter>::VisitCXXTypeidExpr(const CXXTypeidExpr *E) { + if (E->containsErrors()) + return false; + const Type *TypeInfoType = E->getType().getTypePtr(); auto canonType = [](const Type *T) { diff --git a/clang/test/AST/ByteCode/typeid.cpp b/clang/test/AST/ByteCode/typeid.cpp index 4b9c024632354..99a864432f1ac 100644 --- a/clang/test/AST/ByteCode/typeid.cpp +++ b/clang/test/AST/ByteCode/typeid.cpp @@ -111,3 +111,13 @@ namespace TypeIdInOtherStruct { auto &zti = typeid(z.y); static_assert(&zti == &typeid(Y)); } + +/// CXXTypeIdExpr containing errors. +namespace std { +struct type_info struct S { // both-error {{cannot combine with previous 'struct' declaration specifier}} + virtual ~S(); + constexpr void foo() { typeid((S &&)*nullptr); } // both-error {{indirection requires pointer operand}} \ + // both-warning {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}} \ + // both-warning {{expression result unused}} +}; +}; // namespace std _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
