Skip to content

Commit fb9915a

Browse files
authored
[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.
1 parent bdd0870 commit fb9915a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6801,6 +6801,10 @@ bool Compiler<Emitter>::emitDestruction(const Descriptor *Desc,
68016801
assert(!Desc->isPrimitive());
68026802
assert(!Desc->isPrimitiveArray());
68036803

6804+
// Can happen if the decl is invalid.
6805+
if (Desc->isDummy())
6806+
return true;
6807+
68046808
// Arrays.
68056809
if (Desc->isArray()) {
68066810
const Descriptor *ElemDesc = Desc->ElemDesc;

clang/test/AST/ByteCode/cxx17.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,14 @@ namespace constant {
125125
}
126126
static_assert(f());
127127
}
128+
129+
130+
template <int a> struct i; // both-note {{template is declared here}}
131+
template <> struct i<0> {};
132+
133+
template <int x> constexpr auto c() {
134+
i<x> g; // both-error {{implicit instantiation of undefined template 'i<1>'}}
135+
return 0;
136+
}
137+
138+
auto y = c<1>(); // both-note {{in instantiation of function template specialization 'c<1>' requested here}}

0 commit comments

Comments
 (0)