Skip to content

Commit

Permalink
refactor isPOD() (dlang#16883)
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright authored and thewilsonator committed Oct 7, 2024
1 parent c787892 commit d84aa2b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions compiler/src/dmd/dstruct.d
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,15 @@ extern (C++) class StructDeclaration : AggregateDeclaration
if (ispod != ThreeState.none)
return (ispod == ThreeState.yes);

ispod = ThreeState.yes;

import dmd.clone;

bool hasCpCtorLocal;
needCopyCtor(this, hasCpCtorLocal);

if (enclosing || search(this, loc, Id.postblit) || search(this, loc, Id.dtor) || hasCpCtorLocal)
if (enclosing || // is nested
search(this, loc, Id.postblit) || // has postblit
search(this, loc, Id.dtor) || // has destructor
hasCpCtorLocal) // has copy constructor
{
ispod = ThreeState.no;
return false;
Expand All @@ -453,20 +455,18 @@ extern (C++) class StructDeclaration : AggregateDeclaration
return false;
}

Type tv = v.type.baseElemOf();
if (tv.ty == Tstruct)
if (auto ts = v.type.baseElemOf().isTypeStruct())
{
auto ts = cast(TypeStruct)tv;
StructDeclaration sd = ts.sym;
if (!sd.isPOD())
if (!ts.sym.isPOD())
{
ispod = ThreeState.no;
return false;
}
}
}

return (ispod == ThreeState.yes);
ispod = ThreeState.yes;
return true;
}

/***************************************
Expand Down

0 comments on commit d84aa2b

Please sign in to comment.