((fd.isCtorDeclaration() && var.isField()) ||
(fd.isStaticCtorDeclaration() && !var.isField())) &&
fd.toParentDecl() == var.toParent2() &&
- (!e1 || e1.op == TOK.this_))
+ (!e1 || e1.op == EXP.this_))
{
bool result = true;
override final d_uns64 size(const ref Loc loc)
{
assert(type);
- return type.size();
+ const sz = type.size();
+ if (sz == SIZE_INVALID)
+ errors = true;
+ return sz;
}
/**
}
}
- if (e1 && e1.op == TOK.this_ && isField())
+ if (e1 && e1.op == EXP.this_ && isField())
{
VarDeclaration vthis = (cast(ThisExp)e1).var;
for (Scope* scx = sc; scx; scx = scx.enclosing)
}
}
- if (v && (isCtorinit() || isField()))
+ if (v && (v.isCtorinit() || isField()))
{
// It's only modifiable if inside the right constructor
if ((storage_class & (STC.foreach_ | STC.ref_)) == (STC.foreach_ | STC.ref_))
return false;
}
- final bool isCtorinit() const pure nothrow @nogc @safe
- {
- return (storage_class & STC.ctorinit) != 0;
- }
-
final bool isFinal() const pure nothrow @nogc @safe
{
return (storage_class & STC.final_) != 0;
if (o.dyncast() == DYNCAST.expression)
{
Expression e = cast(Expression)o;
- if (e.op == TOK.dSymbol)
+ if (e.op == EXP.dSymbol)
{
DsymbolExp ve = cast(DsymbolExp)e;
Declaration d = ve.s.isDeclaration();
bool ctorinit; // it has been initialized in a ctor
bool iscatchvar; // this is the exception object variable in catch() clause
bool isowner; // this is an Owner, despite it being `scope`
+ bool setInCtorOnly; // field can only be set in a constructor, as it is const or immutable
// Both these mean the var is not rebindable once assigned,
// and the destructor gets run when it goes out of scope
RootObject o = (*v2.objects)[i];
assert(o.dyncast() == DYNCAST.expression);
Expression e = cast(Expression)o;
- assert(e.op == TOK.dSymbol);
+ assert(e.op == EXP.dSymbol);
DsymbolExp se = cast(DsymbolExp)e;
se.s.setFieldOffset(ad, fieldState, isunion);
}
return false;
}
+ final bool isCtorinit() const pure nothrow @nogc @safe
+ {
+ return setInCtorOnly;
+ }
+
/*******************************
* Does symbol go into data segment?
* Includes extern variables.
ExpInitializer ez = _init.isExpInitializer();
assert(ez);
Expression e = ez.exp;
- if (e.op == TOK.construct || e.op == TOK.blit)
+ if (e.op == EXP.construct || e.op == EXP.blit)
e = (cast(AssignExp)e).e2;
return lambdaCheckForNestedRef(e, sc);
}
assert(this.loc != Loc.initial);
assert(v.loc != Loc.initial);
- if (auto ld = this.loc.linnum - v.loc.linnum)
- return ld < 0;
+ if (this.loc.linnum != v.loc.linnum)
+ return this.loc.linnum < v.loc.linnum;
- if (auto cd = this.loc.charnum - v.loc.charnum)
- return cd < 0;
+ if (this.loc.charnum != v.loc.charnum)
+ return this.loc.charnum < v.loc.charnum;
// Default fallback
return this.sequenceNumber < v.sequenceNumber;
*/
extern (C++) final class SymbolDeclaration : Declaration
{
- StructDeclaration dsym;
+ AggregateDeclaration dsym;
- extern (D) this(const ref Loc loc, StructDeclaration dsym)
+ extern (D) this(const ref Loc loc, AggregateDeclaration dsym)
{
super(loc, dsym.ident);
this.dsym = dsym;