Fix ICE for ref/out params of opaque structs

Fixes dmd-testsuite's new compilable/test21668.d.
This commit is contained in:
Martin Kinkelin 2021-03-01 11:12:28 +01:00
parent 3abffca14c
commit 52bcbcc566
3 changed files with 25 additions and 13 deletions

View file

@ -152,7 +152,9 @@ void DtoDeleteArray(const Loc &loc, DValue *arr) {
unsigned DtoAlignment(Type *type) {
structalign_t alignment = type->alignment();
if (alignment == STRUCTALIGN_DEFAULT) {
alignment = type->alignsize();
auto ts = type->toBasetype()->isTypeStruct();
if (!ts || ts->sym->members) // not an opaque struct
alignment = type->alignsize();
}
return (alignment == STRUCTALIGN_DEFAULT ? 0 : alignment);
}