[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.
This commit is contained in:
Timm Baeder 2025-04-08 06:00:35 +02:00 committed by GitHub
parent bdd087023f
commit fb9915a391
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View File

@ -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;

View File

@ -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}}