Author: Timm Baeder Date: 2025-04-08T06:00:35+02:00 New Revision: fb9915a3918e3a9659a7f2825ee35bada3a2baf1
URL: https://github.com/llvm/llvm-project/commit/fb9915a3918e3a9659a7f2825ee35bada3a2baf1 DIFF: https://github.com/llvm/llvm-project/commit/fb9915a3918e3a9659a7f2825ee35bada3a2baf1.diff LOG: [clang][bytecode] Fix emitDestruction() for dummy descriptors (#134665) This might happen if the referenced declaration is invalid and thus gets a dummy descriptor. We ran into an assertion later on. Added: Modified: clang/lib/AST/ByteCode/Compiler.cpp clang/test/AST/ByteCode/cxx17.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index dd246f7ef74fc..db87ea1b6016f 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -6801,6 +6801,10 @@ bool Compiler<Emitter>::emitDestruction(const Descriptor *Desc, assert(!Desc->isPrimitive()); assert(!Desc->isPrimitiveArray()); + // Can happen if the decl is invalid. + if (Desc->isDummy()) + return true; + // Arrays. if (Desc->isArray()) { const Descriptor *ElemDesc = Desc->ElemDesc; diff --git a/clang/test/AST/ByteCode/cxx17.cpp b/clang/test/AST/ByteCode/cxx17.cpp index ecb8a395520a0..9453906579f04 100644 --- a/clang/test/AST/ByteCode/cxx17.cpp +++ b/clang/test/AST/ByteCode/cxx17.cpp @@ -125,3 +125,14 @@ namespace constant { } static_assert(f()); } + + +template <int a> struct i; // both-note {{template is declared here}} +template <> struct i<0> {}; + +template <int x> constexpr auto c() { + i<x> g; // both-error {{implicit instantiation of undefined template 'i<1>'}} + return 0; +} + +auto y = c<1>(); // both-note {{in instantiation of function template specialization 'c<1>' requested here}} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits