From fd577de4650baba7b8aab015dd7747f7a133d18d Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Mon, 8 Jan 2018 04:23:48 +0100 Subject: [PATCH 1/2] add STC enum --- src/dmd/astbase.d | 114 +++++++++++++++++++++-------------------- src/dmd/astcodegen.d | 36 +------------ src/dmd/declaration.d | 115 ++++++++++++++++++++++-------------------- 3 files changed, 119 insertions(+), 146 deletions(-) diff --git a/src/dmd/astbase.d b/src/dmd/astbase.d index dbfcc318df5f..5cc8ccdc9dc0 100644 --- a/src/dmd/astbase.d +++ b/src/dmd/astbase.d @@ -107,61 +107,65 @@ struct ASTBase alias MOD = ubyte; - enum STCundefined = 0L; - enum STCstatic = (1L << 0); - enum STCextern = (1L << 1); - enum STCconst = (1L << 2); - enum STCfinal = (1L << 3); - enum STCabstract = (1L << 4); - enum STCparameter = (1L << 5); - enum STCfield = (1L << 6); - enum STCoverride = (1L << 7); - enum STCauto = (1L << 8); - enum STCsynchronized = (1L << 9); - enum STCdeprecated = (1L << 10); - enum STCin = (1L << 11); // in parameter - enum STCout = (1L << 12); // out parameter - enum STClazy = (1L << 13); // lazy parameter - enum STCforeach = (1L << 14); // variable for foreach loop - // (1L << 15) - enum STCvariadic = (1L << 16); // the 'variadic' parameter in: T foo(T a, U b, V variadic...) - enum STCctorinit = (1L << 17); // can only be set inside constructor - enum STCtemplateparameter = (1L << 18); // template parameter - enum STCscope = (1L << 19); - enum STCimmutable = (1L << 20); - enum STCref = (1L << 21); - enum STCinit = (1L << 22); // has explicit initializer - enum STCmanifest = (1L << 23); // manifest constant - enum STCnodtor = (1L << 24); // don't run destructor - enum STCnothrow = (1L << 25); // never throws exceptions - enum STCpure = (1L << 26); // pure function - enum STCtls = (1L << 27); // thread local - enum STCalias = (1L << 28); // alias parameter - enum STCshared = (1L << 29); // accessible from multiple threads - enum STCgshared = (1L << 30); // accessible from multiple threads, but not typed as "shared" - enum STCwild = (1L << 31); // for "wild" type constructor - enum STCproperty = (1L << 32); - enum STCsafe = (1L << 33); - enum STCtrusted = (1L << 34); - enum STCsystem = (1L << 35); - enum STCctfe = (1L << 36); // can be used in CTFE, even if it is static - enum STCdisable = (1L << 37); // for functions that are not callable - enum STCresult = (1L << 38); // for result variables passed to out contracts - enum STCnodefaultctor = (1L << 39); // must be set inside constructor - enum STCtemp = (1L << 40); // temporary variable - enum STCrvalue = (1L << 41); // force rvalue for variables - enum STCnogc = (1L << 42); // @nogc - enum STCvolatile = (1L << 43); // destined for volatile in the back end - enum STCreturn = (1L << 44); // 'return ref' or 'return scope' for function parameters - enum STCautoref = (1L << 45); // Mark for the already deduced 'auto ref' parameter - enum STCinference = (1L << 46); // do attribute inference - enum STCexptemp = (1L << 47); // temporary variable that has lifetime restricted to an expression - enum STCmaybescope = (1L << 48); // parameter might be 'scope' - enum STCfuture = (1L << 49); // introducing new base class function - - enum STC_TYPECTOR = (STCconst | STCimmutable | STCshared | STCwild); - - private enum STC_FUNCATTR = (STCref | STCnothrow | STCnogc | STCpure | STCproperty | STCsafe | STCtrusted | STCsystem); + enum STC : long + { + undefined_ = 0L, + static_ = (1L << 0), + extern_ = (1L << 1), + const_ = (1L << 2), + final_ = (1L << 3), + abstract_ = (1L << 4), + parameter = (1L << 5), + field = (1L << 6), + override_ = (1L << 7), + auto_ = (1L << 8), + synchronized_ = (1L << 9), + deprecated_ = (1L << 10), + in_ = (1L << 11), // in parameter + out_ = (1L << 12), // out parameter + lazy_ = (1L << 13), // lazy parameter + foreach_ = (1L << 14), // variable for foreach loop + //(1L << 15) + variadic = (1L << 16), // the 'variadic' parameter in: T foo(T a, U b, V variadic...) + ctorinit = (1L << 17), // can only be set inside constructor + templateparameter = (1L << 18), // template parameter + scope_ = (1L << 19), + immutable_ = (1L << 20), + ref_ = (1L << 21), + init = (1L << 22), // has explicit initializer + manifest = (1L << 23), // manifest constant + nodtor = (1L << 24), // don't run destructor + nothrow_ = (1L << 25), // never throws exceptions + pure_ = (1L << 26), // pure function + tls = (1L << 27), // thread local + alias_ = (1L << 28), // alias parameter + shared_ = (1L << 29), // accessible from multiple threads + gshared = (1L << 30), // accessible from multiple threads, but not typed as "shared" + wild = (1L << 31), // for "wild" type constructor + property = (1L << 32), + safe = (1L << 33), + trusted = (1L << 34), + system = (1L << 35), + ctfe = (1L << 36), // can be used in CTFE, even if it is static + disable = (1L << 37), // for functions that are not callable + result = (1L << 38), // for result variables passed to out contracts + nodefaultctor = (1L << 39), // must be set inside constructor + temp = (1L << 40), // temporary variable + rvalue = (1L << 41), // force rvalue for variables + nogc = (1L << 42), // @nogc + volatile_ = (1L << 43), // destined for volatile in the back end + return_ = (1L << 44), // 'return ref' or 'return scope' for function parameters + autoref = (1L << 45), // Mark for the already deduced 'auto ref' parameter + inference = (1L << 46), // do attribute inference + exptemp = (1L << 47), // temporary variable that has lifetime restricted to an expression + maybescope = (1L << 48), // parameter might be 'scope' + scopeinferred = (1L << 49), // 'scope' has been inferred and should not be part of mangling + future = (1L << 50), // introducing new base class function + local = (1L << 51), // do not forward (see dmd.dsymbol.ForwardingScopeDsymbol). + + TYPECTOR = (STC.const_ | STC.immutable_ | STC.shared_ | STC.wild), + FUNCATTR = (STC.ref_ | STC.nothrow_ | STC.nogc | STC.pure_ | STC.property | STC.safe | STC.trusted | STC.system), + } extern (C++) __gshared const(StorageClass) STCStorageClass = (STCauto | STCscope | STCstatic | STCextern | STCconst | STCfinal | STCabstract | STCsynchronized | STCdeprecated | STCoverride | STClazy | STCalias | STCout | STCin | STCmanifest | STCimmutable | STCshared | STCwild | STCnothrow | STCnogc | STCpure | STCref | STCreturn | STCtls | STCgshared | STCproperty | STCsafe | STCtrusted | STCsystem | STCdisable); diff --git a/src/dmd/astcodegen.d b/src/dmd/astcodegen.d index 4b10b785707c..4db132eed42f 100644 --- a/src/dmd/astcodegen.d +++ b/src/dmd/astcodegen.d @@ -49,41 +49,7 @@ struct ASTCodegen alias Tsarray = dmd.mtype.Tsarray; alias Terror = dmd.mtype.Terror; - alias STCconst = dmd.declaration.STCconst; - alias STCimmutable = dmd.declaration.STCimmutable; - alias STCshared = dmd.declaration.STCshared; - alias STCwild = dmd.declaration.STCwild; - alias STCin = dmd.declaration.STCin; - alias STCout = dmd.declaration.STCout; - alias STCref = dmd.declaration.STCref; - alias STClazy = dmd.declaration.STClazy; - alias STCscope = dmd.declaration.STCscope; - alias STCfinal = dmd.declaration.STCfinal; - alias STCauto = dmd.declaration.STCauto; - alias STCreturn = dmd.declaration.STCreturn; - alias STCmanifest = dmd.declaration.STCmanifest; - alias STCgshared = dmd.declaration.STCgshared; - alias STCtls = dmd.declaration.STCtls; - alias STCsafe = dmd.declaration.STCsafe; - alias STCsystem = dmd.declaration.STCsystem; - alias STCtrusted = dmd.declaration.STCtrusted; - alias STCnothrow = dmd.declaration.STCnothrow; - alias STCpure = dmd.declaration.STCpure; - alias STCproperty = dmd.declaration.STCproperty; - alias STCnogc = dmd.declaration.STCnogc; - alias STCdisable = dmd.declaration.STCdisable; - alias STCundefined = dmd.declaration.STCundefined; - alias STC_TYPECTOR = dmd.declaration.STC_TYPECTOR; - alias STCoverride = dmd.declaration.STCoverride; - alias STCabstract = dmd.declaration.STCabstract; - alias STCsynchronized = dmd.declaration.STCsynchronized; - alias STCdeprecated = dmd.declaration.STCdeprecated; - alias STCstatic = dmd.declaration.STCstatic; - alias STCextern = dmd.declaration.STCextern; - alias STCfuture = dmd.declaration.STCfuture; - alias STCalias = dmd.declaration.STCalias; - alias STClocal = dmd.declaration.STClocal; - + alias STC = dmd.declaration.STC; alias Dsymbol = dmd.dsymbol.Dsymbol; alias Dsymbols = dmd.dsymbol.Dsymbols; alias PROTprivate = dmd.dsymbol.PROTprivate; diff --git a/src/dmd/declaration.d b/src/dmd/declaration.d index b72026c6518d..5a85c947ea3d 100644 --- a/src/dmd/declaration.d +++ b/src/dmd/declaration.d @@ -186,62 +186,65 @@ extern (C++) void ObjectNotFound(Identifier id) fatal(); } -enum STCundefined = 0L; -enum STCstatic = (1L << 0); -enum STCextern = (1L << 1); -enum STCconst = (1L << 2); -enum STCfinal = (1L << 3); -enum STCabstract = (1L << 4); -enum STCparameter = (1L << 5); -enum STCfield = (1L << 6); -enum STCoverride = (1L << 7); -enum STCauto = (1L << 8); -enum STCsynchronized = (1L << 9); -enum STCdeprecated = (1L << 10); -enum STCin = (1L << 11); // in parameter -enum STCout = (1L << 12); // out parameter -enum STClazy = (1L << 13); // lazy parameter -enum STCforeach = (1L << 14); // variable for foreach loop -// (1L << 15) -enum STCvariadic = (1L << 16); // the 'variadic' parameter in: T foo(T a, U b, V variadic...) -enum STCctorinit = (1L << 17); // can only be set inside constructor -enum STCtemplateparameter = (1L << 18); // template parameter -enum STCscope = (1L << 19); -enum STCimmutable = (1L << 20); -enum STCref = (1L << 21); -enum STCinit = (1L << 22); // has explicit initializer -enum STCmanifest = (1L << 23); // manifest constant -enum STCnodtor = (1L << 24); // don't run destructor -enum STCnothrow = (1L << 25); // never throws exceptions -enum STCpure = (1L << 26); // pure function -enum STCtls = (1L << 27); // thread local -enum STCalias = (1L << 28); // alias parameter -enum STCshared = (1L << 29); // accessible from multiple threads -enum STCgshared = (1L << 30); // accessible from multiple threads, but not typed as "shared" -enum STCwild = (1L << 31); // for "wild" type constructor -enum STCproperty = (1L << 32); -enum STCsafe = (1L << 33); -enum STCtrusted = (1L << 34); -enum STCsystem = (1L << 35); -enum STCctfe = (1L << 36); // can be used in CTFE, even if it is static -enum STCdisable = (1L << 37); // for functions that are not callable -enum STCresult = (1L << 38); // for result variables passed to out contracts -enum STCnodefaultctor = (1L << 39); // must be set inside constructor -enum STCtemp = (1L << 40); // temporary variable -enum STCrvalue = (1L << 41); // force rvalue for variables -enum STCnogc = (1L << 42); // @nogc -enum STCvolatile = (1L << 43); // destined for volatile in the back end -enum STCreturn = (1L << 44); // 'return ref' or 'return scope' for function parameters -enum STCautoref = (1L << 45); // Mark for the already deduced 'auto ref' parameter -enum STCinference = (1L << 46); // do attribute inference -enum STCexptemp = (1L << 47); // temporary variable that has lifetime restricted to an expression -enum STCmaybescope = (1L << 48); // parameter might be 'scope' -enum STCscopeinferred = (1L << 49); // 'scope' has been inferred and should not be part of mangling -enum STCfuture = (1L << 50); // introducing new base class function -enum STClocal = (1L << 51); // do not forward (see dmd.dsymbol.ForwardingScopeDsymbol). - -enum STC_TYPECTOR = (STCconst | STCimmutable | STCshared | STCwild); -enum STC_FUNCATTR = (STCref | STCnothrow | STCnogc | STCpure | STCproperty | STCsafe | STCtrusted | STCsystem); +enum STC : long +{ + undefined_ = 0L, + static_ = (1L << 0), + extern_ = (1L << 1), + const_ = (1L << 2), + final_ = (1L << 3), + abstract_ = (1L << 4), + parameter = (1L << 5), + field = (1L << 6), + override_ = (1L << 7), + auto_ = (1L << 8), + synchronized_ = (1L << 9), + deprecated_ = (1L << 10), + in_ = (1L << 11), // in parameter + out_ = (1L << 12), // out parameter + lazy_ = (1L << 13), // lazy parameter + foreach_ = (1L << 14), // variable for foreach loop + //(1L << 15) + variadic = (1L << 16), // the 'variadic' parameter in: T foo(T a, U b, V variadic...) + ctorinit = (1L << 17), // can only be set inside constructor + templateparameter = (1L << 18), // template parameter + scope_ = (1L << 19), + immutable_ = (1L << 20), + ref_ = (1L << 21), + init = (1L << 22), // has explicit initializer + manifest = (1L << 23), // manifest constant + nodtor = (1L << 24), // don't run destructor + nothrow_ = (1L << 25), // never throws exceptions + pure_ = (1L << 26), // pure function + tls = (1L << 27), // thread local + alias_ = (1L << 28), // alias parameter + shared_ = (1L << 29), // accessible from multiple threads + gshared = (1L << 30), // accessible from multiple threads, but not typed as "shared" + wild = (1L << 31), // for "wild" type constructor + property = (1L << 32), + safe = (1L << 33), + trusted = (1L << 34), + system = (1L << 35), + ctfe = (1L << 36), // can be used in CTFE, even if it is static + disable = (1L << 37), // for functions that are not callable + result = (1L << 38), // for result variables passed to out contracts + nodefaultctor = (1L << 39), // must be set inside constructor + temp = (1L << 40), // temporary variable + rvalue = (1L << 41), // force rvalue for variables + nogc = (1L << 42), // @nogc + volatile_ = (1L << 43), // destined for volatile in the back end + return_ = (1L << 44), // 'return ref' or 'return scope' for function parameters + autoref = (1L << 45), // Mark for the already deduced 'auto ref' parameter + inference = (1L << 46), // do attribute inference + exptemp = (1L << 47), // temporary variable that has lifetime restricted to an expression + maybescope = (1L << 48), // parameter might be 'scope' + scopeinferred = (1L << 49), // 'scope' has been inferred and should not be part of mangling + future = (1L << 50), // introducing new base class function + local = (1L << 51), // do not forward (see dmd.dsymbol.ForwardingScopeDsymbol). + + TYPECTOR = (STC.const_ | STC.immutable_ | STC.shared_ | STC.wild), + FUNCATTR = (STC.ref_ | STC.nothrow_ | STC.nogc | STC.pure_ | STC.property | STC.safe | STC.trusted | STC.system), +} extern (C++) __gshared const(StorageClass) STCStorageClass = (STCauto | STCscope | STCstatic | STCextern | STCconst | STCfinal | STCabstract | STCsynchronized | From 651829adcc95c0a97e2d7a85ae9442fb162df831 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Mon, 8 Jan 2018 04:42:45 +0100 Subject: [PATCH 2/2] Replace STCxxx with STC enum ``` replacements=( "STCautoref autoref" "STCinference inference" "STCinit init" "STCscopeinferred scopeinferred" "STCundefined undefined_" "STCstatic static_" "STCextern extern_" "STCconst const_" "STCfinal final_" "STCabstract abstract_" "STCparameter parameter" "STCfield field" "STCoverride override_" "STCauto auto_" "STCsynchronized synchronized_" "STCdeprecated deprecated_" "STCin in_" "STCout out_" "STClazy lazy_" "STCforeach foreach_" "STCvariadic variadic" "STCctorinit ctorinit" "STCtemplateparameter templateparameter" "STCscope scope_" "STCimmutable immutable_" "STCref ref_" "STCmanifest manifest" "STCnodtor nodtor" "STCnothrow nothrow_" "STCpure pure_" "STCtls tls" "STCalias alias_" "STCshared shared_" "STCgshared gshared" "STCwild wild" "STCproperty property" "STCsafe safe" "STCtrusted trusted" "STCsystem system" "STCctfe ctfe" "STCdisable disable" "STCresult result" "STCnodefaultctor nodefaultctor" "STCtemp temp" "STCrvalue rvalue" "STCnogc nogc" "STCvolatile volatile_" "STCreturn return_" "STCexptemp exptemp" "STCmaybescope maybescope" "STCfuture future" "STClocal local" "STC_TYPECTOR TYPECTOR" "STC_FUNCATTR FUNCATTR" ) for r in "${replacements[@]}" ; do w=($r) sed "s/${w[0]}/STC.${w[1]}/g" -i **/*.d done ``` --- src/dmd/aggregate.d | 16 +-- src/dmd/astbase.d | 122 ++++++++-------- src/dmd/attrib.d | 32 ++--- src/dmd/blockexit.d | 4 +- src/dmd/canthrow.d | 4 +- src/dmd/clone.d | 166 ++++++++++----------- src/dmd/cond.d | 2 +- src/dmd/cppmangle.d | 6 +- src/dmd/cppmanglewin.d | 8 +- src/dmd/dcast.d | 10 +- src/dmd/dclass.d | 6 +- src/dmd/declaration.d | 100 ++++++------- src/dmd/delegatize.d | 2 +- src/dmd/dinterpret.d | 44 +++--- src/dmd/dmangle.d | 16 +-- src/dmd/doc.d | 6 +- src/dmd/dscope.d | 2 +- src/dmd/dstruct.d | 2 +- src/dmd/dsymbol.d | 22 +-- src/dmd/dsymbolsem.d | 226 ++++++++++++++--------------- src/dmd/dtemplate.d | 74 +++++----- src/dmd/e2ir.d | 20 +-- src/dmd/escape.d | 104 +++++++------- src/dmd/expression.d | 46 +++--- src/dmd/expressionsem.d | 68 ++++----- src/dmd/func.d | 92 ++++++------ src/dmd/hdrgen.d | 118 +++++++-------- src/dmd/iasm.d | 6 +- src/dmd/inline.d | 22 +-- src/dmd/json.d | 4 +- src/dmd/mtype.d | 166 ++++++++++----------- src/dmd/nogc.d | 2 +- src/dmd/opover.d | 2 +- src/dmd/optimize.d | 18 +-- src/dmd/parse.d | 312 ++++++++++++++++++++-------------------- src/dmd/semantic2.d | 2 +- src/dmd/semantic3.d | 64 ++++----- src/dmd/sideeffect.d | 12 +- src/dmd/statement.d | 8 +- src/dmd/statementsem.d | 138 +++++++++--------- src/dmd/tocsym.d | 10 +- src/dmd/toctype.d | 4 +- src/dmd/todt.d | 2 +- src/dmd/toir.d | 14 +- src/dmd/toobj.d | 4 +- src/dmd/traits.d | 32 ++--- src/dmd/typesem.d | 78 +++++----- 47 files changed, 1109 insertions(+), 1109 deletions(-) diff --git a/src/dmd/aggregate.d b/src/dmd/aggregate.d index b73eeb484dd5..2b07b3ce57a7 100644 --- a/src/dmd/aggregate.d +++ b/src/dmd/aggregate.d @@ -120,7 +120,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol Scope* newScope(Scope* sc) { auto sc2 = sc.push(this); - sc2.stc &= STCsafe | STCtrusted | STCsystem; + sc2.stc &= STC.safe | STC.trusted | STC.system; sc2.parent = this; if (isUnionDeclaration()) sc2.inunion = 1; @@ -166,7 +166,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol auto v = s.isVarDeclaration(); if (!v) return 0; - if (v.storage_class & STCmanifest) + if (v.storage_class & STC.manifest) return 0; auto ad = cast(AggregateDeclaration)param; @@ -180,14 +180,14 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol if (v.aliassym) return 0; // If this variable was really a tuple, skip it. - if (v.storage_class & (STCstatic | STCextern | STCtls | STCgshared | STCmanifest | STCctfe | STCtemplateparameter)) + if (v.storage_class & (STC.static_ | STC.extern_ | STC.tls | STC.gshared | STC.manifest | STC.ctfe | STC.templateparameter)) return 0; if (!v.isField() || v.semanticRun < PASSsemanticdone) return 1; // unresolvable forward reference ad.fields.push(v); - if (v.storage_class & STCref) + if (v.storage_class & STC.ref_) return 0; auto tv = v.type.baseElemOf(); if (tv.ty != Tstruct) @@ -472,7 +472,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol } else { - if ((vx.storage_class & STCnodefaultctor) && !ctorinit) + if ((vx.storage_class & STC.nodefaultctor) && !ctorinit) { .error(loc, "field `%s.%s` must be initialized because it has no default constructor", type.toChars(), vx.toChars()); @@ -614,7 +614,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol return; if (isUnionDeclaration() || isInterfaceDeclaration()) return; - if (storage_class & STCstatic) + if (storage_class & STC.static_) return; // If nested struct, add in hidden 'this' pointer to outer scope @@ -656,13 +656,13 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol assert(!vthis); vthis = new ThisDeclaration(loc, t); - //vthis.storage_class |= STCref; + //vthis.storage_class |= STC.ref_; // Emulate vthis.addMember() members.push(vthis); // Emulate vthis.dsymbolSemantic() - vthis.storage_class |= STCfield; + vthis.storage_class |= STC.field; vthis.parent = this; vthis.protection = Prot(PROTpublic); vthis.alignment = t.alignment(); diff --git a/src/dmd/astbase.d b/src/dmd/astbase.d index 5cc8ccdc9dc0..45ba9ad13d92 100644 --- a/src/dmd/astbase.d +++ b/src/dmd/astbase.d @@ -168,7 +168,7 @@ struct ASTBase } extern (C++) __gshared const(StorageClass) STCStorageClass = - (STCauto | STCscope | STCstatic | STCextern | STCconst | STCfinal | STCabstract | STCsynchronized | STCdeprecated | STCoverride | STClazy | STCalias | STCout | STCin | STCmanifest | STCimmutable | STCshared | STCwild | STCnothrow | STCnogc | STCpure | STCref | STCreturn | STCtls | STCgshared | STCproperty | STCsafe | STCtrusted | STCsystem | STCdisable); + (STC.auto_ | STC.scope_ | STC.static_ | STC.extern_ | STC.const_ | STC.final_ | STC.abstract_ | STC.synchronized_ | STC.deprecated_ | STC.override_ | STC.lazy_ | STC.alias_ | STC.out_ | STC.in_ | STC.manifest | STC.immutable_ | STC.shared_ | STC.wild | STC.nothrow_ | STC.nogc | STC.pure_ | STC.ref_ | STC.return_ | STC.tls | STC.gshared | STC.property | STC.safe | STC.trusted | STC.system | STC.disable); enum ENUMTY : int { @@ -540,7 +540,7 @@ struct ASTBase final extern (D) this(Identifier id) { super(id); - storage_class = STCundefined; + storage_class = STC.undefined_; protection = Prot(PROTundefined); linkage = LINKdefault; } @@ -710,7 +710,7 @@ struct ASTBase uint sequenceNumber; __gshared uint nextSequenceNumber; - final extern (D) this(Loc loc, Type type, Identifier id, Initializer _init, StorageClass st = STCundefined) + final extern (D) this(Loc loc, Type type, Identifier id, Initializer _init, StorageClass st = STC.undefined_) { super(id); this.type = type; @@ -754,7 +754,7 @@ struct ASTBase { // Normalize storage_class, because function-type related attributes // are already set in the 'type' in parsing phase. - this.storage_class &= ~(STC_TYPECTOR | STC_FUNCATTR); + this.storage_class &= ~(STC.TYPECTOR | STC.FUNCATTR); } this.loc = loc; this.endloc = endloc; @@ -836,7 +836,7 @@ struct ASTBase extern (D) this(Loc loc, Loc endloc, Type type, TOK tok, ForeachStatement fes, Identifier id = null) { - super(loc, endloc, null, STCundefined, type); + super(loc, endloc, null, STC.undefined_, type); this.ident = id ? id : Id.empty; this.tok = tok; this.fes = fes; @@ -883,7 +883,7 @@ struct ASTBase { extern (D) this(Loc loc, Loc endloc) { - super(loc, endloc, Id.dtor, STCundefined, null); + super(loc, endloc, Id.dtor, STC.undefined_, null); } extern (D) this(Loc loc, Loc endloc, StorageClass stc, Identifier id) { @@ -935,7 +935,7 @@ struct ASTBase extern (D) this(Loc loc, Loc endloc, StorageClass stc, Parameters* fparams, int varargs) { - super(loc, endloc, Id.classNew, STCstatic | stc, null); + super(loc, endloc, Id.classNew, STC.static_ | stc, null); this.parameters = fparams; this.varargs = varargs; } @@ -952,7 +952,7 @@ struct ASTBase extern (D) this(Loc loc, Loc endloc, StorageClass stc, Parameters* fparams) { - super(loc, endloc, Id.classDelete, STCstatic | stc, null); + super(loc, endloc, Id.classDelete, STC.static_ | stc, null); this.parameters = fparams; } @@ -966,11 +966,11 @@ struct ASTBase { final extern (D) this(Loc loc, Loc endloc, StorageClass stc) { - super(loc, endloc, Identifier.generateId("_staticCtor"), STCstatic | stc, null); + super(loc, endloc, Identifier.generateId("_staticCtor"), STC.static_ | stc, null); } final extern (D) this(Loc loc, Loc endloc, const(char)* name, StorageClass stc) { - super(loc, endloc, Identifier.generateId(name), STCstatic | stc, null); + super(loc, endloc, Identifier.generateId(name), STC.static_ | stc, null); } override void accept(Visitor v) @@ -983,11 +983,11 @@ struct ASTBase { final extern (D) this()(Loc loc, Loc endloc, StorageClass stc) { - super(loc, endloc, Identifier.generateId("__staticDtor"), STCstatic | stc, null); + super(loc, endloc, Identifier.generateId("__staticDtor"), STC.static_ | stc, null); } final extern (D) this(Loc loc, Loc endloc, const(char)* name, StorageClass stc) { - super(loc, endloc, Identifier.generateId(name), STCstatic | stc, null); + super(loc, endloc, Identifier.generateId(name), STC.static_ | stc, null); } override void accept(Visitor v) @@ -1425,7 +1425,7 @@ struct ASTBase extern (D) this(Expression msg, Dsymbols* decl) { - super(STCdeprecated, decl); + super(STC.deprecated_, decl); this.msg = msg; } @@ -2966,13 +2966,13 @@ struct ASTBase if (t.isImmutable()) { } - else if (stc & STCimmutable) + else if (stc & STC.immutable_) { t = t.makeImmutable(); } else { - if ((stc & STCshared) && !t.isShared()) + if ((stc & STC.shared_) && !t.isShared()) { if (t.isWild()) { @@ -2989,7 +2989,7 @@ struct ASTBase t = t.makeShared(); } } - if ((stc & STCconst) && !t.isConst()) + if ((stc & STC.const_) && !t.isConst()) { if (t.isShared()) { @@ -3006,7 +3006,7 @@ struct ASTBase t = t.makeConst(); } } - if ((stc & STCwild) && !t.isWild()) + if ((stc & STC.wild) && !t.isWild()) { if (t.isShared()) { @@ -3669,7 +3669,7 @@ struct ASTBase Expression e = (*exps)[i]; if (e.type.ty == Ttuple) e.error("cannot form tuple of tuples"); - auto arg = new Parameter(STCundefined, e.type, null, null); + auto arg = new Parameter(STC.undefined_, e.type, null, null); (*arguments)[i] = arg; } } @@ -3886,28 +3886,28 @@ struct ASTBase this.varargs = varargs; this.linkage = linkage; - if (stc & STCpure) + if (stc & STC.pure_) this.purity = PUREfwdref; - if (stc & STCnothrow) + if (stc & STC.nothrow_) this.isnothrow = true; - if (stc & STCnogc) + if (stc & STC.nogc) this.isnogc = true; - if (stc & STCproperty) + if (stc & STC.property) this.isproperty = true; - if (stc & STCref) + if (stc & STC.ref_) this.isref = true; - if (stc & STCreturn) + if (stc & STC.return_) this.isreturn = true; - if (stc & STCscope) + if (stc & STC.scope_) this.isscope = true; this.trust = TRUSTdefault; - if (stc & STCsafe) + if (stc & STC.safe) this.trust = TRUSTsafe; - if (stc & STCsystem) + if (stc & STC.system) this.trust = TRUSTsystem; - if (stc & STCtrusted) + if (stc & STC.trusted) this.trust = TRUSTtrusted; } @@ -6236,8 +6236,8 @@ struct ASTBase extern (C++) static bool stcToBuffer(OutBuffer* buf, StorageClass stc) { bool result = false; - if ((stc & (STCreturn | STCscope)) == (STCreturn | STCscope)) - stc &= ~STCscope; + if ((stc & (STC.return_ | STC.scope_)) == (STC.return_ | STC.scope_)) + stc &= ~STC.scope_; while (stc) { const(char)* p = stcToChars(stc); @@ -6273,36 +6273,36 @@ struct ASTBase static __gshared SCstring* table = [ - SCstring(STCauto, TOKauto), - SCstring(STCscope, TOKscope), - SCstring(STCstatic, TOKstatic), - SCstring(STCextern, TOKextern), - SCstring(STCconst, TOKconst), - SCstring(STCfinal, TOKfinal), - SCstring(STCabstract, TOKabstract), - SCstring(STCsynchronized, TOKsynchronized), - SCstring(STCdeprecated, TOKdeprecated), - SCstring(STCoverride, TOKoverride), - SCstring(STClazy, TOKlazy), - SCstring(STCalias, TOKalias), - SCstring(STCout, TOKout), - SCstring(STCin, TOKin), - SCstring(STCmanifest, TOKenum), - SCstring(STCimmutable, TOKimmutable), - SCstring(STCshared, TOKshared), - SCstring(STCnothrow, TOKnothrow), - SCstring(STCwild, TOKwild), - SCstring(STCpure, TOKpure), - SCstring(STCref, TOKref), - SCstring(STCtls), - SCstring(STCgshared, TOKgshared), - SCstring(STCnogc, TOKat, "@nogc"), - SCstring(STCproperty, TOKat, "@property"), - SCstring(STCsafe, TOKat, "@safe"), - SCstring(STCtrusted, TOKat, "@trusted"), - SCstring(STCsystem, TOKat, "@system"), - SCstring(STCdisable, TOKat, "@disable"), - SCstring(STCfuture, TOKat, "@__future"), + SCstring(STC.auto_, TOKauto), + SCstring(STC.scope_, TOKscope), + SCstring(STC.static_, TOKstatic), + SCstring(STC.extern_, TOKextern), + SCstring(STC.const_, TOKconst), + SCstring(STC.final_, TOKfinal), + SCstring(STC.abstract_, TOKabstract), + SCstring(STC.synchronized_, TOKsynchronized), + SCstring(STC.deprecated_, TOKdeprecated), + SCstring(STC.override_, TOKoverride), + SCstring(STC.lazy_, TOKlazy), + SCstring(STC.alias_, TOKalias), + SCstring(STC.out_, TOKout), + SCstring(STC.in_, TOKin), + SCstring(STC.manifest, TOKenum), + SCstring(STC.immutable_, TOKimmutable), + SCstring(STC.shared_, TOKshared), + SCstring(STC.nothrow_, TOKnothrow), + SCstring(STC.wild, TOKwild), + SCstring(STC.pure_, TOKpure), + SCstring(STC.ref_, TOKref), + SCstring(STC.tls), + SCstring(STC.gshared, TOKgshared), + SCstring(STC.nogc, TOKat, "@nogc"), + SCstring(STC.property, TOKat, "@property"), + SCstring(STC.safe, TOKat, "@safe"), + SCstring(STC.trusted, TOKat, "@trusted"), + SCstring(STC.system, TOKat, "@system"), + SCstring(STC.disable, TOKat, "@disable"), + SCstring(STC.future, TOKat, "@__future"), SCstring(0, TOKreserved) ]; for (int i = 0; table[i].stc; i++) @@ -6312,7 +6312,7 @@ struct ASTBase if (stc & tbl) { stc &= ~tbl; - if (tbl == STCtls) // TOKtls was removed + if (tbl == STC.tls) // TOKtls was removed return "__thread"; TOK tok = table[i].tok; if (tok == TOKat) diff --git a/src/dmd/attrib.d b/src/dmd/attrib.d index 5c973ae3633f..436dbd45beb5 100644 --- a/src/dmd/attrib.d +++ b/src/dmd/attrib.d @@ -296,16 +296,16 @@ extern (C++) class StorageClassDeclaration : AttribDeclaration /* These sets of storage classes are mutually exclusive, * so choose the innermost or most recent one. */ - if (stc & (STCauto | STCscope | STCstatic | STCextern | STCmanifest)) - scstc &= ~(STCauto | STCscope | STCstatic | STCextern | STCmanifest); - if (stc & (STCauto | STCscope | STCstatic | STCtls | STCmanifest | STCgshared)) - scstc &= ~(STCauto | STCscope | STCstatic | STCtls | STCmanifest | STCgshared); - if (stc & (STCconst | STCimmutable | STCmanifest)) - scstc &= ~(STCconst | STCimmutable | STCmanifest); - if (stc & (STCgshared | STCshared | STCtls)) - scstc &= ~(STCgshared | STCshared | STCtls); - if (stc & (STCsafe | STCtrusted | STCsystem)) - scstc &= ~(STCsafe | STCtrusted | STCsystem); + if (stc & (STC.auto_ | STC.scope_ | STC.static_ | STC.extern_ | STC.manifest)) + scstc &= ~(STC.auto_ | STC.scope_ | STC.static_ | STC.extern_ | STC.manifest); + if (stc & (STC.auto_ | STC.scope_ | STC.static_ | STC.tls | STC.manifest | STC.gshared)) + scstc &= ~(STC.auto_ | STC.scope_ | STC.static_ | STC.tls | STC.manifest | STC.gshared); + if (stc & (STC.const_ | STC.immutable_ | STC.manifest)) + scstc &= ~(STC.const_ | STC.immutable_ | STC.manifest); + if (stc & (STC.gshared | STC.shared_ | STC.tls)) + scstc &= ~(STC.gshared | STC.shared_ | STC.tls); + if (stc & (STC.safe | STC.trusted | STC.system)) + scstc &= ~(STC.safe | STC.trusted | STC.system); scstc |= stc; //printf("scstc = x%llx\n", scstc); return createNewScope(sc, scstc, sc.linkage, sc.cppmangle, @@ -349,13 +349,13 @@ extern (C++) class StorageClassDeclaration : AttribDeclaration { Dsymbol s = (*d)[i]; //printf("\taddMember %s to %s\n", s.toChars(), sds.toChars()); - // STClocal needs to be attached before the member is added to the scope (because it influences the parent symbol) + // STC.local needs to be attached before the member is added to the scope (because it influences the parent symbol) if (auto decl = s.isDeclaration()) { - decl.storage_class |= stc & STClocal; + decl.storage_class |= stc & STC.local; if (auto sdecl = s.isStorageClassDeclaration()) // TODO: why is this not enough to deal with the nested case? { - sdecl.stc |= stc & STClocal; + sdecl.stc |= stc & STC.local; } } s.addMember(sc2, sds); @@ -386,7 +386,7 @@ extern (C++) final class DeprecatedDeclaration : StorageClassDeclaration extern (D) this(Expression msg, Dsymbols* decl) { - super(STCdeprecated, decl); + super(STC.deprecated_, decl); this.msg = msg; } @@ -397,7 +397,7 @@ extern (C++) final class DeprecatedDeclaration : StorageClassDeclaration } /** - * Provides a new scope with `STCdeprecated` and `Scope.depdecl` set + * Provides a new scope with `STC.deprecated_` and `Scope.depdecl` set * * Calls `StorageClassDeclaration.newScope` (as it must be called or copied * in any function overriding `newScope`), then set the `Scope`'s depdecl. @@ -1142,7 +1142,7 @@ extern (C++) final class StaticForeachDeclaration : AttribDeclaration * another scope, like: * * static foreach (i; 0 .. 10) // loop variables for different indices do not conflict. - * { // this body is expanded into 10 ForwardingAttribDeclarations, where `i` has storage class STClocal + * { // this body is expanded into 10 ForwardingAttribDeclarations, where `i` has storage class STC.local * mixin("enum x" ~ to!string(i) ~ " = i"); // ok, can access current loop variable * } * diff --git a/src/dmd/blockexit.d b/src/dmd/blockexit.d index ec16f21246c6..5357471118ff 100644 --- a/src/dmd/blockexit.d +++ b/src/dmd/blockexit.d @@ -510,9 +510,9 @@ int blockExit(Statement s, FuncDeclaration func, bool mustNotThrow) { // Assume the worst result = BE.fallthru | BE.return_ | BE.goto_ | BE.halt; - if (!(s.stc & STCnothrow)) + if (!(s.stc & STC.nothrow_)) { - if (mustNotThrow && !(s.stc & STCnothrow)) + if (mustNotThrow && !(s.stc & STC.nothrow_)) s.deprecation("asm statement is assumed to throw - mark it with `nothrow` if it does not"); else result |= BE.throw_; diff --git a/src/dmd/canthrow.d b/src/dmd/canthrow.d index 9b37538062b6..5c9ddf7272c6 100644 --- a/src/dmd/canthrow.d +++ b/src/dmd/canthrow.d @@ -260,10 +260,10 @@ private bool Dsymbol_canThrow(Dsymbol s, FuncDeclaration func, bool mustNotThrow s = s.toAlias(); if (s != vd) return Dsymbol_canThrow(s, func, mustNotThrow); - if (vd.storage_class & STCmanifest) + if (vd.storage_class & STC.manifest) { } - else if (vd.isStatic() || vd.storage_class & (STCextern | STCtls | STCgshared)) + else if (vd.isStatic() || vd.storage_class & (STC.extern_ | STC.tls | STC.gshared)) { } else diff --git a/src/dmd/clone.d b/src/dmd/clone.d index db1509081377..011fb9cf57d4 100644 --- a/src/dmd/clone.d +++ b/src/dmd/clone.d @@ -42,39 +42,39 @@ extern (C++) StorageClass mergeFuncAttrs(StorageClass s1, FuncDeclaration f) { if (!f) return s1; - StorageClass s2 = (f.storage_class & STCdisable); + StorageClass s2 = (f.storage_class & STC.disable); TypeFunction tf = cast(TypeFunction)f.type; if (tf.trust == TRUSTsafe) - s2 |= STCsafe; + s2 |= STC.safe; else if (tf.trust == TRUSTsystem) - s2 |= STCsystem; + s2 |= STC.system; else if (tf.trust == TRUSTtrusted) - s2 |= STCtrusted; + s2 |= STC.trusted; if (tf.purity != PUREimpure) - s2 |= STCpure; + s2 |= STC.pure_; if (tf.isnothrow) - s2 |= STCnothrow; + s2 |= STC.nothrow_; if (tf.isnogc) - s2 |= STCnogc; + s2 |= STC.nogc; StorageClass stc = 0; StorageClass sa = s1 & s2; StorageClass so = s1 | s2; - if (so & STCsystem) - stc |= STCsystem; - else if (sa & STCtrusted) - stc |= STCtrusted; - else if ((so & (STCtrusted | STCsafe)) == (STCtrusted | STCsafe)) - stc |= STCtrusted; - else if (sa & STCsafe) - stc |= STCsafe; - if (sa & STCpure) - stc |= STCpure; - if (sa & STCnothrow) - stc |= STCnothrow; - if (sa & STCnogc) - stc |= STCnogc; - if (so & STCdisable) - stc |= STCdisable; + if (so & STC.system) + stc |= STC.system; + else if (sa & STC.trusted) + stc |= STC.trusted; + else if ((so & (STC.trusted | STC.safe)) == (STC.trusted | STC.safe)) + stc |= STC.trusted; + else if (sa & STC.safe) + stc |= STC.safe; + if (sa & STC.pure_) + stc |= STC.pure_; + if (sa & STC.nothrow_) + stc |= STC.nothrow_; + if (sa & STC.nogc) + stc |= STC.nogc; + if (so & STC.disable) + stc |= STC.disable; return stc; } @@ -155,7 +155,7 @@ private bool needOpAssign(StructDeclaration sd) for (size_t i = 0; i < sd.fields.dim; i++) { VarDeclaration v = sd.fields[i]; - if (v.storage_class & STCref) + if (v.storage_class & STC.ref_) continue; if (v.overlapped) // if field of a union continue; // user must handle it themselves @@ -209,18 +209,18 @@ extern (C++) FuncDeclaration buildOpAssign(StructDeclaration sd, Scope* sc) return null; //printf("StructDeclaration::buildOpAssign() %s\n", sd.toChars()); - StorageClass stc = STCsafe | STCnothrow | STCpure | STCnogc; + StorageClass stc = STC.safe | STC.nothrow_ | STC.pure_ | STC.nogc; Loc declLoc = sd.loc; Loc loc = Loc(); // internal code should have no loc to prevent coverage // One of our sub-field might have `@disable opAssign` so we need to // check for it. // In this event, it will be reflected by having `stc` (opAssign's - // storage class) include `STCdisabled`. + // storage class) include `STC.disabled`. for (size_t i = 0; i < sd.fields.dim; i++) { VarDeclaration v = sd.fields[i]; - if (v.storage_class & STCref) + if (v.storage_class & STC.ref_) continue; if (v.overlapped) continue; @@ -236,18 +236,18 @@ extern (C++) FuncDeclaration buildOpAssign(StructDeclaration sd, Scope* sc) if (!sd.type.isAssignable()) // https://issues.dlang.org/show_bug.cgi?id=13044 return null; stc = mergeFuncAttrs(stc, sd.dtor); - if (stc & STCsafe) - stc = (stc & ~STCsafe) | STCtrusted; + if (stc & STC.safe) + stc = (stc & ~STC.safe) | STC.trusted; } auto fparams = new Parameters(); - fparams.push(new Parameter(STCnodtor, sd.type, Id.p, null)); - auto tf = new TypeFunction(fparams, sd.handleType(), 0, LINKd, stc | STCref); + fparams.push(new Parameter(STC.nodtor, sd.type, Id.p, null)); + auto tf = new TypeFunction(fparams, sd.handleType(), 0, LINKd, stc | STC.ref_); auto fop = new FuncDeclaration(declLoc, Loc(), Id.assign, stc, tf); - fop.storage_class |= STCinference; + fop.storage_class |= STC.inference; fop.generated = true; Expression e = null; - if (stc & STCdisable) + if (stc & STC.disable) { } else if (sd.dtor || sd.postblit) @@ -262,7 +262,7 @@ extern (C++) FuncDeclaration buildOpAssign(StructDeclaration sd, Scope* sc) if (sd.dtor) { tmp = new VarDeclaration(loc, sd.type, idtmp, new VoidInitializer(loc)); - tmp.storage_class |= STCnodtor | STCtemp | STCctfe; + tmp.storage_class |= STC.nodtor | STC.temp | STC.ctfe; e = new DeclarationExp(loc, tmp); ec = new BlitExp(loc, new VarExp(loc, tmp), new ThisExp(loc)); e = Expression.combine(e, ec); @@ -326,11 +326,11 @@ extern (C++) FuncDeclaration buildOpAssign(StructDeclaration sd, Scope* sc) if (global.endGagging(errors)) // if errors happened { // Disable generated opAssign, because some members forbid identity assignment. - fop.storage_class |= STCdisable; + fop.storage_class |= STC.disable; fop.fbody = null; // remove fbody which contains the error } - //printf("-StructDeclaration::buildOpAssign() %s, errors = %d\n", sd.toChars(), (fop.storage_class & STCdisable) != 0); + //printf("-StructDeclaration::buildOpAssign() %s, errors = %d\n", sd.toChars(), (fop.storage_class & STC.disable) != 0); return fop; } @@ -352,7 +352,7 @@ extern (C++) bool needOpEquals(StructDeclaration sd) for (size_t i = 0; i < sd.fields.dim; i++) { VarDeclaration v = sd.fields[i]; - if (v.storage_class & STCref) + if (v.storage_class & STC.ref_) continue; if (v.overlapped) continue; @@ -486,7 +486,7 @@ extern (C++) FuncDeclaration buildXopEquals(StructDeclaration sd, Scope* sc) /* const bool opEquals(ref const S s); */ auto parameters = new Parameters(); - parameters.push(new Parameter(STCref | STCconst, sd.type, null, null)); + parameters.push(new Parameter(STC.ref_ | STC.const_, sd.type, null, null)); tfeqptr = new TypeFunction(parameters, Type.tbool, 0, LINKd); tfeqptr.mod = MODconst; tfeqptr = cast(TypeFunction)tfeqptr.typeSemantic(Loc(), &scx); @@ -511,11 +511,11 @@ extern (C++) FuncDeclaration buildXopEquals(StructDeclaration sd, Scope* sc) Loc declLoc = Loc(); // loc is unnecessary so __xopEquals is never called directly Loc loc = Loc(); // loc is unnecessary so errors are gagged auto parameters = new Parameters(); - parameters.push(new Parameter(STCref | STCconst, sd.type, Id.p, null)); - parameters.push(new Parameter(STCref | STCconst, sd.type, Id.q, null)); + parameters.push(new Parameter(STC.ref_ | STC.const_, sd.type, Id.p, null)); + parameters.push(new Parameter(STC.ref_ | STC.const_, sd.type, Id.q, null)); auto tf = new TypeFunction(parameters, Type.tbool, 0, LINKd); Identifier id = Id.xopEquals; - auto fop = new FuncDeclaration(declLoc, Loc(), id, STCstatic, tf); + auto fop = new FuncDeclaration(declLoc, Loc(), id, STC.static_, tf); fop.generated = true; Expression e1 = new IdentifierExp(loc, Id.p); Expression e2 = new IdentifierExp(loc, Id.q); @@ -556,7 +556,7 @@ extern (C++) FuncDeclaration buildXopCmp(StructDeclaration sd, Scope* sc) /* const int opCmp(ref const S s); */ auto parameters = new Parameters(); - parameters.push(new Parameter(STCref | STCconst, sd.type, null, null)); + parameters.push(new Parameter(STC.ref_ | STC.const_, sd.type, null, null)); tfcmpptr = new TypeFunction(parameters, Type.tint32, 0, LINKd); tfcmpptr.mod = MODconst; tfcmpptr = cast(TypeFunction)tfcmpptr.typeSemantic(Loc(), &scx); @@ -631,11 +631,11 @@ extern (C++) FuncDeclaration buildXopCmp(StructDeclaration sd, Scope* sc) Loc declLoc = Loc(); // loc is unnecessary so __xopCmp is never called directly Loc loc = Loc(); // loc is unnecessary so errors are gagged auto parameters = new Parameters(); - parameters.push(new Parameter(STCref | STCconst, sd.type, Id.p, null)); - parameters.push(new Parameter(STCref | STCconst, sd.type, Id.q, null)); + parameters.push(new Parameter(STC.ref_ | STC.const_, sd.type, Id.p, null)); + parameters.push(new Parameter(STC.ref_ | STC.const_, sd.type, Id.q, null)); auto tf = new TypeFunction(parameters, Type.tint32, 0, LINKd); Identifier id = Id.xopCmp; - auto fop = new FuncDeclaration(declLoc, Loc(), id, STCstatic, tf); + auto fop = new FuncDeclaration(declLoc, Loc(), id, STC.static_, tf); fop.generated = true; Expression e1 = new IdentifierExp(loc, Id.p); Expression e2 = new IdentifierExp(loc, Id.q); @@ -672,7 +672,7 @@ private bool needToHash(StructDeclaration sd) for (size_t i = 0; i < sd.fields.dim; i++) { VarDeclaration v = sd.fields[i]; - if (v.storage_class & STCref) + if (v.storage_class & STC.ref_) continue; if (v.overlapped) continue; @@ -739,10 +739,10 @@ extern (C++) FuncDeclaration buildXtoHash(StructDeclaration sd, Scope* sc) Loc declLoc = Loc(); // loc is unnecessary so __xtoHash is never called directly Loc loc = Loc(); // internal code should have no loc to prevent coverage auto parameters = new Parameters(); - parameters.push(new Parameter(STCref | STCconst, sd.type, Id.p, null)); - auto tf = new TypeFunction(parameters, Type.thash_t, 0, LINKd, STCnothrow | STCtrusted); + parameters.push(new Parameter(STC.ref_ | STC.const_, sd.type, Id.p, null)); + auto tf = new TypeFunction(parameters, Type.thash_t, 0, LINKd, STC.nothrow_ | STC.trusted); Identifier id = Id.xtoHash; - auto fop = new FuncDeclaration(declLoc, Loc(), id, STCstatic, tf); + auto fop = new FuncDeclaration(declLoc, Loc(), id, STC.static_, tf); fop.generated = true; /* Do memberwise hashing. @@ -780,20 +780,20 @@ extern (C++) FuncDeclaration buildPostBlit(StructDeclaration sd, Scope* sc) if (sd.isUnionDeclaration()) return null; - StorageClass stc = STCsafe | STCnothrow | STCpure | STCnogc; + StorageClass stc = STC.safe | STC.nothrow_ | STC.pure_ | STC.nogc; Loc declLoc = sd.postblits.dim ? sd.postblits[0].loc : sd.loc; Loc loc = Loc(); // internal code should have no loc to prevent coverage for (size_t i = 0; i < sd.postblits.dim; i++) { - stc |= sd.postblits[i].storage_class & STCdisable; + stc |= sd.postblits[i].storage_class & STC.disable; } auto a = new Statements(); - for (size_t i = 0; i < sd.fields.dim && !(stc & STCdisable); i++) + for (size_t i = 0; i < sd.fields.dim && !(stc & STC.disable); i++) { auto v = sd.fields[i]; - if (v.storage_class & STCref) + if (v.storage_class & STC.ref_) continue; if (v.overlapped) continue; @@ -808,7 +808,7 @@ extern (C++) FuncDeclaration buildPostBlit(StructDeclaration sd, Scope* sc) stc = mergeFuncAttrs(stc, sdv.postblit); stc = mergeFuncAttrs(stc, sdv.dtor); - if (stc & STCdisable) + if (stc & STC.disable) { a.setDim(0); break; @@ -827,8 +827,8 @@ extern (C++) FuncDeclaration buildPostBlit(StructDeclaration sd, Scope* sc) ex = new AddrExp(loc, ex); ex = new CastExp(loc, ex, v.type.mutableOf().pointerTo()); ex = new PtrExp(loc, ex); - if (stc & STCsafe) - stc = (stc & ~STCsafe) | STCtrusted; + if (stc & STC.safe) + stc = (stc & ~STC.safe) | STC.trusted; ex = new DotVarExp(loc, ex, sdv.postblit, false); ex = new CallExp(loc, ex); @@ -852,8 +852,8 @@ extern (C++) FuncDeclaration buildPostBlit(StructDeclaration sd, Scope* sc) // This is a hack so we can call postblits on const/immutable objects. ex = new DotIdExp(loc, ex, Id.ptr); ex = new CastExp(loc, ex, sdv.type.pointerTo()); - if (stc & STCsafe) - stc = (stc & ~STCsafe) | STCtrusted; + if (stc & STC.safe) + stc = (stc & ~STC.safe) | STC.trusted; ex = new SliceExp(loc, ex, new IntegerExp(loc, 0, Type.tsize_t), new IntegerExp(loc, n, Type.tsize_t)); @@ -884,8 +884,8 @@ extern (C++) FuncDeclaration buildPostBlit(StructDeclaration sd, Scope* sc) ex = new AddrExp(loc, ex); ex = new CastExp(loc, ex, v.type.mutableOf().pointerTo()); ex = new PtrExp(loc, ex); - if (stc & STCsafe) - stc = (stc & ~STCsafe) | STCtrusted; + if (stc & STC.safe) + stc = (stc & ~STC.safe) | STC.trusted; ex = new DotVarExp(loc, ex, sdv.dtor, false); ex = new CallExp(loc, ex); @@ -909,8 +909,8 @@ extern (C++) FuncDeclaration buildPostBlit(StructDeclaration sd, Scope* sc) // This is a hack so we can call destructors on const/immutable objects. ex = new DotIdExp(loc, ex, Id.ptr); ex = new CastExp(loc, ex, sdv.type.pointerTo()); - if (stc & STCsafe) - stc = (stc & ~STCsafe) | STCtrusted; + if (stc & STC.safe) + stc = (stc & ~STC.safe) | STC.trusted; ex = new SliceExp(loc, ex, new IntegerExp(loc, 0, Type.tsize_t), new IntegerExp(loc, n, Type.tsize_t)); @@ -924,13 +924,13 @@ extern (C++) FuncDeclaration buildPostBlit(StructDeclaration sd, Scope* sc) } // Build our own "postblit" which executes a, but only if needed. - if (a.dim || (stc & STCdisable)) + if (a.dim || (stc & STC.disable)) { //printf("Building __fieldPostBlit()\n"); auto dd = new PostBlitDeclaration(declLoc, Loc(), stc, Id.__fieldPostblit); dd.generated = true; - dd.storage_class |= STCinference; - dd.fbody = (stc & STCdisable) ? null : new CompoundStatement(loc, a); + dd.storage_class |= STC.inference; + dd.fbody = (stc & STC.disable) ? null : new CompoundStatement(loc, a); sd.postblits.shift(dd); sd.members.push(dd); dd.dsymbolSemantic(sc); @@ -948,12 +948,12 @@ extern (C++) FuncDeclaration buildPostBlit(StructDeclaration sd, Scope* sc) default: Expression e = null; - stc = STCsafe | STCnothrow | STCpure | STCnogc; + stc = STC.safe | STC.nothrow_ | STC.pure_ | STC.nogc; for (size_t i = 0; i < sd.postblits.dim; i++) { auto fd = sd.postblits[i]; stc = mergeFuncAttrs(stc, fd); - if (stc & STCdisable) + if (stc & STC.disable) { e = null; break; @@ -965,7 +965,7 @@ extern (C++) FuncDeclaration buildPostBlit(StructDeclaration sd, Scope* sc) } auto dd = new PostBlitDeclaration(declLoc, Loc(), stc, Id.__aggrPostblit); dd.generated = true; - dd.storage_class |= STCinference; + dd.storage_class |= STC.inference; dd.fbody = new ExpStatement(loc, e); sd.members.push(dd); dd.dsymbolSemantic(sc); @@ -1003,7 +1003,7 @@ extern (C++) FuncDeclaration buildDtor(AggregateDeclaration ad, Scope* sc) if (ad.isUnionDeclaration()) return null; // unions don't have destructors - StorageClass stc = STCsafe | STCnothrow | STCpure | STCnogc; + StorageClass stc = STC.safe | STC.nothrow_ | STC.pure_ | STC.nogc; Loc declLoc = ad.dtors.dim ? ad.dtors[0].loc : ad.loc; Loc loc = Loc(); // internal code should have no loc to prevent coverage @@ -1011,7 +1011,7 @@ extern (C++) FuncDeclaration buildDtor(AggregateDeclaration ad, Scope* sc) for (size_t i = 0; i < ad.fields.dim; i++) { auto v = ad.fields[i]; - if (v.storage_class & STCref) + if (v.storage_class & STC.ref_) continue; if (v.overlapped) continue; @@ -1024,7 +1024,7 @@ extern (C++) FuncDeclaration buildDtor(AggregateDeclaration ad, Scope* sc) sdv.dtor.functionSemantic(); stc = mergeFuncAttrs(stc, sdv.dtor); - if (stc & STCdisable) + if (stc & STC.disable) { e = null; break; @@ -1042,8 +1042,8 @@ extern (C++) FuncDeclaration buildDtor(AggregateDeclaration ad, Scope* sc) // This is a hack so we can call destructors on const/immutable objects. // Do it as a type 'paint'. ex = new CastExp(loc, ex, v.type.mutableOf()); - if (stc & STCsafe) - stc = (stc & ~STCsafe) | STCtrusted; + if (stc & STC.safe) + stc = (stc & ~STC.safe) | STC.trusted; ex = new DotVarExp(loc, ex, sdv.dtor, false); ex = new CallExp(loc, ex); @@ -1067,8 +1067,8 @@ extern (C++) FuncDeclaration buildDtor(AggregateDeclaration ad, Scope* sc) // This is a hack so we can call destructors on const/immutable objects. ex = new DotIdExp(loc, ex, Id.ptr); ex = new CastExp(loc, ex, sdv.type.pointerTo()); - if (stc & STCsafe) - stc = (stc & ~STCsafe) | STCtrusted; + if (stc & STC.safe) + stc = (stc & ~STC.safe) | STC.trusted; ex = new SliceExp(loc, ex, new IntegerExp(loc, 0, Type.tsize_t), new IntegerExp(loc, n, Type.tsize_t)); @@ -1083,12 +1083,12 @@ extern (C++) FuncDeclaration buildDtor(AggregateDeclaration ad, Scope* sc) /* Build our own "destructor" which executes e */ - if (e || (stc & STCdisable)) + if (e || (stc & STC.disable)) { //printf("Building __fieldDtor(), %s\n", e.toChars()); auto dd = new DtorDeclaration(declLoc, Loc(), stc, Id.__fieldDtor); dd.generated = true; - dd.storage_class |= STCinference; + dd.storage_class |= STC.inference; dd.fbody = new ExpStatement(loc, e); ad.dtors.shift(dd); ad.members.push(dd); @@ -1107,12 +1107,12 @@ extern (C++) FuncDeclaration buildDtor(AggregateDeclaration ad, Scope* sc) default: e = null; - stc = STCsafe | STCnothrow | STCpure | STCnogc; + stc = STC.safe | STC.nothrow_ | STC.pure_ | STC.nogc; for (size_t i = 0; i < ad.dtors.dim; i++) { FuncDeclaration fd = ad.dtors[i]; stc = mergeFuncAttrs(stc, fd); - if (stc & STCdisable) + if (stc & STC.disable) { e = null; break; @@ -1124,7 +1124,7 @@ extern (C++) FuncDeclaration buildDtor(AggregateDeclaration ad, Scope* sc) } auto dd = new DtorDeclaration(declLoc, Loc(), stc, Id.__aggrDtor); dd.generated = true; - dd.storage_class |= STCinference; + dd.storage_class |= STC.inference; dd.fbody = new ExpStatement(loc, e); ad.members.push(dd); dd.dsymbolSemantic(sc); @@ -1154,7 +1154,7 @@ extern (C++) FuncDeclaration buildDtor(AggregateDeclaration ad, Scope* sc) */ extern (C++) FuncDeclaration buildInv(AggregateDeclaration ad, Scope* sc) { - StorageClass stc = STCsafe | STCnothrow | STCpure | STCnogc; + StorageClass stc = STC.safe | STC.nothrow_ | STC.pure_ | STC.nogc; Loc declLoc = ad.loc; Loc loc = Loc(); // internal code should have no loc to prevent coverage switch (ad.invs.dim) @@ -1170,11 +1170,11 @@ extern (C++) FuncDeclaration buildInv(AggregateDeclaration ad, Scope* sc) for (size_t i = 0; i < ad.invs.dim; i++) { stc = mergeFuncAttrs(stc, ad.invs[i]); - if (stc & STCdisable) + if (stc & STC.disable) { // What should do? } - StorageClass stcy = (ad.invs[i].storage_class & STCsynchronized) | (ad.invs[i].type.mod & MODshared ? STCshared : 0); + StorageClass stcy = (ad.invs[i].storage_class & STC.synchronized_) | (ad.invs[i].type.mod & MODshared ? STC.shared_ : 0); if (i == 0) stcx = stcy; else if (stcx ^ stcy) diff --git a/src/dmd/cond.d b/src/dmd/cond.d index abd4c9abe322..faa5c18c26af 100644 --- a/src/dmd/cond.d +++ b/src/dmd/cond.d @@ -227,7 +227,7 @@ extern (C++) final class StaticForeach : RootObject { // TODO: move to druntime? auto sid = Identifier.generateId("Tuple"); auto sdecl = new StructDeclaration(loc, sid, false); - sdecl.storage_class |= STCstatic; + sdecl.storage_class |= STC.static_; sdecl.members = new Dsymbols(); auto fid = Identifier.idPool(tupleFieldName.ptr, tupleFieldName.length); auto ty = new TypeTypeof(loc, new TupleExp(loc, e)); diff --git a/src/dmd/cppmangle.d b/src/dmd/cppmangle.d index a43c2194f68c..26241adb3883 100644 --- a/src/dmd/cppmangle.d +++ b/src/dmd/cppmangle.d @@ -540,7 +540,7 @@ private final class CppMangleVisitor : Visitor void mangle_variable(VarDeclaration d, bool is_temp_arg_ref) { // fake mangling for fields to fix https://issues.dlang.org/show_bug.cgi?id=16525 - if (!(d.storage_class & (STCextern | STCfield | STCgshared))) + if (!(d.storage_class & (STC.extern_ | STC.field | STC.gshared))) { d.error("Internal Compiler Error: C++ static non- __gshared non-extern variables not supported"); fatal(); @@ -639,9 +639,9 @@ private final class CppMangleVisitor : Visitor int paramsCppMangleDg(size_t n, Parameter fparam) { Type t = fparam.type.merge2(); - if (fparam.storageClass & (STCout | STCref)) + if (fparam.storageClass & (STC.out_ | STC.ref_)) t = t.referenceTo(); - else if (fparam.storageClass & STClazy) + else if (fparam.storageClass & STC.lazy_) { // Mangle as delegate Type td = new TypeFunction(null, t, 0, LINKd); diff --git a/src/dmd/cppmanglewin.d b/src/dmd/cppmanglewin.d index e3fd5c0de214..a570c55b07ed 100644 --- a/src/dmd/cppmanglewin.d +++ b/src/dmd/cppmanglewin.d @@ -569,14 +569,14 @@ private: // ::= ? assert(d); // fake mangling for fields to fix https://issues.dlang.org/show_bug.cgi?id=16525 - if (!(d.storage_class & (STCextern | STCfield | STCgshared))) + if (!(d.storage_class & (STC.extern_ | STC.field | STC.gshared))) { d.error("Internal Compiler Error: C++ static non- __gshared non-extern variables not supported"); fatal(); } buf.writeByte('?'); mangleIdent(d); - assert((d.storage_class & STCfield) || !d.needThis()); + assert((d.storage_class & STC.field) || !d.needThis()); Dsymbol parent = d.toParent(); while (parent && parent.isNspace()) { @@ -1031,11 +1031,11 @@ private: int mangleParameterDg(size_t n, Parameter p) { Type t = p.type; - if (p.storageClass & (STCout | STCref)) + if (p.storageClass & (STC.out_ | STC.ref_)) { t = t.referenceTo(); } - else if (p.storageClass & STClazy) + else if (p.storageClass & STC.lazy_) { // Mangle as delegate Type td = new TypeFunction(null, t, 0, LINKd); diff --git a/src/dmd/dcast.d b/src/dmd/dcast.d index 8ff7b9ff23b5..f9a5e9ecf3c3 100644 --- a/src/dmd/dcast.d +++ b/src/dmd/dcast.d @@ -915,12 +915,12 @@ extern (C++) MATCH implicitConvTo(Expression e, Type t) if (i - j < nparams) { Parameter fparam = Parameter.getNth(tf.parameters, i - j); - if (fparam.storageClass & STClazy) + if (fparam.storageClass & STC.lazy_) return; // not sure what to do with this Type tparam = fparam.type; if (!tparam) continue; - if (fparam.storageClass & (STCout | STCref)) + if (fparam.storageClass & (STC.out_ | STC.ref_)) { if (targ.constConv(tparam.castMod(mod)) == MATCH.nomatch) return; @@ -1209,12 +1209,12 @@ extern (C++) MATCH implicitConvTo(Expression e, Type t) if (i - j < nparams) { Parameter fparam = Parameter.getNth(tf.parameters, i - j); - if (fparam.storageClass & STClazy) + if (fparam.storageClass & STC.lazy_) return; // not sure what to do with this Type tparam = fparam.type; if (!tparam) continue; - if (fparam.storageClass & (STCout | STCref)) + if (fparam.storageClass & (STC.out_ | STC.ref_)) { if (targ.constConv(tparam.castMod(mod)) == MATCH.nomatch) return; @@ -1454,7 +1454,7 @@ extern (C++) Expression castTo(Expression e, Scope* sc, Type t) if (e.op == TOKvar) { VarDeclaration v = (cast(VarExp)e).var.isVarDeclaration(); - if (v && v.storage_class & STCmanifest) + if (v && v.storage_class & STC.manifest) { result = e.ctfeInterpret(); result = result.castTo(sc, t); diff --git a/src/dmd/dclass.d b/src/dmd/dclass.d index 000e823da30b..9d44b66f95e4 100644 --- a/src/dmd/dclass.d +++ b/src/dmd/dclass.d @@ -874,7 +874,7 @@ extern (C++) class ClassDeclaration : AggregateDeclaration bool no() { if (log) printf("no\n"); isabstract = ABSno; return false; } bool yes() { if (log) printf("yes\n"); isabstract = ABSyes; return true; } - if (storage_class & STCabstract || _scope && _scope.stc & STCabstract) + if (storage_class & STC.abstract_ || _scope && _scope.stc & STC.abstract_) return yes(); if (errors) @@ -889,7 +889,7 @@ extern (C++) class ClassDeclaration : AggregateDeclaration auto fd = s.isFuncDeclaration(); if (!fd) return 0; - if (fd.storage_class & STCstatic) + if (fd.storage_class & STC.static_) return 0; if (fd.isAbstract()) @@ -930,7 +930,7 @@ extern (C++) class ClassDeclaration : AggregateDeclaration extern (C++) static int virtualSemantic(Dsymbol s, void* param) { auto fd = s.isFuncDeclaration(); - if (fd && !(fd.storage_class & STCstatic) && !fd.isUnitTestDeclaration()) + if (fd && !(fd.storage_class & STC.static_) && !fd.isUnitTestDeclaration()) fd.dsymbolSemantic(null); return 0; } diff --git a/src/dmd/declaration.d b/src/dmd/declaration.d index 5a85c947ea3d..b92386daa567 100644 --- a/src/dmd/declaration.d +++ b/src/dmd/declaration.d @@ -98,7 +98,7 @@ private int modifyFieldVar(Loc loc, Scope* sc, VarDeclaration var, Expression e1 if (var.isField() && sc.fieldinit && !sc.intypeof) { assert(e1); - auto mustInit = ((var.storage_class & STCnodefaultctor) != 0 || + auto mustInit = ((var.storage_class & STC.nodefaultctor) != 0 || var.type.needsNested()); auto dim = sc.fieldinit_dim; @@ -247,10 +247,10 @@ enum STC : long } extern (C++) __gshared const(StorageClass) STCStorageClass = - (STCauto | STCscope | STCstatic | STCextern | STCconst | STCfinal | STCabstract | STCsynchronized | - STCdeprecated | STCfuture | STCoverride | STClazy | STCalias | STCout | STCin | STCmanifest | - STCimmutable | STCshared | STCwild | STCnothrow | STCnogc | STCpure | STCref | STCreturn | STCtls | STCgshared | - STCproperty | STCsafe | STCtrusted | STCsystem | STCdisable | STClocal); + (STC.auto_ | STC.scope_ | STC.static_ | STC.extern_ | STC.const_ | STC.final_ | STC.abstract_ | STC.synchronized_ | + STC.deprecated_ | STC.future | STC.override_ | STC.lazy_ | STC.alias_ | STC.out_ | STC.in_ | STC.manifest | + STC.immutable_ | STC.shared_ | STC.wild | STC.nothrow_ | STC.nogc | STC.pure_ | STC.ref_ | STC.return_ | STC.tls | STC.gshared | + STC.property | STC.safe | STC.trusted | STC.system | STC.disable | STC.local); struct Match { @@ -278,7 +278,7 @@ extern (C++) abstract class Declaration : Dsymbol final extern (D) this(Identifier id) { super(id); - storage_class = STCundefined; + storage_class = STC.undefined_; protection = Prot(PROTundefined); linkage = LINKdefault; } @@ -310,9 +310,9 @@ extern (C++) abstract class Declaration : Dsymbol */ final bool checkDisabled(Loc loc, Scope* sc, bool isAliasedDeclaration = false) { - if (storage_class & STCdisable) + if (storage_class & STC.disable) { - if (!(sc.func && sc.func.storage_class & STCdisable)) + if (!(sc.func && sc.func.storage_class & STC.disable)) { auto p = toParent(); if (p && isPostBlitDeclaration()) @@ -327,7 +327,7 @@ extern (C++) abstract class Declaration : Dsymbol if (fd) { for (FuncDeclaration ovl = fd; ovl; ovl = cast(FuncDeclaration)ovl.overnext) - if (!(ovl.storage_class & STCdisable)) + if (!(ovl.storage_class & STC.disable)) return false; } } @@ -381,7 +381,7 @@ extern (C++) abstract class Declaration : Dsymbol if (v && (isCtorinit() || isField())) { // It's only modifiable if inside the right constructor - if ((storage_class & (STCforeach | STCref)) == (STCforeach | STCref)) + if ((storage_class & (STC.foreach_ | STC.ref_)) == (STC.foreach_ | STC.ref_)) return 2; return modifyFieldVar(loc, sc, v, e1) ? 2 : 1; } @@ -402,7 +402,7 @@ extern (C++) abstract class Declaration : Dsymbol final bool isStatic() const pure nothrow @nogc @safe { - return (storage_class & STCstatic) != 0; + return (storage_class & STC.static_) != 0; } bool isDelete() @@ -427,92 +427,92 @@ extern (C++) abstract class Declaration : Dsymbol final bool isCtorinit() const pure nothrow @nogc @safe { - return (storage_class & STCctorinit) != 0; + return (storage_class & STC.ctorinit) != 0; } final bool isFinal() const pure nothrow @nogc @safe { - return (storage_class & STCfinal) != 0; + return (storage_class & STC.final_) != 0; } bool isAbstract() { - return (storage_class & STCabstract) != 0; + return (storage_class & STC.abstract_) != 0; } final bool isConst() const pure nothrow @nogc @safe { - return (storage_class & STCconst) != 0; + return (storage_class & STC.const_) != 0; } final bool isImmutable() const pure nothrow @nogc @safe { - return (storage_class & STCimmutable) != 0; + return (storage_class & STC.immutable_) != 0; } final bool isWild() const pure nothrow @nogc @safe { - return (storage_class & STCwild) != 0; + return (storage_class & STC.wild) != 0; } final bool isAuto() const pure nothrow @nogc @safe { - return (storage_class & STCauto) != 0; + return (storage_class & STC.auto_) != 0; } final bool isScope() const pure nothrow @nogc @safe { - return (storage_class & STCscope) != 0; + return (storage_class & STC.scope_) != 0; } final bool isSynchronized() const pure nothrow @nogc @safe { - return (storage_class & STCsynchronized) != 0; + return (storage_class & STC.synchronized_) != 0; } final bool isParameter() const pure nothrow @nogc @safe { - return (storage_class & STCparameter) != 0; + return (storage_class & STC.parameter) != 0; } override final bool isDeprecated() const pure nothrow @nogc @safe { - return (storage_class & STCdeprecated) != 0; + return (storage_class & STC.deprecated_) != 0; } final bool isOverride() const pure nothrow @nogc @safe { - return (storage_class & STCoverride) != 0; + return (storage_class & STC.override_) != 0; } final bool isResult() const pure nothrow @nogc @safe { - return (storage_class & STCresult) != 0; + return (storage_class & STC.result) != 0; } final bool isField() const pure nothrow @nogc @safe { - return (storage_class & STCfield) != 0; + return (storage_class & STC.field) != 0; } final bool isIn() const pure nothrow @nogc @safe { - return (storage_class & STCin) != 0; + return (storage_class & STC.in_) != 0; } final bool isOut() const pure nothrow @nogc @safe { - return (storage_class & STCout) != 0; + return (storage_class & STC.out_) != 0; } final bool isRef() const pure nothrow @nogc @safe { - return (storage_class & STCref) != 0; + return (storage_class & STC.ref_) != 0; } final bool isFuture() const pure nothrow @nogc @safe { - return (storage_class & STCfuture) != 0; + return (storage_class & STC.future) != 0; } override final Prot prot() pure nothrow @nogc @safe @@ -595,7 +595,7 @@ extern (C++) final class TupleDeclaration : Declaration const len = buf.offset; const name = cast(const(char)*)buf.extractData(); auto id = Identifier.idPool(name, len); - auto arg = new Parameter(STCin, t, id, null); + auto arg = new Parameter(STC.in_, t, id, null); } else { @@ -1074,7 +1074,7 @@ extern (C++) class VarDeclaration : Declaration Expression edtor; // if !=null, does the destruction of the variable IntRange* range; // if !=null, the variable is known to be within the range - final extern (D) this(Loc loc, Type type, Identifier id, Initializer _init, StorageClass storage_class = STCundefined) + final extern (D) this(Loc loc, Type type, Identifier id, Initializer _init, StorageClass storage_class = STC.undefined_) { super(id); //printf("VarDeclaration('%s')\n", id.toChars()); @@ -1128,7 +1128,7 @@ extern (C++) class VarDeclaration : Declaration if (!isField()) return; - assert(!(storage_class & (STCstatic | STCextern | STCparameter | STCtls))); + assert(!(storage_class & (STC.static_ | STC.extern_ | STC.parameter | STC.tls))); //printf("+VarDeclaration::setFieldOffset(ad = %s) %s\n", ad.toChars(), toChars()); @@ -1153,7 +1153,7 @@ extern (C++) class VarDeclaration : Declaration // Check for forward referenced types which will fail the size() call Type t = type.toBasetype(); - if (storage_class & STCref) + if (storage_class & STC.ref_) { // References are the size of a pointer t = Type.tvoidptr; @@ -1200,7 +1200,7 @@ extern (C++) class VarDeclaration : Declaration override final AggregateDeclaration isThis() { AggregateDeclaration ad = null; - if (!(storage_class & (STCstatic | STCextern | STCmanifest | STCtemplateparameter | STCtls | STCgshared | STCctfe))) + if (!(storage_class & (STC.static_ | STC.extern_ | STC.manifest | STC.templateparameter | STC.tls | STC.gshared | STC.ctfe))) { for (Dsymbol s = this; s; s = s.parent) { @@ -1227,7 +1227,7 @@ extern (C++) class VarDeclaration : Declaration override final bool isImportedSymbol() { - if (protection.kind == PROTexport && !_init && (storage_class & STCstatic || parent.isModule())) + if (protection.kind == PROTexport && !_init && (storage_class & STC.static_ || parent.isModule())) return true; return false; } @@ -1242,7 +1242,7 @@ extern (C++) class VarDeclaration : Declaration { printf("VarDeclaration::isDataseg(%p, '%s')\n", this, toChars()); printf("%llx, isModule: %p, isTemplateInstance: %p, isNspace: %p\n", - storage_class & (STCstatic | STCconst), parent.isModule(), parent.isTemplateInstance(), parent.isNspace()); + storage_class & (STC.static_ | STC.const_), parent.isModule(), parent.isTemplateInstance(), parent.isNspace()); printf("parent = '%s'\n", parent.toChars()); } @@ -1256,12 +1256,12 @@ extern (C++) class VarDeclaration : Declaration } Dsymbol parent = toParent(); - if (!parent && !(storage_class & STCstatic)) + if (!parent && !(storage_class & STC.static_)) { error("forward referenced"); type = Type.terror; } - else if (storage_class & (STCstatic | STCextern | STCtls | STCgshared) || + else if (storage_class & (STC.static_ | STC.extern_ | STC.tls | STC.gshared) || parent.isModule() || parent.isTemplateInstance() || parent.isNspace()) { isdataseg = 1; // It is in the DataSegment @@ -1279,7 +1279,7 @@ extern (C++) class VarDeclaration : Declaration /* Data defaults to being thread-local. It is not thread-local * if it is immutable, const or shared. */ - bool i = isDataseg() && !(storage_class & (STCimmutable | STCconst | STCshared | STCgshared)); + bool i = isDataseg() && !(storage_class & (STC.immutable_ | STC.const_ | STC.shared_ | STC.gshared)); //printf("\treturn %d\n", i); return i; } @@ -1289,7 +1289,7 @@ extern (C++) class VarDeclaration : Declaration */ final bool isCTFE() { - return (storage_class & STCctfe) != 0; // || !isDataseg(); + return (storage_class & STC.ctfe) != 0; // || !isDataseg(); } final bool isOverlappedWith(VarDeclaration v) @@ -1312,7 +1312,7 @@ extern (C++) class VarDeclaration : Declaration */ final bool canTakeAddressOf() { - return !(storage_class & STCmanifest); + return !(storage_class & STC.manifest); } /****************************************** @@ -1321,7 +1321,7 @@ extern (C++) class VarDeclaration : Declaration final bool needsScopeDtor() { //printf("VarDeclaration::needsScopeDtor() %s\n", toChars()); - return edtor && !(storage_class & STCnodtor); + return edtor && !(storage_class & STC.nodtor); } /****************************************** @@ -1332,8 +1332,8 @@ extern (C++) class VarDeclaration : Declaration { //printf("VarDeclaration::callScopeDtor() %s\n", toChars()); - // Destruction of STCfield's is handled by buildDtor() - if (storage_class & (STCnodtor | STCref | STCout | STCfield)) + // Destruction of STC.field's is handled by buildDtor() + if (storage_class & (STC.nodtor | STC.ref_ | STC.out_ | STC.field)) { return null; } @@ -1396,7 +1396,7 @@ extern (C++) class VarDeclaration : Declaration return e; } // Destructors for classes - if (storage_class & (STCauto | STCscope) && !(storage_class & STCparameter)) + if (storage_class & (STC.auto_ | STC.scope_) && !(storage_class & STC.parameter)) { for (ClassDeclaration cd = type.isClassHandle(); cd; cd = cd.baseClass) { @@ -1462,7 +1462,7 @@ extern (C++) class VarDeclaration : Declaration */ final Expression expandInitializer(Loc loc) { - assert((storage_class & STCmanifest) && _init); + assert((storage_class & STC.manifest) && _init); auto e = getConstInitializer(); if (!e) @@ -1498,7 +1498,7 @@ extern (C++) class VarDeclaration : Declaration return false; if (!parent || parent == sc.parent) return false; - if (isDataseg() || (storage_class & STCmanifest)) + if (isDataseg() || (storage_class & STC.manifest)) return false; // The current function @@ -1626,7 +1626,7 @@ extern (C++) final class SymbolDeclaration : Declaration super(dsym.ident); this.loc = loc; this.dsym = dsym; - storage_class |= STCconst; + storage_class |= STC.const_; } // Eliminate need for dynamic_cast @@ -1651,7 +1651,7 @@ extern (C++) class TypeInfoDeclaration : VarDeclaration { super(Loc(), Type.dtypeinfo.type, tinfo.getTypeInfoIdent(), null); this.tinfo = tinfo; - storage_class = STCstatic | STCgshared; + storage_class = STC.static_ | STC.gshared; protection = Prot(PROTpublic); linkage = LINKc; alignment = Target.ptrsize; @@ -2096,7 +2096,7 @@ extern (C++) final class ThisDeclaration : VarDeclaration extern (D) this(Loc loc, Type t) { super(loc, t, Id.This, null); - storage_class |= STCnodtor; + storage_class |= STC.nodtor; } override Dsymbol syntaxCopy(Dsymbol s) diff --git a/src/dmd/delegatize.d b/src/dmd/delegatize.d index 7536d55f93c1..a75523713af8 100644 --- a/src/dmd/delegatize.d +++ b/src/dmd/delegatize.d @@ -234,7 +234,7 @@ bool ensureStaticLinkTo(Dsymbol s, Dsymbol p) } if (auto ad = s.isAggregateDeclaration()) { - if (ad.storage_class & STCstatic) + if (ad.storage_class & STC.static_) break; } s = s.toParent2(); diff --git a/src/dmd/dinterpret.d b/src/dmd/dinterpret.d index 4439a40d25a5..f0404a68f497 100644 --- a/src/dmd/dinterpret.d +++ b/src/dmd/dinterpret.d @@ -141,7 +141,7 @@ public: extern (C++) Expression getValue(VarDeclaration v) { - if ((v.isDataseg() || v.storage_class & STCmanifest) && !v.isCTFE()) + if ((v.isDataseg() || v.storage_class & STC.manifest) && !v.isCTFE()) { assert(v.ctfeAdrOnStack >= 0 && v.ctfeAdrOnStack < globalValues.dim); return globalValues[v.ctfeAdrOnStack]; @@ -175,7 +175,7 @@ public: extern (C++) void pop(VarDeclaration v) { assert(!v.isDataseg() || v.isCTFE()); - assert(!(v.storage_class & (STCref | STCout))); + assert(!(v.storage_class & (STC.ref_ | STC.out_))); int oldid = v.ctfeAdrOnStack; v.ctfeAdrOnStack = cast(int)cast(size_t)savedId[oldid]; if (v.ctfeAdrOnStack == values.dim - 1) @@ -203,7 +203,7 @@ public: extern (C++) void saveGlobalConstant(VarDeclaration v, Expression e) { - assert(v._init && (v.isConst() || v.isImmutable() || v.storage_class & STCmanifest) && !v.isCTFE()); + assert(v._init && (v.isConst() || v.isImmutable() || v.storage_class & STC.manifest) && !v.isCTFE()); v.ctfeAdrOnStack = cast(int)globalValues.dim; globalValues.push(e); } @@ -310,7 +310,7 @@ struct CompiledCtfeFunction ccf.onDeclaration(v2); } } - else if (!(v.isDataseg() || v.storage_class & STCmanifest) || v.isCTFE()) + else if (!(v.isDataseg() || v.storage_class & STC.manifest) || v.isCTFE()) ccf.onDeclaration(v); Dsymbol s = v.toAlias(); if (s == v && !v.isStatic() && v._init) @@ -789,9 +789,9 @@ private Expression interpret(FuncDeclaration fd, InterState* istate, Expressions Expression earg = (*arguments)[i]; Parameter fparam = Parameter.getNth(tf.parameters, i); - if (fparam.storageClass & (STCout | STCref)) + if (fparam.storageClass & (STC.out_ | STC.ref_)) { - if (!istate && (fparam.storageClass & STCout)) + if (!istate && (fparam.storageClass & STC.out_)) { // initializing an out parameter involves writing to it. earg.error("global `%s` cannot be passed as an `out` parameter at compile time", earg.toChars()); @@ -802,7 +802,7 @@ private Expression interpret(FuncDeclaration fd, InterState* istate, Expressions if (CTFEExp.isCantExp(earg)) return earg; } - else if (fparam.storageClass & STClazy) + else if (fparam.storageClass & STC.lazy_) { } else @@ -824,7 +824,7 @@ private Expression interpret(FuncDeclaration fd, InterState* istate, Expressions /* Struct literals are passed by value, but we don't need to * copy them if they are passed as const */ - if (earg.op == TOKstructliteral && !(fparam.storageClass & (STCconst | STCimmutable))) + if (earg.op == TOKstructliteral && !(fparam.storageClass & (STC.const_ | STC.immutable_))) earg = copyLiteral(earg).copy(); } if (earg.op == TOKthrownexception) @@ -860,7 +860,7 @@ private Expression interpret(FuncDeclaration fd, InterState* istate, Expressions } ctfeStack.push(v); - if ((fparam.storageClass & (STCout | STCref)) && earg.op == TOKvar && (cast(VarExp)earg).var.toParent2() == fd) + if ((fparam.storageClass & (STC.out_ | STC.ref_)) && earg.op == TOKvar && (cast(VarExp)earg).var.toParent2() == fd) { VarDeclaration vx = (cast(VarExp)earg).var.isVarDeclaration(); if (!vx) @@ -1194,7 +1194,7 @@ public: VarDeclaration v; while (x.op == TOKvar && (v = (cast(VarExp)x).var.isVarDeclaration()) !is null) { - if (v.storage_class & STCref) + if (v.storage_class & STC.ref_) { x = getValue(v); if (e.op == TOKaddress) @@ -2253,7 +2253,7 @@ public: return CTFEExp.cantexp; } - if ((v.isConst() || v.isImmutable() || v.storage_class & STCmanifest) && !hasValue(v) && v._init && !v.isCTFE()) + if ((v.isConst() || v.isImmutable() || v.storage_class & STC.manifest) && !hasValue(v) && v._init && !v.isCTFE()) { if (v.inuse) { @@ -2281,7 +2281,7 @@ public: { // FIXME: Ultimately all errors should be detected in prior semantic analysis stage. } - else if (v.isDataseg() || (v.storage_class & STCmanifest)) + else if (v.isDataseg() || (v.storage_class & STC.manifest)) { /* https://issues.dlang.org/show_bug.cgi?id=14304 * e is a value that is not yet owned by CTFE. @@ -2318,7 +2318,7 @@ public: e = interpret(e, istate); } - else if (!(v.isDataseg() || v.storage_class & STCmanifest) && !v.isCTFE() && !istate) + else if (!(v.isDataseg() || v.storage_class & STC.manifest) && !v.isCTFE() && !istate) { error(loc, "variable `%s` cannot be read at compile time", v.toChars()); return CTFEExp.cantexp; @@ -2398,7 +2398,7 @@ public: result = CTFEExp.cantexp; return; } - if (v && (v.storage_class & (STCout | STCref)) && hasValue(v)) + if (v && (v.storage_class & (STC.out_ | STC.ref_)) && hasValue(v)) { // Strip off the nest of ref variables Expression ev = getValue(v); @@ -2414,9 +2414,9 @@ public: result = getVarExp(e.loc, istate, e.var, goal); if (exceptionOrCant(result)) return; - if ((e.var.storage_class & (STCref | STCout)) == 0 && e.type.baseElemOf().ty != Tstruct) + if ((e.var.storage_class & (STC.ref_ | STC.out_)) == 0 && e.type.baseElemOf().ty != Tstruct) { - /* Ultimately, STCref|STCout check should be enough to see the + /* Ultimately, STC.ref_|STC.out_ check should be enough to see the * necessity of type repainting. But currently front-end paints * non-ref struct variables by the const type. * @@ -2486,7 +2486,7 @@ public: result = null; return; } - if (!(v.isDataseg() || v.storage_class & STCmanifest) || v.isCTFE()) + if (!(v.isDataseg() || v.storage_class & STC.manifest) || v.isCTFE()) ctfeStack.push(v); if (v._init) { @@ -3597,7 +3597,7 @@ public: { VarDeclaration v = (cast(VarExp)e1).var.isVarDeclaration(); assert(v); - if (v.storage_class & STCout) + if (v.storage_class & STC.out_) goto L1; } else if (ultimateVar && !getValue(ultimateVar)) @@ -4987,7 +4987,7 @@ public: if (e.e1.op == TOKdeclaration && e.e2.op == TOKvar && (cast(DeclarationExp)e.e1).declaration == (cast(VarExp)e.e2).var && - (cast(VarExp)e.e2).var.storage_class & STCctfe) + (cast(VarExp)e.e2).var.storage_class & STC.ctfe) { VarExp ve = cast(VarExp)e.e2; VarDeclaration v = ve.var.isVarDeclaration(); @@ -6529,7 +6529,7 @@ private Expression interpret_aaApply(InterState* istate, Expression aa, Expressi assert(numParams == 1 || numParams == 2); Parameter fparam = Parameter.getNth((cast(TypeFunction)fd.type).parameters, numParams - 1); - bool wantRefValue = 0 != (fparam.storageClass & (STCout | STCref)); + bool wantRefValue = 0 != (fparam.storageClass & (STC.out_ | STC.ref_)); Expressions args; args.setDim(numParams); @@ -7005,11 +7005,11 @@ private void setValue(VarDeclaration vd, Expression newval) { version (none) { - if (!((vd.storage_class & (STCout | STCref)) ? isCtfeReferenceValid(newval) : isCtfeValueValid(newval))) + if (!((vd.storage_class & (STC.out_ | STC.ref_)) ? isCtfeReferenceValid(newval) : isCtfeValueValid(newval))) { printf("[%s] vd = %s %s, newval = %s\n", vd.loc.toChars(), vd.type.toChars(), vd.toChars(), newval.toChars()); } } - assert((vd.storage_class & (STCout | STCref)) ? isCtfeReferenceValid(newval) : isCtfeValueValid(newval)); + assert((vd.storage_class & (STC.out_ | STC.ref_)) ? isCtfeReferenceValid(newval) : isCtfeValueValid(newval)); ctfeStack.setValue(vd, newval); } diff --git a/src/dmd/dmangle.d b/src/dmd/dmangle.d index 0178c118003f..75555dd5cb5d 100644 --- a/src/dmd/dmangle.d +++ b/src/dmd/dmangle.d @@ -1058,29 +1058,29 @@ public: override void visit(Parameter p) { - if (p.storageClass & STCscope && !(p.storageClass & STCscopeinferred)) + if (p.storageClass & STC.scope_ && !(p.storageClass & STC.scopeinferred)) buf.writeByte('M'); // 'return inout ref' is the same as 'inout ref' - if ((p.storageClass & (STCreturn | STCwild)) == STCreturn) + if ((p.storageClass & (STC.return_ | STC.wild)) == STC.return_) buf.writestring("Nk"); - switch (p.storageClass & (STCin | STCout | STCref | STClazy)) + switch (p.storageClass & (STC.in_ | STC.out_ | STC.ref_ | STC.lazy_)) { case 0: - case STCin: + case STC.in_: break; - case STCout: + case STC.out_: buf.writeByte('J'); break; - case STCref: + case STC.ref_: buf.writeByte('K'); break; - case STClazy: + case STC.lazy_: buf.writeByte('L'); break; default: debug { - printf("storageClass = x%llx\n", p.storageClass & (STCin | STCout | STCref | STClazy)); + printf("storageClass = x%llx\n", p.storageClass & (STC.in_ | STC.out_ | STC.ref_ | STC.lazy_)); } assert(0); } diff --git a/src/dmd/doc.d b/src/dmd/doc.d index 9a70ee6a3cd7..6d3425ed2735 100644 --- a/src/dmd/doc.d +++ b/src/dmd/doc.d @@ -1134,7 +1134,7 @@ private void toDocBuffer(Dsymbol s, OutBuffer* buf, Scope* sc) if (d.isImmutable()) buf.writestring("immutable "); - if (d.storage_class & STCshared) + if (d.storage_class & STC.shared_) buf.writestring("shared "); if (d.isWild()) buf.writestring("inout "); @@ -1144,12 +1144,12 @@ private void toDocBuffer(Dsymbol s, OutBuffer* buf, Scope* sc) if (d.isSynchronized()) buf.writestring("synchronized "); - if (d.storage_class & STCmanifest) + if (d.storage_class & STC.manifest) buf.writestring("enum "); // Add "auto" for the untyped variable in template members if (!d.type && d.isVarDeclaration() && - !d.isImmutable() && !(d.storage_class & STCshared) && !d.isWild() && !d.isConst() && + !d.isImmutable() && !(d.storage_class & STC.shared_) && !d.isWild() && !d.isConst() && !d.isSynchronized()) { buf.writestring("auto "); diff --git a/src/dmd/dscope.d b/src/dmd/dscope.d index fa357bd72030..25ccf89e226f 100644 --- a/src/dmd/dscope.d +++ b/src/dmd/dscope.d @@ -415,7 +415,7 @@ struct Scope for (size_t i = 0; i < ad.fields.dim; i++) { VarDeclaration v = ad.fields[i]; - bool mustInit = (v.storage_class & STCnodefaultctor || v.type.needsNested()); + bool mustInit = (v.storage_class & STC.nodefaultctor || v.type.needsNested()); if (!.mergeFieldInit(loc, fieldinit[i], fies[i], mustInit)) { .error(loc, "one path skips field `%s`", ad.fields[i].toChars()); diff --git a/src/dmd/dstruct.d b/src/dmd/dstruct.d index 41345113ab9d..f9ccc35e7513 100644 --- a/src/dmd/dstruct.d +++ b/src/dmd/dstruct.d @@ -552,7 +552,7 @@ extern (C++) class StructDeclaration : AggregateDeclaration for (size_t i = 0; i < fields.dim; i++) { VarDeclaration v = fields[i]; - if (v.storage_class & STCref) + if (v.storage_class & STC.ref_) { ispod = ISPODno; break; diff --git a/src/dmd/dsymbol.d b/src/dmd/dsymbol.d index 1b75cf6a2ac0..c7bba1ef7d14 100644 --- a/src/dmd/dsymbol.d +++ b/src/dmd/dsymbol.d @@ -321,7 +321,7 @@ extern (C++) class Dsymbol : RootObject return; // If inside a StorageClassDeclaration that is deprecated - if (sc2.stc & STCdeprecated) + if (sc2.stc & STC.deprecated_) return; } const(char)* message = null; @@ -1552,7 +1552,7 @@ public: { Scope sc; auto parameters = new Parameters(); - Parameters* p = new Parameter(STCin, Type.tchar.constOf().arrayOf(), null, null); + Parameters* p = new Parameter(STC.in_, Type.tchar.constOf().arrayOf(), null, null); parameters.push(p); Type tret = null; tfgetmembers = new TypeFunction(parameters, tret, 0, LINKd); @@ -1793,7 +1793,7 @@ extern (C++) final class ArrayScopeSymbol : ScopeDsymbol auto v = new VarDeclaration(loc, Type.tsize_t, Id.dollar, null); Expression e = new IntegerExp(Loc(), td.objects.dim, Type.tsize_t); v._init = new ExpInitializer(Loc(), e); - v.storage_class |= STCtemp | STCstatic | STCconst; + v.storage_class |= STC.temp | STC.static_ | STC.const_; v.dsymbolSemantic(sc); return v; } @@ -1804,7 +1804,7 @@ extern (C++) final class ArrayScopeSymbol : ScopeDsymbol auto v = new VarDeclaration(loc, Type.tsize_t, Id.dollar, null); Expression e = new IntegerExp(Loc(), type.arguments.dim, Type.tsize_t); v._init = new ExpInitializer(Loc(), e); - v.storage_class |= STCtemp | STCstatic | STCconst; + v.storage_class |= STC.temp | STC.static_ | STC.const_; v.dsymbolSemantic(sc); return v; } @@ -1870,7 +1870,7 @@ extern (C++) final class ArrayScopeSymbol : ScopeDsymbol */ Expression e = new IntegerExp(Loc(), (cast(TupleExp)ce).exps.dim, Type.tsize_t); v = new VarDeclaration(loc, Type.tsize_t, Id.dollar, new ExpInitializer(Loc(), e)); - v.storage_class |= STCtemp | STCstatic | STCconst; + v.storage_class |= STC.temp | STC.static_ | STC.const_; } else if (ce.type && (t = ce.type.toBasetype()) !is null && (t.ty == Tstruct || t.ty == Tclass)) { @@ -1928,7 +1928,7 @@ extern (C++) final class ArrayScopeSymbol : ScopeDsymbol if (t && t.ty == Tfunction) e = new CallExp(e.loc, e); v = new VarDeclaration(loc, null, Id.dollar, new ExpInitializer(Loc(), e)); - v.storage_class |= STCtemp | STCctfe | STCrvalue; + v.storage_class |= STC.temp | STC.ctfe | STC.rvalue; } else { @@ -1940,7 +1940,7 @@ extern (C++) final class ArrayScopeSymbol : ScopeDsymbol auto e = new VoidInitializer(Loc()); e.type = Type.tsize_t; v = new VarDeclaration(loc, Type.tsize_t, Id.dollar, e); - v.storage_class |= STCtemp | STCctfe; // it's never a true static variable + v.storage_class |= STC.temp | STC.ctfe; // it's never a true static variable } *pvar = v; } @@ -2022,9 +2022,9 @@ extern (C++) final class ForwardingScopeDsymbol : ScopeDsymbol assert(forward); if (auto d = s.isDeclaration()) { - if (d.storage_class & STClocal) + if (d.storage_class & STC.local) { - // Symbols with storage class STClocal are not + // Symbols with storage class STC.local are not // forwarded, but stored in the local symbol // table. (Those are the `static foreach` variables.) if (!symtab) @@ -2038,7 +2038,7 @@ extern (C++) final class ForwardingScopeDsymbol : ScopeDsymbol { forward.symtab = new DsymbolTable(); } - // Non-STClocal symbols are forwarded to `forward`. + // Non-STC.local symbols are forwarded to `forward`. return forward.symtabInsert(s); } @@ -2054,7 +2054,7 @@ extern (C++) final class ForwardingScopeDsymbol : ScopeDsymbol // correctly diagnose clashing foreach loop variables. if (auto d = s.isDeclaration()) { - if (d.storage_class & STClocal) + if (d.storage_class & STC.local) { if (!symtab) { diff --git a/src/dmd/dsymbolsem.d b/src/dmd/dsymbolsem.d index ffd82cd2fb4e..8c54df09a59e 100644 --- a/src/dmd/dsymbolsem.d +++ b/src/dmd/dsymbolsem.d @@ -263,7 +263,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor return; assert(dsym.semanticRun <= PASSsemantic); - dsym.storage_class |= sc.stc & STCdeprecated; + dsym.storage_class |= sc.stc & STC.deprecated_; dsym.protection = sc.protection; dsym.userAttribDecl = sc.userAttribDecl; @@ -307,15 +307,15 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor /* Pick up storage classes from context, but except synchronized, * override, abstract, and final. */ - dsym.storage_class |= (sc.stc & ~(STCsynchronized | STCoverride | STCabstract | STCfinal)); - if (dsym.storage_class & STCextern && dsym._init) + dsym.storage_class |= (sc.stc & ~(STC.synchronized_ | STC.override_ | STC.abstract_ | STC.final_)); + if (dsym.storage_class & STC.extern_ && dsym._init) dsym.error("extern symbols cannot have initializers"); dsym.userAttribDecl = sc.userAttribDecl; AggregateDeclaration ad = dsym.isThis(); if (ad) - dsym.storage_class |= ad.storage_class & STC_TYPECTOR; + dsym.storage_class |= ad.storage_class & STC.TYPECTOR; /* If auto type inference, do the inference */ @@ -326,7 +326,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor // Infering the type requires running semantic, // so mark the scope as ctfe if required - bool needctfe = (dsym.storage_class & (STCmanifest | STCstatic)) != 0; + bool needctfe = (dsym.storage_class & (STC.manifest | STC.static_)) != 0; if (needctfe) sc = sc.startCTFE(); @@ -342,7 +342,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor /* This is a kludge to support the existing syntax for RAII * declarations. */ - dsym.storage_class &= ~STCauto; + dsym.storage_class &= ~STC.auto_; dsym.originalType = dsym.type.syntaxCopy(); } else @@ -356,7 +356,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor * static assert(is(typeof(fp) == void function() pure nothrow)); */ Scope* sc2 = sc.push(); - sc2.stc |= (dsym.storage_class & STC_FUNCATTR); + sc2.stc |= (dsym.storage_class & STC.FUNCATTR); dsym.inuse++; dsym.type = dsym.type.typeSemantic(dsym.loc, sc2); dsym.inuse--; @@ -388,7 +388,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor // Calculate type size + safety checks if (sc.func && !sc.intypeof) { - if (dsym.storage_class & STCgshared && !dsym.isMember()) + if (dsym.storage_class & STC.gshared && !dsym.isMember()) { if (sc.func.setUnsafe()) dsym.error("__gshared not allowed in safe functions; use shared"); @@ -399,7 +399,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor Type tb = dsym.type.toBasetype(); Type tbn = tb.baseElemOf(); - if (tb.ty == Tvoid && !(dsym.storage_class & STClazy)) + if (tb.ty == Tvoid && !(dsym.storage_class & STC.lazy_)) { if (inferred) { @@ -424,7 +424,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor dsym.error("no definition of struct `%s`", ts.toChars()); } } - if ((dsym.storage_class & STCauto) && !inferred) + if ((dsym.storage_class & STC.auto_) && !inferred) dsym.error("storage class `auto` has no effect if type is not inferred, did you mean `scope`?"); if (tb.ty == Ttuple) @@ -559,8 +559,8 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor else ti = dsym._init ? dsym._init.syntaxCopy() : null; - StorageClass storage_class = STCtemp | dsym.storage_class; - if (arg.storageClass & STCparameter) + StorageClass storage_class = STC.temp | dsym.storage_class; + if (arg.storageClass & STC.parameter) storage_class |= arg.storageClass; auto v = new VarDeclaration(dsym.loc, arg.type, id, ti, storage_class); //printf("declaring field %s of type %s\n", v.toChars(), v.type.toChars()); @@ -593,20 +593,20 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor */ if (dsym.type.isConst()) { - dsym.storage_class |= STCconst; + dsym.storage_class |= STC.const_; if (dsym.type.isShared()) - dsym.storage_class |= STCshared; + dsym.storage_class |= STC.shared_; } else if (dsym.type.isImmutable()) - dsym.storage_class |= STCimmutable; + dsym.storage_class |= STC.immutable_; else if (dsym.type.isShared()) - dsym.storage_class |= STCshared; + dsym.storage_class |= STC.shared_; else if (dsym.type.isWild()) - dsym.storage_class |= STCwild; + dsym.storage_class |= STC.wild; - if (StorageClass stc = dsym.storage_class & (STCsynchronized | STCoverride | STCabstract | STCfinal)) + if (StorageClass stc = dsym.storage_class & (STC.synchronized_ | STC.override_ | STC.abstract_ | STC.final_)) { - if (stc == STCfinal) + if (stc == STC.final_) dsym.error("cannot be final, perhaps you meant const?"); else { @@ -617,9 +617,9 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor dsym.storage_class &= ~stc; // strip off } - if (dsym.storage_class & STCscope) + if (dsym.storage_class & STC.scope_) { - StorageClass stc = dsym.storage_class & (STCstatic | STCextern | STCmanifest | STCtls | STCgshared); + StorageClass stc = dsym.storage_class & (STC.static_ | STC.extern_ | STC.manifest | STC.tls | STC.gshared); if (stc) { OutBuffer buf; @@ -632,11 +632,11 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor } else if (!dsym.type.hasPointers()) { - dsym.storage_class &= ~STCscope; // silently ignore; may occur in generic code + dsym.storage_class &= ~STC.scope_; // silently ignore; may occur in generic code } } - if (dsym.storage_class & (STCstatic | STCextern | STCmanifest | STCtemplateparameter | STCtls | STCgshared | STCctfe)) + if (dsym.storage_class & (STC.static_ | STC.extern_ | STC.manifest | STC.templateparameter | STC.tls | STC.gshared | STC.ctfe)) { } else @@ -644,13 +644,13 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor AggregateDeclaration aad = parent.isAggregateDeclaration(); if (aad) { - if (global.params.vfield && dsym.storage_class & (STCconst | STCimmutable) && dsym._init && !dsym._init.isVoidInitializer()) + if (global.params.vfield && dsym.storage_class & (STC.const_ | STC.immutable_) && dsym._init && !dsym._init.isVoidInitializer()) { const(char)* p = dsym.loc.toChars(); - const(char)* s = (dsym.storage_class & STCimmutable) ? "immutable" : "const"; + const(char)* s = (dsym.storage_class & STC.immutable_) ? "immutable" : "const"; fprintf(global.stdmsg, "%s: %s.%s is %s field\n", p ? p : "", ad.toPrettyChars(), dsym.toChars(), s); } - dsym.storage_class |= STCfield; + dsym.storage_class |= STC.field; if (tbn.ty == Tstruct && (cast(TypeStruct)tbn).sym.noDefaultCtor) { if (!dsym.isThisDeclaration() && !dsym._init) @@ -683,21 +683,21 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor } // If it's a member template AggregateDeclaration ad2 = ti.tempdecl.isMember(); - if (ad2 && dsym.storage_class != STCundefined) + if (ad2 && dsym.storage_class != STC.undefined_) { dsym.error("cannot use template to add field to aggregate `%s`", ad2.toChars()); } } } - if ((dsym.storage_class & (STCref | STCparameter | STCforeach | STCtemp | STCresult)) == STCref && dsym.ident != Id.This) + if ((dsym.storage_class & (STC.ref_ | STC.parameter | STC.foreach_ | STC.temp | STC.result)) == STC.ref_ && dsym.ident != Id.This) { dsym.error("only parameters or foreach declarations can be ref"); } if (dsym.type.hasWild()) { - if (dsym.storage_class & (STCstatic | STCextern | STCtls | STCgshared | STCmanifest | STCfield) || dsym.isDataseg()) + if (dsym.storage_class & (STC.static_ | STC.extern_ | STC.tls | STC.gshared | STC.manifest | STC.field) || dsym.isDataseg()) { dsym.error("only parameters or stack based variables can be inout"); } @@ -722,7 +722,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor } } - if (!(dsym.storage_class & (STCctfe | STCref | STCresult)) && tbn.ty == Tstruct && (cast(TypeStruct)tbn).sym.noDefaultCtor) + if (!(dsym.storage_class & (STC.ctfe | STC.ref_ | STC.result)) && tbn.ty == Tstruct && (cast(TypeStruct)tbn).sym.noDefaultCtor) { if (!dsym._init) { @@ -730,9 +730,9 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor { /* For fields, we'll check the constructor later to make sure it is initialized */ - dsym.storage_class |= STCnodefaultctor; + dsym.storage_class |= STC.nodefaultctor; } - else if (dsym.storage_class & STCparameter) + else if (dsym.storage_class & STC.parameter) { } else @@ -741,15 +741,15 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor } FuncDeclaration fd = parent.isFuncDeclaration(); - if (dsym.type.isscope() && !(dsym.storage_class & STCnodtor)) + if (dsym.type.isscope() && !(dsym.storage_class & STC.nodtor)) { - if (dsym.storage_class & (STCfield | STCout | STCref | STCstatic | STCmanifest | STCtls | STCgshared) || !fd) + if (dsym.storage_class & (STC.field | STC.out_ | STC.ref_ | STC.static_ | STC.manifest | STC.tls | STC.gshared) || !fd) { dsym.error("globals, statics, fields, manifest constants, ref and out parameters cannot be scope"); } - if (!(dsym.storage_class & STCscope)) + if (!(dsym.storage_class & STC.scope_)) { - if (!(dsym.storage_class & STCparameter) && dsym.ident != Id.withSym) + if (!(dsym.storage_class & STC.parameter) && dsym.ident != Id.withSym) dsym.error("reference to scope class must be scope"); } } @@ -763,7 +763,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor dsym.error("void initializers for pointers not allowed in safe functions"); } else if (!dsym._init && - !(dsym.storage_class & (STCstatic | STCextern | STCtls | STCgshared | STCmanifest | STCfield | STCparameter)) && + !(dsym.storage_class & (STC.static_ | STC.extern_ | STC.tls | STC.gshared | STC.manifest | STC.field | STC.parameter)) && dsym.type.hasVoidInitPointers()) { if (sc.func.setUnsafe()) @@ -774,22 +774,22 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor if (!dsym._init && !fd) { // If not mutable, initializable by constructor only - dsym.storage_class |= STCctorinit; + dsym.storage_class |= STC.ctorinit; } if (dsym._init) - dsym.storage_class |= STCinit; // remember we had an explicit initializer - else if (dsym.storage_class & STCmanifest) + dsym.storage_class |= STC.init; // remember we had an explicit initializer + else if (dsym.storage_class & STC.manifest) dsym.error("manifest constants must have initializers"); bool isBlit = false; d_uns64 sz; if (!dsym._init && !sc.inunion && - !(dsym.storage_class & (STCstatic | STCgshared | STCextern)) && + !(dsym.storage_class & (STC.static_ | STC.gshared | STC.extern_)) && fd && - (!(dsym.storage_class & (STCfield | STCin | STCforeach | STCparameter | STCresult)) || - (dsym.storage_class & STCout)) && + (!(dsym.storage_class & (STC.field | STC.in_ | STC.foreach_ | STC.parameter | STC.result)) || + (dsym.storage_class & STC.out_)) && (sz = dsym.type.size()) != 0) { // Provide a default initializer @@ -844,7 +844,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor if (dsym._init) { sc = sc.push(); - sc.stc &= ~(STC_TYPECTOR | STCpure | STCnothrow | STCnogc | STCref | STCdisable); + sc.stc &= ~(STC.TYPECTOR | STC.pure_ | STC.nothrow_ | STC.nogc | STC.ref_ | STC.disable); ExpInitializer ei = dsym._init.isExpInitializer(); if (ei) // https://issues.dlang.org/show_bug.cgi?id=13424 @@ -856,7 +856,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor { // If local variable, use AssignExp to handle all the various // possibilities. - if (fd && !(dsym.storage_class & (STCmanifest | STCstatic | STCtls | STCgshared | STCextern)) && !dsym._init.isVoidInitializer()) + if (fd && !(dsym.storage_class & (STC.manifest | STC.static_ | STC.tls | STC.gshared | STC.extern_)) && !dsym._init.isVoidInitializer()) { //printf("fd = '%s', var = '%s'\n", fd.toChars(), toChars()); if (!ei) @@ -944,7 +944,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor dsym._scope = scx ? scx : sc.copy(); dsym._scope.setNoFree(); } - else if (dsym.storage_class & (STCconst | STCimmutable | STCmanifest) || dsym.type.isConst() || dsym.type.isImmutable()) + else if (dsym.storage_class & (STC.const_ | STC.immutable_ | STC.manifest) || dsym.type.isConst() || dsym.type.isImmutable()) { /* Because we may need the results of a const declaration in a * subsequent type, such as an array dimension, before semantic2() @@ -959,7 +959,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor { Expression exp = ei.exp.syntaxCopy(); - bool needctfe = dsym.isDataseg() || (dsym.storage_class & STCmanifest); + bool needctfe = dsym.isDataseg() || (dsym.storage_class & STC.manifest); if (needctfe) sc = sc.startCTFE(); exp = exp.expressionSemantic(sc); @@ -1025,20 +1025,20 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor * then make dsym scope, too. */ if (global.params.vsafe && - !(dsym.storage_class & (STCparameter | STCtemp | STCfield | STCin | STCforeach | STCresult | STCmanifest)) && + !(dsym.storage_class & (STC.parameter | STC.temp | STC.field | STC.in_ | STC.foreach_ | STC.result | STC.manifest)) && !dsym.isDataseg() && !dsym.doNotInferScope && dsym.type.hasPointers()) { auto tv = dsym.type.baseElemOf(); if (tv.ty == Tstruct && - (cast(TypeStruct)tv).sym.dtor.storage_class & STCscope) + (cast(TypeStruct)tv).sym.dtor.storage_class & STC.scope_) { - dsym.storage_class |= STCscope; + dsym.storage_class |= STC.scope_; } } - if (sc.func && dsym.storage_class & (STCstatic | STCgshared)) + if (sc.func && dsym.storage_class & (STC.static_ | STC.gshared)) dsym.edtor = dsym.edtor.expressionSemantic(sc._module._scope); else dsym.edtor = dsym.edtor.expressionSemantic(sc); @@ -1046,7 +1046,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor version (none) { // currently disabled because of std.stdio.stdin, stdout and stderr - if (dsym.isDataseg() && !(dsym.storage_class & STCextern)) + if (dsym.isDataseg() && !(dsym.storage_class & STC.extern_)) dsym.error("static storage variables cannot have destructors"); } } @@ -1205,7 +1205,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor ob.writeByte(' '); if (imp.isstatic) { - stcToBuffer(ob, STCstatic); + stcToBuffer(ob, STC.static_); ob.writeByte(' '); } ob.writestring(": "); @@ -1292,7 +1292,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor if (scd.decl) { sc = sc.push(); - sc.stc &= ~(STCauto | STCscope | STCstatic | STCtls | STCgshared); + sc.stc &= ~(STC.auto_ | STC.scope_ | STC.static_ | STC.tls | STC.gshared); sc.inunion = scd.isunion; sc.flags = 0; for (size_t i = 0; i < scd.decl.dim; i++) @@ -1690,7 +1690,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor ed.type = ed.type.typeSemantic(ed.loc, sc); ed.protection = sc.protection; - if (sc.stc & STCdeprecated) + if (sc.stc & STC.deprecated_) ed.isdeprecated = true; ed.userAttribDecl = sc.userAttribDecl; @@ -1875,7 +1875,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor em.protection = em.ed.isAnonymous() ? em.ed.protection : Prot(PROTpublic); em.linkage = LINKd; - em.storage_class = STCmanifest; + em.storage_class = STC.manifest; em.userAttribDecl = em.ed.isAnonymous() ? em.ed.userAttribDecl : null; // The first enum member is special @@ -2104,7 +2104,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor tempdecl.parent = sc.parent; tempdecl.protection = sc.protection; - tempdecl.isstatic = tempdecl.toParent().isModule() || (tempdecl._scope.stc & STCstatic); + tempdecl.isstatic = tempdecl.toParent().isModule() || (tempdecl._scope.stc & STC.static_); if (!tempdecl.isstatic) { @@ -2537,20 +2537,20 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor funcdecl.foverrides.setDim(0); // reset in case semantic() is being retried for this function - funcdecl.storage_class |= sc.stc & ~STCref; + funcdecl.storage_class |= sc.stc & ~STC.ref_; ad = funcdecl.isThis(); // Don't nest structs b/c of generated methods which should not access the outer scopes. // https://issues.dlang.org/show_bug.cgi?id=16627 if (ad && !funcdecl.generated) { - funcdecl.storage_class |= ad.storage_class & (STC_TYPECTOR | STCsynchronized); + funcdecl.storage_class |= ad.storage_class & (STC.TYPECTOR | STC.synchronized_); ad.makeNested(); } if (sc.func) - funcdecl.storage_class |= sc.func.storage_class & STCdisable; + funcdecl.storage_class |= sc.func.storage_class & STC.disable; // Remove prefix storage classes silently. - if ((funcdecl.storage_class & STC_TYPECTOR) && !(ad || funcdecl.isNested())) - funcdecl.storage_class &= ~STC_TYPECTOR; + if ((funcdecl.storage_class & STC.TYPECTOR) && !(ad || funcdecl.isNested())) + funcdecl.storage_class &= ~STC.TYPECTOR; //printf("function storage_class = x%llx, sc.stc = x%llx, %x\n", storage_class, sc.stc, Declaration::isFinal()); @@ -2588,7 +2588,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor if (!funcdecl.type.deco) { sc = sc.push(); - sc.stc |= funcdecl.storage_class & (STCdisable | STCdeprecated); // forward to function type + sc.stc |= funcdecl.storage_class & (STC.disable | STC.deprecated_); // forward to function type TypeFunction tf = funcdecl.type.toTypeFunction(); if (sc.func) @@ -2633,25 +2633,25 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor } if (tf.isref) - sc.stc |= STCref; + sc.stc |= STC.ref_; if (tf.isscope) - sc.stc |= STCscope; + sc.stc |= STC.scope_; if (tf.isnothrow) - sc.stc |= STCnothrow; + sc.stc |= STC.nothrow_; if (tf.isnogc) - sc.stc |= STCnogc; + sc.stc |= STC.nogc; if (tf.isproperty) - sc.stc |= STCproperty; + sc.stc |= STC.property; if (tf.purity == PUREfwdref) - sc.stc |= STCpure; + sc.stc |= STC.pure_; if (tf.trust != TRUSTdefault) - sc.stc &= ~(STCsafe | STCsystem | STCtrusted); + sc.stc &= ~(STC.safe | STC.system | STC.trusted); if (tf.trust == TRUSTsafe) - sc.stc |= STCsafe; + sc.stc |= STC.safe; if (tf.trust == TRUSTsystem) - sc.stc |= STCsystem; + sc.stc |= STC.system; if (tf.trust == TRUSTtrusted) - sc.stc |= STCtrusted; + sc.stc |= STC.trusted; if (funcdecl.isCtorDeclaration()) { @@ -2662,17 +2662,17 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor tret = tret.addMod(funcdecl.type.mod); tf.next = tret; if (ad.isStructDeclaration()) - sc.stc |= STCref; + sc.stc |= STC.ref_; } // 'return' on a non-static class member function implies 'scope' as well - if (ad && ad.isClassDeclaration() && (tf.isreturn || sc.stc & STCreturn) && !(sc.stc & STCstatic)) - sc.stc |= STCscope; + if (ad && ad.isClassDeclaration() && (tf.isreturn || sc.stc & STC.return_) && !(sc.stc & STC.static_)) + sc.stc |= STC.scope_; // If 'this' has no pointers, remove 'scope' as it has no meaning - if (sc.stc & STCscope && ad && ad.isStructDeclaration() && !ad.type.hasPointers()) + if (sc.stc & STC.scope_ && ad && ad.isStructDeclaration() && !ad.type.hasPointers()) { - sc.stc &= ~STCscope; + sc.stc &= ~STC.scope_; tf.isscope = false; } @@ -2691,13 +2691,13 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor */ auto stc = funcdecl.storage_class; if (funcdecl.type.isImmutable()) - stc |= STCimmutable; + stc |= STC.immutable_; if (funcdecl.type.isConst()) - stc |= STCconst; - if (funcdecl.type.isShared() || funcdecl.storage_class & STCsynchronized) - stc |= STCshared; + stc |= STC.const_; + if (funcdecl.type.isShared() || funcdecl.storage_class & STC.synchronized_) + stc |= STC.shared_; if (funcdecl.type.isWild()) - stc |= STCwild; + stc |= STC.wild; funcdecl.type = funcdecl.type.addSTC(stc); funcdecl.type = funcdecl.type.typeSemantic(funcdecl.loc, sc); @@ -2729,13 +2729,13 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor tfo.purity = tfx.purity; tfo.trust = tfx.trust; - funcdecl.storage_class &= ~(STC_TYPECTOR | STC_FUNCATTR); + funcdecl.storage_class &= ~(STC.TYPECTOR | STC.FUNCATTR); } f = cast(TypeFunction)funcdecl.type; size_t nparams = Parameter.dim(f.parameters); - if ((funcdecl.storage_class & STCauto) && !f.isref && !funcdecl.inferRetType) + if ((funcdecl.storage_class & STC.auto_) && !f.isref && !funcdecl.inferRetType) funcdecl.error("storage class `auto` has no effect if return type is not inferred"); /* Functions can only be 'scope' if they have a 'this' @@ -2797,7 +2797,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor id = parent.isInterfaceDeclaration(); if (id) { - funcdecl.storage_class |= STCabstract; + funcdecl.storage_class |= STC.abstract_; if (funcdecl.isCtorDeclaration() || funcdecl.isPostBlitDeclaration() || funcdecl.isDtorDeclaration() || funcdecl.isInvariantDeclaration() || funcdecl.isNewDeclaration() || funcdecl.isDelete()) funcdecl.error("constructors, destructors, postblits, invariants, new and delete functions are not allowed in interface `%s`", id.toChars()); if (funcdecl.fbody && funcdecl.isVirtual()) @@ -2824,7 +2824,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor goto Ldone; } - if (funcdecl.storage_class & STCabstract) + if (funcdecl.storage_class & STC.abstract_) cd.isabstract = ABSyes; // if static function, do not put in vtbl[] @@ -3164,7 +3164,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor if (funcdecl.isOverride) { - if (funcdecl.storage_class & STCdisable) + if (funcdecl.storage_class & STC.disable) deprecation(funcdecl.loc, "`%s` cannot be annotated with `@disable` because it is overriding a function in the base class", funcdecl.toPrettyChars); @@ -3278,7 +3278,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor } sc = sc.push(); - sc.stc &= ~STCstatic; // not a static constructor + sc.stc &= ~STC.static_; // not a static constructor sc.flags |= SCOPEctor; funcDeclarationSemantic(ctd); @@ -3301,11 +3301,11 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor { if (dim == 0 && tf.varargs == 0) // empty default ctor w/o any varargs { - if (ctd.fbody || !(ctd.storage_class & STCdisable)) + if (ctd.fbody || !(ctd.storage_class & STC.disable)) { ctd.error("default constructor for structs only allowed " ~ "with @disable, no body, and no parameters"); - ctd.storage_class |= STCdisable; + ctd.storage_class |= STC.disable; ctd.fbody = null; } sd.noDefaultCtor = true; @@ -3316,7 +3316,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor else if (dim && Parameter.getNth(tf.parameters, 0).defaultArg) { // if the first parameter has a default argument, then the rest does as well - if (ctd.storage_class & STCdisable) + if (ctd.storage_class & STC.disable) { ctd.deprecation("@disable'd constructor cannot have default "~ "arguments for all parameters."); @@ -3363,7 +3363,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor pbd.type = new TypeFunction(null, Type.tvoid, false, LINKd, pbd.storage_class); sc = sc.push(); - sc.stc &= ~STCstatic; // not static + sc.stc &= ~STC.static_; // not static sc.linkage = LINKd; funcDeclarationSemantic(pbd); @@ -3399,7 +3399,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor dd.type = new TypeFunction(null, Type.tvoid, false, LINKd, dd.storage_class); sc = sc.push(); - sc.stc &= ~STCstatic; // not a static destructor + sc.stc &= ~STC.static_; // not a static destructor if (sc.linkage != LINKcpp) sc.linkage = LINKd; @@ -3445,7 +3445,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor * during static construction. */ auto v = new VarDeclaration(Loc(), Type.tint32, Id.gate, null); - v.storage_class = STCtemp | (scd.isSharedStaticCtorDeclaration() ? STCstatic : STCtls); + v.storage_class = STC.temp | (scd.isSharedStaticCtorDeclaration() ? STC.static_ : STC.tls); auto sa = new Statements(); Statement s = new ExpStatement(Loc(), v); @@ -3513,7 +3513,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor * during static destruction. */ auto v = new VarDeclaration(Loc(), Type.tint32, Id.gate, null); - v.storage_class = STCtemp | (sdd.isSharedStaticDtorDeclaration() ? STCstatic : STCtls); + v.storage_class = STC.temp | (sdd.isSharedStaticDtorDeclaration() ? STC.static_ : STC.tls); auto sa = new Statements(); Statement s = new ExpStatement(Loc(), v); @@ -3575,8 +3575,8 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor invd.type = new TypeFunction(null, Type.tvoid, false, LINKd, invd.storage_class); sc = sc.push(); - sc.stc &= ~STCstatic; // not a static invariant - sc.stc |= STCconst; // invariant() is always const + sc.stc &= ~STC.static_; // not a static invariant + sc.stc |= STC.const_; // invariant() is always const sc.flags = (sc.flags & ~SCOPEcontract) | SCOPEinvariant; sc.linkage = LINKd; @@ -3771,9 +3771,9 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor sd.alignment = sc.alignment(); sd.storage_class |= sc.stc; - if (sd.storage_class & STCdeprecated) + if (sd.storage_class & STC.deprecated_) sd.isdeprecated = true; - if (sd.storage_class & STCabstract) + if (sd.storage_class & STC.abstract_) sd.error("structs, unions cannot be abstract"); sd.userAttribDecl = sc.userAttribDecl; @@ -3996,13 +3996,13 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor cldec.protection = sc.protection; cldec.storage_class |= sc.stc; - if (cldec.storage_class & STCdeprecated) + if (cldec.storage_class & STC.deprecated_) cldec.isdeprecated = true; - if (cldec.storage_class & STCauto) + if (cldec.storage_class & STC.auto_) cldec.error("storage class `auto` is invalid when declaring a class, did you mean to use `scope`?"); - if (cldec.storage_class & STCscope) + if (cldec.storage_class & STC.scope_) cldec.stack = true; - if (cldec.storage_class & STCabstract) + if (cldec.storage_class & STC.abstract_) cldec.isabstract = ABSyes; cldec.userAttribDecl = sc.userAttribDecl; @@ -4229,7 +4229,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor } if (cldec.baseClass) { - if (cldec.baseClass.storage_class & STCfinal) + if (cldec.baseClass.storage_class & STC.final_) cldec.error("cannot inherit from class `%s` because it is `final`", cldec.baseClass.toChars()); // Inherit properties from base class @@ -4240,7 +4240,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor if (cldec.baseClass.stack) cldec.stack = true; cldec.enclosing = cldec.baseClass.enclosing; - cldec.storage_class |= cldec.baseClass.storage_class & STC_TYPECTOR; + cldec.storage_class |= cldec.baseClass.storage_class & STC.TYPECTOR; } cldec.interfaces = cldec.baseclasses.tdata()[(cldec.baseClass ? 1 : 0) .. cldec.baseclasses.dim]; @@ -4349,7 +4349,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor if (cldec.vthis) // if inheriting from nested class { // Use the base class's 'this' member - if (cldec.storage_class & STCstatic) + if (cldec.storage_class & STC.static_) cldec.error("static class cannot inherit from nested class `%s`", cldec.baseClass.toChars()); if (cldec.toParent2() != cldec.baseClass.toParent2() && (!cldec.toParent2() || @@ -4433,7 +4433,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor // A class object is always created by constructor, so this check is legitimate. foreach (v; cldec.fields) { - if (v.storage_class & STCnodefaultctor) + if (v.storage_class & STC.nodefaultctor) error(v.loc, "field `%s` must be initialized in constructor", v.toChars()); } } @@ -4478,7 +4478,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor if (auto f = hasIdentityOpAssign(cldec, sc2)) { - if (!(f.storage_class & STCdisable)) + if (!(f.storage_class & STC.disable)) cldec.error(f.loc, "identity assignment operator overload is illegal"); } @@ -4527,7 +4527,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor } // Verify fields of a synchronized class are not public - if (cldec.storage_class & STCsynchronized) + if (cldec.storage_class & STC.synchronized_) { foreach (vd; cldec.fields) { @@ -4590,7 +4590,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor idec.protection = sc.protection; idec.storage_class |= sc.stc; - if (idec.storage_class & STCdeprecated) + if (idec.storage_class & STC.deprecated_) idec.isdeprecated = true; idec.userAttribDecl = sc.userAttribDecl; @@ -5488,12 +5488,12 @@ void aliasSemantic(AliasDeclaration ds, Scope* sc) Type t; Expression e; Scope* sc2 = sc; - if (ds.storage_class & (STCref | STCnothrow | STCnogc | STCpure | STCdisable)) + if (ds.storage_class & (STC.ref_ | STC.nothrow_ | STC.nogc | STC.pure_ | STC.disable)) { // For 'ref' to be attached to function types, and picked // up by Type.resolve(), it has to go into sc. sc2 = sc.push(); - sc2.stc |= ds.storage_class & (STCref | STCnothrow | STCnogc | STCpure | STCshared | STCdisable); + sc2.stc |= ds.storage_class & (STC.ref_ | STC.nothrow_ | STC.nogc | STC.pure_ | STC.shared_ | STC.disable); } ds.type = ds.type.addSTC(ds.storage_class); ds.type.resolve(ds.loc, sc2, &e, &t, &s); diff --git a/src/dmd/dtemplate.d b/src/dmd/dtemplate.d index 179ce9ec635d..7bba08fcdeba 100644 --- a/src/dmd/dtemplate.d +++ b/src/dmd/dtemplate.d @@ -191,7 +191,7 @@ private Expression getValue(ref Dsymbol s) if (s) { VarDeclaration v = s.isVarDeclaration(); - if (v && v.storage_class & STCmanifest) + if (v && v.storage_class & STC.manifest) { e = v.getConstInitializer(); } @@ -207,7 +207,7 @@ private Expression getValue(Expression e) if (e && e.op == TOKvar) { VarDeclaration v = (cast(VarExp)e).var.isVarDeclaration(); - if (v && v.storage_class & STCmanifest) + if (v && v.storage_class & STC.manifest) { e = v.getConstInitializer(); } @@ -738,10 +738,10 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol for (size_t i = 0; i < nfparams; i++) { Parameter fparam = Parameter.getNth(fparameters, i); - fparam.storageClass &= (STCin | STCout | STCref | STClazy | STCfinal | STC_TYPECTOR | STCnodtor); - fparam.storageClass |= STCparameter; + fparam.storageClass &= (STC.in_ | STC.out_ | STC.ref_ | STC.lazy_ | STC.final_ | STC.TYPECTOR | STC.nodtor); + fparam.storageClass |= STC.parameter; if (fvarargs == 2 && i + 1 == nfparams) - fparam.storageClass |= STCvariadic; + fparam.storageClass |= STC.variadic; } for (size_t i = 0; i < fparameters.dim; i++) { @@ -760,7 +760,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol v.parent = fd; } if (isstatic) - fd.storage_class |= STCstatic; + fd.storage_class |= STC.static_; fd.vthis = fd.declareThis(scx, fd.isThis()); } @@ -1253,7 +1253,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol } } - if (toParent().isModule() || (_scope.stc & STCstatic)) + if (toParent().isModule() || (_scope.stc & STC.static_)) tthis = null; if (tthis) { @@ -1289,15 +1289,15 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol stc |= ad.storage_class; ubyte mod = fd.type.mod; - if (stc & STCimmutable) + if (stc & STC.immutable_) mod = MODimmutable; else { - if (stc & (STCshared | STCsynchronized)) + if (stc & (STC.shared_ | STC.synchronized_)) mod |= MODshared; - if (stc & STCconst) + if (stc & STC.const_) mod |= MODconst; - if (stc & STCwild) + if (stc & STC.wild) mod |= MODwild; } @@ -1371,7 +1371,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol if (farg.op == TOKerror || farg.type.ty == Terror) goto Lnomatch; - if (!(fparam.storageClass & STClazy) && farg.type.ty == Tvoid) + if (!(fparam.storageClass & STC.lazy_) && farg.type.ty == Tvoid) goto Lnomatch; Type tt; @@ -1392,7 +1392,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol /* Remove top const for dynamic array types and pointer types */ - if ((tt.ty == Tarray || tt.ty == Tpointer) && !tt.isMutable() && (!(fparam.storageClass & STCref) || (fparam.storageClass & STCauto) && !farg.isLvalue())) + if ((tt.ty == Tarray || tt.ty == Tpointer) && !tt.isMutable() && (!(fparam.storageClass & STC.ref_) || (fparam.storageClass & STC.auto_) && !farg.isLvalue())) { tt = tt.mutableOf(); } @@ -1568,16 +1568,16 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol } Type argtype = farg.type; - if (!(fparam.storageClass & STClazy) && argtype.ty == Tvoid && farg.op != TOKfunction) + if (!(fparam.storageClass & STC.lazy_) && argtype.ty == Tvoid && farg.op != TOKfunction) goto Lnomatch; // https://issues.dlang.org/show_bug.cgi?id=12876 // Optimize argument to allow CT-known length matching - farg = farg.optimize(WANTvalue, (fparam.storageClass & (STCref | STCout)) != 0); + farg = farg.optimize(WANTvalue, (fparam.storageClass & (STC.ref_ | STC.out_)) != 0); //printf("farg = %s %s\n", farg.type.toChars(), farg.toChars()); RootObject oarg = farg; - if ((fparam.storageClass & STCref) && (!(fparam.storageClass & STCauto) || farg.isLvalue())) + if ((fparam.storageClass & STC.ref_) && (!(fparam.storageClass & STC.auto_) || farg.isLvalue())) { /* Allow expressions that have CT-known boundaries and type [] to match with [dim] */ @@ -1604,7 +1604,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol oarg = argtype; } - else if ((fparam.storageClass & STCout) == 0 && (argtype.ty == Tarray || argtype.ty == Tpointer) && templateParameterLookup(prmtype, parameters) != IDX_NOTFOUND && (cast(TypeIdentifier)prmtype).idents.dim == 0) + else if ((fparam.storageClass & STC.out_) == 0 && (argtype.ty == Tarray || argtype.ty == Tpointer) && templateParameterLookup(prmtype, parameters) != IDX_NOTFOUND && (cast(TypeIdentifier)prmtype).idents.dim == 0) { /* The farg passing to the prmtype always make a copy. Therefore, * we can shrink the set of the deduced type arguments for prmtype @@ -1658,7 +1658,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol } } - if (m > MATCH.nomatch && (fparam.storageClass & (STCref | STCauto)) == STCref) + if (m > MATCH.nomatch && (fparam.storageClass & (STC.ref_ | STC.auto_)) == STC.ref_) { if (!farg.isLvalue()) { @@ -1670,14 +1670,14 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol goto Lnomatch; } } - if (m > MATCH.nomatch && (fparam.storageClass & STCout)) + if (m > MATCH.nomatch && (fparam.storageClass & STC.out_)) { if (!farg.isLvalue()) goto Lnomatch; if (!farg.type.isMutable()) // https://issues.dlang.org/show_bug.cgi?id=11916 goto Lnomatch; } - if (m == MATCH.nomatch && (fparam.storageClass & STClazy) && prmtype.ty == Tvoid && farg.type.ty != Tvoid) + if (m == MATCH.nomatch && (fparam.storageClass & STC.lazy_) && prmtype.ty == Tvoid && farg.type.ty != Tvoid) m = MATCH.convert; if (m != MATCH.nomatch) { @@ -2040,7 +2040,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol TemplateValueParameter tvp = tp.isTemplateValueParameter(); Type t = tvp ? tvp.valType : null; v = new VarDeclaration(loc, t, tp.ident, _init); - v.storage_class = STCmanifest | STCtemplateparameter; + v.storage_class = STC.manifest | STC.templateparameter; d = v; } else if (va) @@ -2056,7 +2056,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol } assert(0); } - d.storage_class |= STCtemplateparameter; + d.storage_class |= STC.templateparameter; if (ta) { @@ -2071,13 +2071,13 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol if (Dsymbol s = t.toDsymbol(sc)) { if (s.isDeprecated()) - d.storage_class |= STCdeprecated; + d.storage_class |= STC.deprecated_; } } else if (sa) { if (sa.isDeprecated()) - d.storage_class |= STCdeprecated; + d.storage_class |= STC.deprecated_; } if (!sc.insert(d)) @@ -3534,7 +3534,7 @@ MATCH deduceType(RootObject o, Scope* sc, Type tparam, TemplateParameters* param if (tparam.ty == Tsarray) { TypeSArray tsa = cast(TypeSArray)tparam; - if (tsa.dim.op == TOKvar && (cast(VarExp)tsa.dim).var.storage_class & STCtemplateparameter) + if (tsa.dim.op == TOKvar && (cast(VarExp)tsa.dim).var.storage_class & STC.templateparameter) { Identifier id = (cast(VarExp)tsa.dim).var.ident; i = templateIdentifierLookup(id, parameters); @@ -3613,7 +3613,7 @@ MATCH deduceType(RootObject o, Scope* sc, Type tparam, TemplateParameters* param // https://issues.dlang.org/show_bug.cgi?id=2579 // Apply function parameter storage classes to parameter types fparam.type = fparam.type.addStorageClass(fparam.storageClass); - fparam.storageClass &= ~(STC_TYPECTOR | STCin); + fparam.storageClass &= ~(STC.TYPECTOR | STC.in_); // https://issues.dlang.org/show_bug.cgi?id=15243 // Resolve parameter type if it's not related with template parameters @@ -3937,7 +3937,7 @@ MATCH deduceType(RootObject o, Scope* sc, Type tparam, TemplateParameters* param /* If it is one of the template parameters for this template, * we should not attempt to interpret it. It already has a value. */ - if (e2.op == TOKvar && ((cast(VarExp)e2).var.storage_class & STCtemplateparameter)) + if (e2.op == TOKvar && ((cast(VarExp)e2).var.storage_class & STC.templateparameter)) { /* * (T:Number!(e2), int e2) @@ -5331,7 +5331,7 @@ extern (C++) final class TemplateValueParameter : TemplateParameter override bool declareParameter(Scope* sc) { auto v = new VarDeclaration(loc, valType, ident, null); - v.storage_class = STCtemplateparameter; + v.storage_class = STC.templateparameter; return sc.insert(v) !is null; } @@ -5483,7 +5483,7 @@ extern (C++) final class TemplateValueParameter : TemplateParameter { Initializer _init = new ExpInitializer(loc, ei); Declaration sparam = new VarDeclaration(loc, vt, ident, _init); - sparam.storage_class = STCmanifest; + sparam.storage_class = STC.manifest; *psparam = sparam; } return dependent ? MATCH.exact : m; @@ -5701,7 +5701,7 @@ extern (C++) final class TemplateAliasParameter : TemplateParameter // Declare manifest constant Initializer _init = new ExpInitializer(loc, ea); auto v = new VarDeclaration(loc, null, ident, _init); - v.storage_class = STCmanifest; + v.storage_class = STC.manifest; v.dsymbolSemantic(sc); *psparam = v; } @@ -6151,7 +6151,7 @@ extern (C++) class TemplateInstance : ScopeDsymbol for (size_t j = 0; j < nfparams; j++) { Parameter fparam = Parameter.getNth(fparameters, j); - if (fparam.storageClass & STCautoref) // if "auto ref" + if (fparam.storageClass & STC.autoref) // if "auto ref" { if (!fargs) goto Lnotequals; @@ -6160,12 +6160,12 @@ extern (C++) class TemplateInstance : ScopeDsymbol Expression farg = (*fargs)[j]; if (farg.isLvalue()) { - if (!(fparam.storageClass & STCref)) + if (!(fparam.storageClass & STC.ref_)) goto Lnotequals; // auto ref's don't match } else { - if (fparam.storageClass & STCref) + if (fparam.storageClass & STC.ref_) goto Lnotequals; // auto ref's don't match } } @@ -6651,7 +6651,7 @@ extern (C++) class TemplateInstance : ScopeDsymbol ea = ea.expressionSemantic(sc); // must not interpret the args, excepting template parameters - if (ea.op != TOKvar || ((cast(VarExp)ea).var.storage_class & STCtemplateparameter)) + if (ea.op != TOKvar || ((cast(VarExp)ea).var.storage_class & STC.templateparameter)) { ea = ea.optimize(WANTvalue); } @@ -7098,7 +7098,7 @@ extern (C++) class TemplateInstance : ScopeDsymbol foreach (size_t i; 0 .. dim) { // 'auto ref' needs inference. - if (Parameter.getNth(tf.parameters, i).storageClass & STCauto) + if (Parameter.getNth(tf.parameters, i).storageClass & STC.auto_) return 1; } } @@ -7220,7 +7220,7 @@ extern (C++) class TemplateInstance : ScopeDsymbol } TemplateInstance ti = sa.isTemplateInstance(); Declaration d = sa.isDeclaration(); - if ((td && td.literal) || (ti && ti.enclosing) || (d && !d.isDataseg() && !(d.storage_class & STCmanifest) && (!d.isFuncDeclaration() || d.isFuncDeclaration().isNested()) && !isTemplateMixin())) + if ((td && td.literal) || (ti && ti.enclosing) || (d && !d.isDataseg() && !(d.storage_class & STC.manifest) && (!d.isFuncDeclaration() || d.isFuncDeclaration().isNested()) && !isTemplateMixin())) { // if module level template if (isstatic) @@ -7571,7 +7571,7 @@ bool definitelyValueParameter(Expression e) // https://issues.dlang.org/show_bug.cgi?id=16685 // var.x.y where var is a constant available at compile time - if (v.storage_class & STCmanifest) + if (v.storage_class & STC.manifest) return true; // TODO: Should we force CTFE if it is a global constant? diff --git a/src/dmd/e2ir.d b/src/dmd/e2ir.d index 1555f7b043fb..31e550b1f916 100644 --- a/src/dmd/e2ir.d +++ b/src/dmd/e2ir.d @@ -90,7 +90,7 @@ void* mem_malloc2(uint); bool ISREF(Declaration var) { return (config.exe == EX_WIN64 && var.isParameter() && - (var.type.size(Loc()) > REGSIZE || var.storage_class & STClazy)) + (var.type.size(Loc()) > REGSIZE || var.storage_class & STC.lazy_)) || var.isOut() || var.isRef(); } @@ -99,7 +99,7 @@ bool ISREF(Declaration var) bool ISWIN64REF(Declaration var) { return (config.exe == EX_WIN64 && var.isParameter() && - (var.type.size(Loc()) > REGSIZE || var.storage_class & STClazy)) + (var.type.size(Loc()) > REGSIZE || var.storage_class & STC.lazy_)) && !(var.isOut() || var.isRef()); } @@ -208,7 +208,7 @@ private elem *callfunc(Loc loc, { Parameter p = Parameter.getNth(tf.parameters, i - j); - if (p.storageClass & (STCout | STCref)) + if (p.storageClass & (STC.out_ | STC.ref_)) { // Convert argument to a pointer ea = addressElem(ea, arg.type.pointerTo()); @@ -1250,7 +1250,7 @@ elem *toElem(Expression e, IRState *irs) } tym_t tym; - if (se.var.storage_class & STClazy) + if (se.var.storage_class & STC.lazy_) tym = TYdelegate; // Tdelegate as C type else if (tb.ty == Tfunction) tym = s.Stype.Tty; @@ -2829,7 +2829,7 @@ elem *toElem(Expression e, IRState *irs) VarExp ve = cast(VarExp)ae.e1; Declaration d = ve.var; - if (d.storage_class & (STCout | STCref)) + if (d.storage_class & (STC.out_ | STC.ref_)) { e = toElem(ae.e2, irs); e = addressElem(e, ae.e2.type); @@ -2874,7 +2874,7 @@ elem *toElem(Expression e, IRState *irs) } // inlining may generate lazy variable initialization - if (ae.e1.op == TOKvar && ((cast(VarExp)ae.e1).var.storage_class & STClazy)) + if (ae.e1.op == TOKvar && ((cast(VarExp)ae.e1).var.storage_class & STC.lazy_)) { assert(ae.op == TOKconstruct || ae.op == TOKblit); e = el_bin(OPeq, tym, e1, toElem(ae.e2, irs)); @@ -3538,7 +3538,7 @@ elem *toElem(Expression e, IRState *irs) if (tb1.ty != Tclass && tb1.ty != Tpointer) e = addressElem(e, tb1); e = el_bin(OPadd, TYnptr, e, el_long(TYsize_t, v.offset)); - if (v.storage_class & (STCout | STCref)) + if (v.storage_class & (STC.out_ | STC.ref_)) e = el_una(OPind, TYnptr, e); e = el_una(OPind, totym(dve.type), e); if (tybasic(e.Ety) == TYstruct) @@ -4822,7 +4822,7 @@ elem *toElem(Expression e, IRState *irs) } else if (t1.ty == Tarray) { - if (se.lengthVar && !(se.lengthVar.storage_class & STCconst)) + if (se.lengthVar && !(se.lengthVar.storage_class & STC.const_)) elen = el_var(toSymbol(se.lengthVar)); else { @@ -5136,9 +5136,9 @@ elem *toElem(Expression e, IRState *irs) s = s.toAlias(); if (s != vd) return Dsymbol_toElem(s); - if (vd.storage_class & STCmanifest) + if (vd.storage_class & STC.manifest) return null; - else if (vd.isStatic() || vd.storage_class & (STCextern | STCtls | STCgshared)) + else if (vd.isStatic() || vd.storage_class & (STC.extern_ | STC.tls | STC.gshared)) toObjFile(vd, false); else { diff --git a/src/dmd/escape.d b/src/dmd/escape.d index b2ca0cd6c9f4..d9dc20429225 100644 --- a/src/dmd/escape.d +++ b/src/dmd/escape.d @@ -84,13 +84,13 @@ bool checkParamArgumentEscape(Scope* sc, FuncDeclaration fdc, Identifier par, Ex Dsymbol p = v.toParent2(); - v.storage_class &= ~STCmaybescope; + v.storage_class &= ~STC.maybescope; if (v.isScope()) { unsafeAssign(v, "scope variable"); } - else if (v.storage_class & STCvariadic && p == sc.func) + else if (v.storage_class & STC.variadic && p == sc.func) { Type tb = v.type.toBasetype(); if (tb.ty == Tarray || tb.ty == Tsarray) @@ -114,9 +114,9 @@ bool checkParamArgumentEscape(Scope* sc, FuncDeclaration fdc, Identifier par, Ex Dsymbol p = v.toParent2(); - v.storage_class &= ~STCmaybescope; + v.storage_class &= ~STC.maybescope; - if ((v.storage_class & (STCref | STCout)) == 0 && p == sc.func) + if ((v.storage_class & (STC.ref_ | STC.out_)) == 0 && p == sc.func) { unsafeAssign(v, "reference to local variable"); continue; @@ -136,9 +136,9 @@ bool checkParamArgumentEscape(Scope* sc, FuncDeclaration fdc, Identifier par, Ex Dsymbol p = v.toParent2(); - v.storage_class &= ~STCmaybescope; + v.storage_class &= ~STC.maybescope; - if ((v.storage_class & (STCref | STCout | STCscope)) && p == sc.func) + if ((v.storage_class & (STC.ref_ | STC.out_ | STC.scope_)) && p == sc.func) { unsafeAssign(v, "reference to local"); continue; @@ -246,11 +246,11 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag) Dsymbol p = v.toParent2(); if (!(va && va.isScope())) - v.storage_class &= ~STCmaybescope; + v.storage_class &= ~STC.maybescope; if (v.isScope()) { - if (va && va.isScope() && va.storage_class & STCreturn && !(v.storage_class & STCreturn) && + if (va && va.isScope() && va.storage_class & STC.return_ && !(v.storage_class & STC.return_) && sc.func.setUnsafe()) { if (!gag) @@ -261,10 +261,10 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag) // If va's lifetime encloses v's, then error if (va && - (va.enclosesLifetimeOf(v) && !(v.storage_class & (STCparameter | STCtemp)) || + (va.enclosesLifetimeOf(v) && !(v.storage_class & (STC.parameter | STC.temp)) || // va is class reference ae.e1.op == TOKdotvar && va.type.toBasetype().ty == Tclass && (va.enclosesLifetimeOf(v) || !va.isScope) || - va.storage_class & STCref && !(v.storage_class & STCtemp)) && + va.storage_class & STC.ref_ && !(v.storage_class & STC.temp)) && sc.func.setUnsafe()) { if (!gag) @@ -277,8 +277,8 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag) { if (!va.isScope() && inferScope) { //printf("inferring scope for %s\n", va.toChars()); - va.storage_class |= STCscope | STCscopeinferred; - va.storage_class |= v.storage_class & STCreturn; + va.storage_class |= STC.scope_ | STC.scopeinferred; + va.storage_class |= v.storage_class & STC.return_; } continue; } @@ -289,7 +289,7 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag) result = true; } } - else if (v.storage_class & STCvariadic && p == sc.func) + else if (v.storage_class & STC.variadic && p == sc.func) { Type tb = v.type.toBasetype(); if (tb.ty == Tarray || tb.ty == Tsarray) @@ -298,7 +298,7 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag) { if (!va.isScope() && inferScope) { //printf("inferring scope for %s\n", va.toChars()); - va.storage_class |= STCscope | STCscopeinferred; + va.storage_class |= STC.scope_ | STC.scopeinferred; } continue; } @@ -330,8 +330,8 @@ ByRef: // If va's lifetime encloses v's, then error if (va && - (va.enclosesLifetimeOf(v) && !(v.storage_class & STCparameter) || - va.storage_class & STCref || + (va.enclosesLifetimeOf(v) && !(v.storage_class & STC.parameter) || + va.storage_class & STC.ref_ || va.isDataseg()) && sc.func.setUnsafe()) { @@ -341,7 +341,7 @@ ByRef: continue; } - if (va && v.storage_class & (STCref | STCout)) + if (va && v.storage_class & (STC.ref_ | STC.out_)) { Dsymbol pva = va.toParent2(); for (Dsymbol pv = p; pv; ) @@ -362,15 +362,15 @@ ByRef: } if (!(va && va.isScope())) - v.storage_class &= ~STCmaybescope; + v.storage_class &= ~STC.maybescope; - if ((v.storage_class & (STCref | STCout)) == 0 && p == sc.func) + if ((v.storage_class & (STC.ref_ | STC.out_)) == 0 && p == sc.func) { if (va && !va.isDataseg() && !va.doNotInferScope) { if (!va.isScope() && inferScope) { //printf("inferring scope for %s\n", va.toChars()); - va.storage_class |= STCscope | STCscopeinferred; + va.storage_class |= STC.scope_ | STC.scopeinferred; } continue; } @@ -398,17 +398,17 @@ ByRef: Dsymbol p = v.toParent2(); if (!(va && va.isScope())) - v.storage_class &= ~STCmaybescope; + v.storage_class &= ~STC.maybescope; - if ((v.storage_class & (STCref | STCout | STCscope)) && p == sc.func) + if ((v.storage_class & (STC.ref_ | STC.out_ | STC.scope_)) && p == sc.func) { if (va && !va.isDataseg() && !va.doNotInferScope) { - /* Don't infer STCscope for va, because then a closure + /* Don't infer STC.scope_ for va, because then a closure * won't be generated for sc.func. */ //if (!va.isScope() && inferScope) - //va.storage_class |= STCscope | STCscopeinferred; + //va.storage_class |= STC.scope_ | STC.scopeinferred; continue; } if (sc.func.setUnsafe()) @@ -429,7 +429,7 @@ ByRef: /* Do not allow slicing of a static array returned by a function */ if (va && ee.op == TOKcall && ee.type.toBasetype().ty == Tsarray && va.type.toBasetype().ty == Tarray && - !(va.storage_class & STCtemp)) + !(va.storage_class & STC.temp)) { if (!gag) deprecation(ee.loc, "slice of static array temporary returned by `%s` assigned to longer lived variable `%s`", @@ -442,7 +442,7 @@ ByRef: { if (!va.isScope() && inferScope) { //printf("inferring scope for %s\n", va.toChars()); - va.storage_class |= STCscope | STCscopeinferred; + va.storage_class |= STC.scope_ | STC.scopeinferred; } continue; } @@ -576,8 +576,8 @@ private bool checkReturnEscapeImpl(Scope* sc, Expression e, bool refs, bool gag) Dsymbol p = v.toParent2(); - if ((v.isScope() || (v.storage_class & STCmaybescope)) && - !(v.storage_class & STCreturn) && + if ((v.isScope() || (v.storage_class & STC.maybescope)) && + !(v.storage_class & STC.return_) && v.isParameter() && sc.func.flags & FUNCFLAG.returnInprocess && p == sc.func) @@ -588,7 +588,7 @@ private bool checkReturnEscapeImpl(Scope* sc, Expression e, bool refs, bool gag) if (v.isScope()) { - if (v.storage_class & STCreturn) + if (v.storage_class & STC.return_) continue; if (sc._module && sc._module.isRoot() && @@ -613,7 +613,7 @@ private bool checkReturnEscapeImpl(Scope* sc, Expression e, bool refs, bool gag) continue; } } - else if (v.storage_class & STCvariadic && p == sc.func) + else if (v.storage_class & STC.variadic && p == sc.func) { Type tb = v.type.toBasetype(); if (tb.ty == Tarray || tb.ty == Tsarray) @@ -639,7 +639,7 @@ private bool checkReturnEscapeImpl(Scope* sc, Expression e, bool refs, bool gag) if (!gag) { const(char)* msg; - if (v.storage_class & STCparameter) + if (v.storage_class & STC.parameter) msg = "returning `%s` escapes a reference to parameter `%s`, perhaps annotate with `return`"; else msg = "returning `%s` escapes a reference to local variable `%s`"; @@ -653,7 +653,7 @@ private bool checkReturnEscapeImpl(Scope* sc, Expression e, bool refs, bool gag) Dsymbol p = v.toParent2(); - if ((v.storage_class & (STCref | STCout)) == 0) + if ((v.storage_class & (STC.ref_ | STC.out_)) == 0) { if (p == sc.func) { @@ -671,7 +671,7 @@ private bool checkReturnEscapeImpl(Scope* sc, Expression e, bool refs, bool gag) * Because dg.ptr points to x, this is returning dt.ptr+offset */ if (global.params.vsafe) - sc.func.storage_class |= STCreturn; + sc.func.storage_class |= STC.return_; } } @@ -679,8 +679,8 @@ private bool checkReturnEscapeImpl(Scope* sc, Expression e, bool refs, bool gag) /* Check for returning a ref variable by 'ref', but should be 'return ref' * Infer the addition of 'return', or set result to be the offending expression. */ - if ( (v.storage_class & (STCref | STCout)) && - !(v.storage_class & (STCreturn | STCforeach))) + if ( (v.storage_class & (STC.ref_ | STC.out_)) && + !(v.storage_class & (STC.return_ | STC.foreach_))) { if (sc.func.flags & FUNCFLAG.returnInprocess && p == sc.func) { @@ -732,7 +732,7 @@ private bool checkReturnEscapeImpl(Scope* sc, Expression e, bool refs, bool gag) * Variable v needs to have 'return' inferred for it. * Params: * fd = function that v is a parameter to - * v = parameter that needs to be STCreturn + * v = parameter that needs to be STC.return_ */ private void inferReturn(FuncDeclaration fd, VarDeclaration v) @@ -740,14 +740,14 @@ private void inferReturn(FuncDeclaration fd, VarDeclaration v) // v is a local in the current function //printf("for function '%s' inferring 'return' for variable '%s'\n", fd.toChars(), v.toChars()); - v.storage_class |= STCreturn; + v.storage_class |= STC.return_; TypeFunction tf = cast(TypeFunction)fd.type; if (v == fd.vthis) { /* v is the 'this' reference, so mark the function */ - fd.storage_class |= STCreturn; + fd.storage_class |= STC.return_; if (tf.ty == Tfunction) { //printf("'this' too %p %s\n", tf, sc.func.toChars()); @@ -765,7 +765,7 @@ private void inferReturn(FuncDeclaration fd, VarDeclaration v) Parameter p = Parameter.getNth(tf.parameters, i); if (p.ident == v.ident) { - p.storageClass |= STCreturn; + p.storageClass |= STC.return_; break; // there can be only one } } @@ -923,7 +923,7 @@ private void escapeByValue(Expression e, EscapeByResults* er) { if (tb.ty == Tsarray) return; - if (v.storage_class & STCvariadic) + if (v.storage_class & STC.variadic) { er.byvalue.push(v); return; @@ -1013,9 +1013,9 @@ private void escapeByValue(Expression e, EscapeByResults* er) { Parameter p = Parameter.getNth(tf.parameters, i - j); const stc = tf.parameterStorageClass(p); - if ((stc & (STCscope)) && (stc & STCreturn)) + if ((stc & (STC.scope_)) && (stc & STC.return_)) arg.accept(this); - else if ((stc & (STCref)) && (stc & STCreturn)) + else if ((stc & (STC.ref_)) && (stc & STC.return_)) escapeByRef(arg, er); } } @@ -1033,11 +1033,11 @@ private void escapeByValue(Expression e, EscapeByResults* er) else if (ad.isStructDeclaration()) // this is 'return ref' escapeByRef(dve.e1, er); } - else if (dve.var.storage_class & STCreturn || tf.isreturn) + else if (dve.var.storage_class & STC.return_ || tf.isreturn) { - if (dve.var.storage_class & STCscope) + if (dve.var.storage_class & STC.scope_) dve.e1.accept(this); - else if (dve.var.storage_class & STCref) + else if (dve.var.storage_class & STC.ref_) escapeByRef(dve.e1, er); } } @@ -1098,7 +1098,7 @@ private void escapeByRef(Expression e, EscapeByResults* er) auto v = e.var.isVarDeclaration(); if (v) { - if (v.storage_class & STCref && v.storage_class & (STCforeach | STCtemp) && v._init) + if (v.storage_class & STC.ref_ && v.storage_class & (STC.foreach_ | STC.temp) && v._init) { /* If compiler generated ref temporary * (ref v = ex; ex) @@ -1135,7 +1135,7 @@ private void escapeByRef(Expression e, EscapeByResults* er) VarDeclaration v = (cast(VarExp)e.e1).var.isVarDeclaration(); if (tb.ty == Tarray || tb.ty == Tsarray) { - if (v && v.storage_class & STCvariadic) + if (v && v.storage_class & STC.variadic) { er.byref.push(v); return; @@ -1211,9 +1211,9 @@ private void escapeByRef(Expression e, EscapeByResults* er) { Parameter p = Parameter.getNth(tf.parameters, i - j); const stc = tf.parameterStorageClass(p); - if ((stc & (STCout | STCref)) && (stc & STCreturn)) + if ((stc & (STC.out_ | STC.ref_)) && (stc & STC.return_)) arg.accept(this); - else if ((stc & STCscope) && (stc & STCreturn)) + else if ((stc & STC.scope_) && (stc & STC.return_)) { if (arg.op == TOKdelegate) { @@ -1231,11 +1231,11 @@ private void escapeByRef(Expression e, EscapeByResults* er) if (e.e1.op == TOKdotvar && t1.ty == Tfunction) { DotVarExp dve = cast(DotVarExp)e.e1; - if (dve.var.storage_class & STCreturn || tf.isreturn) + if (dve.var.storage_class & STC.return_ || tf.isreturn) { - if (dve.var.storage_class & STCscope || tf.isscope) + if (dve.var.storage_class & STC.scope_ || tf.isscope) escapeByValue(dve.e1, er); - else if (dve.var.storage_class & STCref || tf.isref) + else if (dve.var.storage_class & STC.ref_ || tf.isref) dve.e1.accept(this); } } diff --git a/src/dmd/expression.d b/src/dmd/expression.d index a1f5e11029e1..9ecc1d56ee0b 100644 --- a/src/dmd/expression.d +++ b/src/dmd/expression.d @@ -194,7 +194,7 @@ Lagain: //printf("s = '%s', s.kind = '%s'\n", s.toChars(), s.kind()); Dsymbol olds = s; Declaration d = s.isDeclaration(); - if (d && (d.storage_class & STCtemplateparameter)) + if (d && (d.storage_class & STC.templateparameter)) { s = s.toAlias(); } @@ -239,7 +239,7 @@ Lagain: if (v.type.ty == Terror) return new ErrorExp(); - if ((v.storage_class & STCmanifest) && v._init) + if ((v.storage_class & STC.manifest) && v._init) { if (v.inuse) { @@ -353,7 +353,7 @@ Lagain: Dsymbol p = td.toParent2(); FuncDeclaration fdthis = hasThis(sc); AggregateDeclaration ad = p ? p.isAggregateDeclaration() : null; - if (fdthis && ad && isAggregate(fdthis.vthis.type) == ad && (td._scope.stc & STCstatic) == 0) + if (fdthis && ad && isAggregate(fdthis.vthis.type) == ad && (td._scope.stc & STC.static_) == 0) { e = new DotTemplateExp(loc, new ThisExp(loc), td); } @@ -534,7 +534,7 @@ extern (C++) Expression resolvePropertiesOnly(Scope* sc, Expression e1) } else if (td && td.onemember && (fd = td.onemember.isFuncDeclaration()) !is null) { - if ((cast(TypeFunction)fd.type).isproperty || (fd.storage_class2 & STCproperty) || (td._scope.stc & STCproperty)) + if ((cast(TypeFunction)fd.type).isproperty || (fd.storage_class2 & STC.property) || (td._scope.stc & STC.property)) { return resolveProperties(sc, e1); } @@ -569,7 +569,7 @@ extern (C++) Expression resolvePropertiesOnly(Scope* sc, Expression e1) assert(td); if (td.onemember && (fd = td.onemember.isFuncDeclaration()) !is null) { - if ((cast(TypeFunction)fd.type).isproperty || (fd.storage_class2 & STCproperty) || (td._scope.stc & STCproperty)) + if ((cast(TypeFunction)fd.type).isproperty || (fd.storage_class2 & STC.property) || (td._scope.stc & STC.property)) { return resolveProperties(sc, e1); } @@ -1110,7 +1110,7 @@ extern (C++) Expression valueNoDtor(Expression e) VarDeclaration ctmp = ve.var.isVarDeclaration(); if (ctmp) { - ctmp.storage_class |= STCnodtor; + ctmp.storage_class |= STC.nodtor; assert(!ce.isLvalue()); } } @@ -1121,9 +1121,9 @@ extern (C++) Expression valueNoDtor(Expression e) else if (ex.op == TOKvar) { auto vtmp = (cast(VarExp)ex).var.isVarDeclaration(); - if (vtmp && (vtmp.storage_class & STCrvalue)) + if (vtmp && (vtmp.storage_class & STC.rvalue)) { - vtmp.storage_class |= STCnodtor; + vtmp.storage_class |= STC.nodtor; } } return e; @@ -1150,8 +1150,8 @@ private Expression callCpCtor(Scope* sc, Expression e) * This is not the most efficient, ideally tmp would be constructed * directly onto the stack. */ - auto tmp = copyToTemp(STCrvalue, "__copytmp", e); - tmp.storage_class |= STCnodtor; + auto tmp = copyToTemp(STC.rvalue, "__copytmp", e); + tmp.storage_class |= STC.nodtor; tmp.dsymbolSemantic(sc); Expression de = new DeclarationExp(e.loc, tmp); Expression ve = new VarExp(e.loc, tmp); @@ -1345,7 +1345,7 @@ private Expression extractOpDollarSideEffect(Scope* sc, UnaExp ue) e1 = extractSideEffect(sc, "__dop", e0, e1, false); assert(e1.op == TOKvar); VarExp ve = cast(VarExp)e1; - ve.var.storage_class |= STCexptemp; // lifetime limited to expression + ve.var.storage_class |= STC.exptemp; // lifetime limited to expression } ue.e1 = e1; return e0; @@ -2049,7 +2049,7 @@ extern (C++) abstract class Expression : RootObject return false; // always safe and pure to access immutables... if (v.isConst() && !v.isRef() && (v.isDataseg() || v.isParameter()) && v.type.implicitConvTo(v.type.immutableOf())) return false; // or const global/parameter values which have no mutable indirections - if (v.storage_class & STCmanifest) + if (v.storage_class & STC.manifest) return false; // ...or manifest constants bool err = false; @@ -2150,7 +2150,7 @@ extern (C++) abstract class Expression : RootObject /* Do not allow safe functions to access __gshared data */ - if (v.storage_class & STCgshared) + if (v.storage_class & STC.gshared) { if (sc.func.setUnsafe()) { @@ -4216,19 +4216,19 @@ extern (C++) final class VarExp : SymbolExp override bool isLvalue() { - if (var.storage_class & (STClazy | STCrvalue | STCmanifest)) + if (var.storage_class & (STC.lazy_ | STC.rvalue | STC.manifest)) return false; return true; } override Expression toLvalue(Scope* sc, Expression e) { - if (var.storage_class & STCmanifest) + if (var.storage_class & STC.manifest) { error("manifest constant '%s' is not lvalue", var.toChars()); return new ErrorExp(); } - if (var.storage_class & STClazy) + if (var.storage_class & STC.lazy_) { error("lazy variables cannot be lvalues"); return new ErrorExp(); @@ -4249,7 +4249,7 @@ extern (C++) final class VarExp : SymbolExp override Expression modifiableLvalue(Scope* sc, Expression e) { //printf("VarExp::modifiableLvalue('%s')\n", var.toChars()); - if (var.storage_class & STCmanifest) + if (var.storage_class & STC.manifest) { error("cannot modify manifest constant '%s'", toChars()); return new ErrorExp(); @@ -4498,7 +4498,7 @@ extern (C++) final class FuncExp : Expression */ convertMatch = true; - auto tfy = new TypeFunction(tfx.parameters, tof.next, tfx.varargs, tfx.linkage, STCundefined); + auto tfy = new TypeFunction(tfx.parameters, tof.next, tfx.varargs, tfx.linkage, STC.undefined_); tfy.mod = tfx.mod; tfy.isnothrow = tfx.isnothrow; tfy.isnogc = tfx.isnogc; @@ -4608,7 +4608,7 @@ extern (C++) final class DeclarationExp : Expression { if (auto vd = declaration.isVarDeclaration()) { - return !(vd.storage_class & (STCmanifest | STCstatic)); + return !(vd.storage_class & (STC.manifest | STC.static_)); } return false; } @@ -6266,7 +6266,7 @@ extern (C++) final class PreExp : UnaExp enum MemorySet { blockAssign = 1, // setting the contents of an array - referenceInit = 2, // setting the reference of STCref variable + referenceInit = 2, // setting the reference of STC.ref_ variable } /*********************************************************** @@ -6343,7 +6343,7 @@ extern (C++) final class ConstructExp : AssignExp super(loc, ve, e2); op = TOKconstruct; - if (v.storage_class & (STCref | STCout)) + if (v.storage_class & (STC.ref_ | STC.out_)) memset |= MemorySet.referenceInit; } @@ -6373,7 +6373,7 @@ extern (C++) final class BlitExp : AssignExp super(loc, ve, e2); op = TOKblit; - if (v.storage_class & (STCref | STCout)) + if (v.storage_class & (STC.ref_ | STC.out_)) memset |= MemorySet.referenceInit; } @@ -7004,7 +7004,7 @@ extern (C++) final class CondExp : BinExp { if (!vcond) { - vcond = copyToTemp(STCvolatile, "__cond", ce.econd); + vcond = copyToTemp(STC.volatile_, "__cond", ce.econd); vcond.dsymbolSemantic(sc); Expression de = new DeclarationExp(ce.econd.loc, vcond); diff --git a/src/dmd/expressionsem.d b/src/dmd/expressionsem.d index f60128b71a6b..f3fcbf4a91ee 100644 --- a/src/dmd/expressionsem.d +++ b/src/dmd/expressionsem.d @@ -284,7 +284,7 @@ private Expression resolvePropertiesX(Scope* sc, Expression e1, Expression e2 = if (e1.op == TOKvar) { VarExp ve = cast(VarExp)e1; - if (ve.var.storage_class & STClazy) + if (ve.var.storage_class & STC.lazy_) { Expression e = new CallExp(loc, e1); return e.expressionSemantic(sc); @@ -697,9 +697,9 @@ private bool functionParameters(Loc loc, Scope* sc, TypeFunction tf, Type tthis, } L1: - if (!(p.storageClass & STClazy && p.type.ty == Tvoid)) + if (!(p.storageClass & STC.lazy_ && p.type.ty == Tvoid)) { - bool isRef = (p.storageClass & (STCref | STCout)) != 0; + bool isRef = (p.storageClass & (STC.ref_ | STC.out_)) != 0; if (ubyte wm = arg.type.deduceWild(p.type, isRef)) { if (wildmatch) @@ -766,7 +766,7 @@ private bool functionParameters(Loc loc, Scope* sc, TypeFunction tf, Type tthis, if (i < nparams) { Parameter p = Parameter.getNth(tf.parameters, i); - if (!(p.storageClass & STClazy && p.type.ty == Tvoid)) + if (!(p.storageClass & STC.lazy_ && p.type.ty == Tvoid)) { Type tprm = p.type; if (p.type.hasWild()) @@ -775,17 +775,17 @@ private bool functionParameters(Loc loc, Scope* sc, TypeFunction tf, Type tthis, { //printf("arg.type = %s, p.type = %s\n", arg.type.toChars(), p.type.toChars()); arg = arg.implicitCastTo(sc, tprm); - arg = arg.optimize(WANTvalue, (p.storageClass & (STCref | STCout)) != 0); + arg = arg.optimize(WANTvalue, (p.storageClass & (STC.ref_ | STC.out_)) != 0); } } - if (p.storageClass & STCref) + if (p.storageClass & STC.ref_) { arg = arg.toLvalue(sc, arg); // Look for mutable misaligned pointer, etc., in @safe mode err |= checkUnsafeAccess(sc, arg, false, true); } - else if (p.storageClass & STCout) + else if (p.storageClass & STC.out_) { Type t = arg.type; if (!t.isMutable() || !t.isAssignable()) // check blit assignable @@ -801,7 +801,7 @@ private bool functionParameters(Loc loc, Scope* sc, TypeFunction tf, Type tthis, } arg = arg.toLvalue(sc, arg); } - else if (p.storageClass & STClazy) + else if (p.storageClass & STC.lazy_) { // Convert lazy argument to a delegate if (p.type.ty == Tvoid) @@ -854,7 +854,7 @@ private bool functionParameters(Loc loc, Scope* sc, TypeFunction tf, Type tthis, } } } - arg = arg.optimize(WANTvalue, (p.storageClass & (STCref | STCout)) != 0); + arg = arg.optimize(WANTvalue, (p.storageClass & (STC.ref_ | STC.out_)) != 0); } else { @@ -970,7 +970,7 @@ private bool functionParameters(Loc loc, Scope* sc, TypeFunction tf, Type tthis, if (firstdtor == -1 && arg.type.needsDestruction()) { Parameter p = (i >= nparams ? null : Parameter.getNth(tf.parameters, i)); - if (!(p && (p.storageClass & (STClazy | STCref | STCout)))) + if (!(p && (p.storageClass & (STC.lazy_ | STC.ref_ | STC.out_)))) firstdtor = i; } } @@ -988,7 +988,7 @@ private bool functionParameters(Loc loc, Scope* sc, TypeFunction tf, Type tthis, // eprefix => bool __gate [= false] Identifier idtmp = Identifier.generateId("__gate"); gate = new VarDeclaration(loc, Type.tbool, idtmp, null); - gate.storage_class |= STCtemp | STCctfe | STCvolatile; + gate.storage_class |= STC.temp | STC.ctfe | STC.volatile_; gate.dsymbolSemantic(sc); auto ae = new DeclarationExp(loc, gate); @@ -1000,8 +1000,8 @@ private bool functionParameters(Loc loc, Scope* sc, TypeFunction tf, Type tthis, Expression arg = (*arguments)[i]; Parameter parameter = (i >= nparams ? null : Parameter.getNth(tf.parameters, i)); - const bool isRef = (parameter && (parameter.storageClass & (STCref | STCout))); - const bool isLazy = (parameter && (parameter.storageClass & STClazy)); + const bool isRef = (parameter && (parameter.storageClass & (STC.ref_ | STC.out_))); + const bool isLazy = (parameter && (parameter.storageClass & STC.lazy_)); /* Skip lazy parameters */ @@ -1099,7 +1099,7 @@ private bool functionParameters(Loc loc, Scope* sc, TypeFunction tf, Type tthis, args.setDim(arguments.dim - nparams); for (size_t i = 0; i < arguments.dim - nparams; i++) { - auto arg = new Parameter(STCin, (*arguments)[nparams + i].type, null, null); + auto arg = new Parameter(STC.in_, (*arguments)[nparams + i].type, null, null); (*args)[i] = arg; } auto tup = new TypeTuple(args); @@ -1343,7 +1343,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor // Create the magic __ctfe bool variable auto vd = new VarDeclaration(exp.loc, Type.tbool, Id.ctfe, null); - vd.storage_class |= STCtemp; + vd.storage_class |= STC.temp; vd.semanticRun = PASSsemanticdone; Expression e = new VarExp(exp.loc, vd); e = e.expressionSemantic(sc); @@ -1894,7 +1894,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor Dsymbol p = td.toParent2(); FuncDeclaration fdthis = hasThis(sc); AggregateDeclaration ad = p ? p.isAggregateDeclaration() : null; - if (fdthis && ad && isAggregate(fdthis.vthis.type) == ad && (td._scope.stc & STCstatic) == 0) + if (fdthis && ad && isAggregate(fdthis.vthis.type) == ad && (td._scope.stc & STC.static_) == 0) { Expression e = new DotTemplateInstanceExp(exp.loc, new ThisExp(exp.loc), ti.name, ti.tiargs); result = e.expressionSemantic(sc); @@ -1945,7 +1945,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor exp.error("forward reference of %s %s", v.kind(), v.toChars()); return setError(); } - if ((v.storage_class & STCmanifest) && v._init) + if ((v.storage_class & STC.manifest) && v._init) { /* When an instance that will be converted to a constant exists, * the instance representation "foo!tiargs" is treated like a @@ -2920,12 +2920,12 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (exp.e1.op == TOKvar) { VarExp ve = cast(VarExp)exp.e1; - if (ve.var.storage_class & STClazy) + if (ve.var.storage_class & STC.lazy_) { // lazy parameters can be called without violating purity and safety Type tw = ve.var.type; Type tc = ve.var.type.substWildTo(MODconst); - auto tf = new TypeFunction(null, tc, 0, LINKd, STCsafe | STCpure); + auto tf = new TypeFunction(null, tc, 0, LINKd, STC.safe | STC.pure_); (tf = cast(TypeFunction)tf.typeSemantic(exp.loc, sc)).next = tw; // hack for bug7757 auto t = new TypeDelegate(tf); ve.type = t.typeSemantic(exp.loc, sc); @@ -3244,7 +3244,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor } else if (ue.e1.op == TOKsuper) exp.directcall = true; - else if ((cd.storage_class & STCfinal) != 0) // https://issues.dlang.org/show_bug.cgi?id=14211 + else if ((cd.storage_class & STC.final_) != 0) // https://issues.dlang.org/show_bug.cgi?id=14211 exp.directcall = true; if (ad != cd) @@ -3700,10 +3700,10 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor Dsymbol s2; if (scx.scopesym && scx.scopesym.symtab && (s2 = scx.scopesym.symtab.lookup(s.ident)) !is null && s != s2) { - // allow STClocal symbols to be shadowed + // allow STC.local symbols to be shadowed // TODO: not really an optimal design auto decl = s2.isDeclaration(); - if (!decl || !(decl.storage_class & STClocal)) + if (!decl || !(decl.storage_class & STC.local)) { e.error("%s %s is shadowing %s %s", s.kind(), s.ident.toChars(), s2.kind(), s2.toPrettyChars()); return setError(); @@ -3716,9 +3716,9 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (!s.isVarDeclaration()) { Scope* sc2 = sc; - if (sc2.stc & (STCpure | STCnothrow | STCnogc)) + if (sc2.stc & (STC.pure_ | STC.nothrow_ | STC.nogc)) sc2 = sc.push(); - sc2.stc &= ~(STCpure | STCnothrow | STCnogc); + sc2.stc &= ~(STC.pure_ | STC.nothrow_ | STC.nogc); e.declaration.dsymbolSemantic(sc2); if (sc2 != sc) sc2.pop(); @@ -3920,7 +3920,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor for (size_t i = 0; i < cd.baseclasses.dim; i++) { BaseClass* b = (*cd.baseclasses)[i]; - args.push(new Parameter(STCin, b.type, null, null)); + args.push(new Parameter(STC.in_, b.type, null, null)); } tded = new TypeTuple(args); } @@ -4567,7 +4567,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor checkAccess(exp.loc, sc, exp.e1, exp.var); VarDeclaration v = exp.var.isVarDeclaration(); - if (v && (v.isDataseg() || (v.storage_class & STCmanifest))) + if (v && (v.isDataseg() || (v.storage_class & STC.manifest))) { Expression e = expandVar(WANTvalue, v); if (e) @@ -4805,7 +4805,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor { ThisExp ve = cast(ThisExp)dve.e1; VarDeclaration v = ve.var.isVarDeclaration(); - if (v && v.storage_class & STCref) + if (v && v.storage_class & STC.ref_) { if (!checkAddressVar(sc, exp, v)) return setError(); @@ -5574,7 +5574,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor { ThisExp ve = cast(ThisExp)dve.e1; v = ve.var.isVarDeclaration(); - if (v && !(v.storage_class & STCref)) + if (v && !(v.storage_class & STC.ref_)) v = null; } } @@ -6210,7 +6210,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor if (exp.e1.op != TOKvar && exp.e1.op != TOKarraylength) { // ref v = e1; - auto v = copyToTemp(STCref, "__postref", exp.e1); + auto v = copyToTemp(STC.ref_, "__postref", exp.e1); de = new DeclarationExp(exp.loc, v); exp.e1 = new VarExp(exp.e1.loc, v); } @@ -6635,7 +6635,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor } } else if (exp.op == TOKconstruct && exp.e1.op == TOKvar && - (cast(VarExp)exp.e1).var.storage_class & (STCout | STCref)) + (cast(VarExp)exp.e1).var.storage_class & (STC.out_ | STC.ref_)) { exp.memset |= MemorySet.referenceInit; } @@ -7392,7 +7392,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor else { // Rewrite: ref tmp = e1; tmp = tmp ^^ e2 - auto v = copyToTemp(STCref, "__powtmp", exp.e1); + auto v = copyToTemp(STC.ref_, "__powtmp", exp.e1); auto de = new DeclarationExp(exp.e1.loc, v); auto ve = new VarExp(exp.e1.loc, v); e = new PowExp(exp.loc, ve, exp.e2); @@ -9654,7 +9654,7 @@ Expression semanticY(DotIdExp exp, Scope* sc, int flag) if (v.type.ty == Terror) return new ErrorExp(); - if ((v.storage_class & STCmanifest) && v._init && !exp.wantsym) + if ((v.storage_class & STC.manifest) && v._init && !exp.wantsym) { /* Normally, the replacement of a symbol with its initializer is supposed to be in semantic2(). * Introduced by https://github.com/dlang/dmd/pull/5588 which should probably @@ -10042,9 +10042,9 @@ private bool checkAddressVar(Scope* sc, UnaExp exp, VarDeclaration v) if (global.params.vsafe) { // Taking the address of v means it cannot be set to 'scope' later - v.storage_class &= ~STCmaybescope; + v.storage_class &= ~STC.maybescope; v.doNotInferScope = true; - if (v.storage_class & STCscope && sc.func.setUnsafe()) + if (v.storage_class & STC.scope_ && sc.func.setUnsafe()) { exp.error("cannot take address of scope %s %s in @safe function %s", p, v.toChars(), sc.func.toChars()); return false; diff --git a/src/dmd/func.d b/src/dmd/func.d index 9781021175ca..e5c1bd69d353 100644 --- a/src/dmd/func.d +++ b/src/dmd/func.d @@ -263,7 +263,7 @@ extern (C++) class FuncDeclaration : Declaration { // Normalize storage_class, because function-type related attributes // are already set in the 'type' in parsing phase. - this.storage_class &= ~(STC_TYPECTOR | STC_FUNCATTR); + this.storage_class &= ~(STC.TYPECTOR | STC.FUNCATTR); } this.loc = loc; this.endloc = endloc; @@ -339,7 +339,7 @@ extern (C++) class FuncDeclaration : Declaration return functionSemantic3() || !errors; } - if (storage_class & STCinference) + if (storage_class & STC.inference) return functionSemantic3() || !errors; return !errors; @@ -410,24 +410,24 @@ extern (C++) class FuncDeclaration : Declaration thandle = thandle.addMod(type.mod); thandle = thandle.addStorageClass(storage_class); VarDeclaration v = new ThisDeclaration(loc, thandle); - v.storage_class |= STCparameter; + v.storage_class |= STC.parameter; if (thandle.ty == Tstruct) { - v.storage_class |= STCref; + v.storage_class |= STC.ref_; // if member function is marked 'inout', then 'this' is 'return ref' if (type.ty == Tfunction && (cast(TypeFunction)type).iswild & 2) - v.storage_class |= STCreturn; + v.storage_class |= STC.return_; } if (type.ty == Tfunction) { TypeFunction tf = cast(TypeFunction)type; if (tf.isreturn) - v.storage_class |= STCreturn; + v.storage_class |= STC.return_; if (tf.isscope) - v.storage_class |= STCscope; + v.storage_class |= STC.scope_; } - if (flags & FUNCFLAG.inferScope && !(v.storage_class & STCscope)) - v.storage_class |= STCmaybescope; + if (flags & FUNCFLAG.inferScope && !(v.storage_class & STC.scope_)) + v.storage_class |= STC.maybescope; v.dsymbolSemantic(sc); if (!sc.insert(v)) @@ -442,17 +442,17 @@ extern (C++) class FuncDeclaration : Declaration * Note that nested functions and member functions are disjoint. */ VarDeclaration v = new ThisDeclaration(loc, Type.tvoid.pointerTo()); - v.storage_class |= STCparameter; + v.storage_class |= STC.parameter; if (type.ty == Tfunction) { TypeFunction tf = cast(TypeFunction)type; if (tf.isreturn) - v.storage_class |= STCreturn; + v.storage_class |= STC.return_; if (tf.isscope) - v.storage_class |= STCscope; + v.storage_class |= STC.scope_; } - if (flags & FUNCFLAG.inferScope && !(v.storage_class & STCscope)) - v.storage_class |= STCmaybescope; + if (flags & FUNCFLAG.inferScope && !(v.storage_class & STC.scope_)) + v.storage_class |= STC.maybescope; v.dsymbolSemantic(sc); if (!sc.insert(v)) @@ -925,7 +925,7 @@ extern (C++) class FuncDeclaration : Declaration { Parameter p = Parameter.getNth(tf.parameters, u); Expression e; - if (p.storageClass & (STCref | STCout)) + if (p.storageClass & (STC.ref_ | STC.out_)) { e = new IdentifierExp(Loc(), p.ident); e.type = p.type; @@ -1125,14 +1125,14 @@ extern (C++) class FuncDeclaration : Declaration */ override final bool isAbstract() { - if (storage_class & STCabstract) + if (storage_class & STC.abstract_) return true; if (semanticRun >= PASSsemanticdone) return false; if (_scope) { - if (_scope.stc & STCabstract) + if (_scope.stc & STC.abstract_) return true; parent = _scope.parent; Dsymbol parent = toParent(); @@ -1162,7 +1162,7 @@ extern (C++) class FuncDeclaration : Declaration return true; if (isFuncLiteralDeclaration() || // externs are not possible with literals - (storage_class & STCinference) || // do attribute inference + (storage_class & STC.inference) || // do attribute inference (inferRetType && !isCtorDeclaration())) return true; @@ -1198,7 +1198,7 @@ extern (C++) class FuncDeclaration : Declaration if (!isVirtual() || introducing) flags |= FUNCFLAG.returnInprocess; - // Initialize for inferring STCscope + // Initialize for inferring STC.scope_ if (global.params.vsafe) flags |= FUNCFLAG.inferScope; } @@ -1440,7 +1440,7 @@ extern (C++) class FuncDeclaration : Declaration if (!tp) continue; - if (fparam.storageClass & (STClazy | STCout | STCref)) + if (fparam.storageClass & (STC.lazy_ | STC.out_ | STC.ref_)) { if (!traverseIndirections(tp, t)) return false; @@ -1509,7 +1509,7 @@ extern (C++) class FuncDeclaration : Declaration { auto f = toAliasFunc(); //printf("\ttoParent2() = '%s'\n", f.toParent2().toChars()); - return ((f.storage_class & STCstatic) == 0) && + return ((f.storage_class & STC.static_) == 0) && (f.linkage == LINKd) && (f.toParent2().isFuncDeclaration() !is null); } @@ -1525,7 +1525,7 @@ extern (C++) class FuncDeclaration : Declaration override AggregateDeclaration isThis() { //printf("+FuncDeclaration::isThis() '%s'\n", toChars()); - auto ad = (storage_class & STCstatic) ? null : isMember2(); + auto ad = (storage_class & STC.static_) ? null : isMember2(); //printf("-FuncDeclaration::isThis() %p\n", ad); return ad; } @@ -1578,12 +1578,12 @@ extern (C++) class FuncDeclaration : Declaration version (none) { printf("FuncDeclaration::isFinalFunc(%s), %x\n", toChars(), Declaration.isFinal()); - printf("%p %d %d %d\n", isMember(), isStatic(), Declaration.isFinal(), ((cd = toParent().isClassDeclaration()) !is null && cd.storage_class & STCfinal)); - printf("result is %d\n", isMember() && (Declaration.isFinal() || ((cd = toParent().isClassDeclaration()) !is null && cd.storage_class & STCfinal))); + printf("%p %d %d %d\n", isMember(), isStatic(), Declaration.isFinal(), ((cd = toParent().isClassDeclaration()) !is null && cd.storage_class & STC.final_)); + printf("result is %d\n", isMember() && (Declaration.isFinal() || ((cd = toParent().isClassDeclaration()) !is null && cd.storage_class & STC.final_))); if (cd) printf("\tmember of %s\n", cd.toChars()); } - return isMember() && (Declaration.isFinal() || ((cd = toParent().isClassDeclaration()) !is null && cd.storage_class & STCfinal)); + return isMember() && (Declaration.isFinal() || ((cd = toParent().isClassDeclaration()) !is null && cd.storage_class & STC.final_)); } bool addPreInvariant() @@ -1907,13 +1907,13 @@ extern (C++) class FuncDeclaration : Declaration * fbody.dsymbolSemantic() running, vresult.type might be modified. */ vresult = new VarDeclaration(loc, tret, outId ? outId : Id.result, null); - vresult.storage_class |= STCnodtor; + vresult.storage_class |= STC.nodtor; if (outId == Id.result) - vresult.storage_class |= STCtemp; + vresult.storage_class |= STC.temp; if (!isVirtual()) - vresult.storage_class |= STCconst; - vresult.storage_class |= STCresult; + vresult.storage_class |= STC.const_; + vresult.storage_class |= STC.result; // set before the semantic() for checkNestedReference() vresult.parent = this; @@ -1923,7 +1923,7 @@ extern (C++) class FuncDeclaration : Declaration { TypeFunction tf = type.toTypeFunction(); if (tf.isref) - vresult.storage_class |= STCref; + vresult.storage_class |= STC.ref_; vresult.type = tret; vresult.dsymbolSemantic(sc); @@ -1982,7 +1982,7 @@ extern (C++) class FuncDeclaration : Declaration { assert(fdv._scope); Scope* sc = fdv._scope.push(); - sc.stc &= ~STCoverride; + sc.stc &= ~STC.override_; fdv.semantic3(sc); sc.pop(); } @@ -2056,7 +2056,7 @@ extern (C++) class FuncDeclaration : Declaration tf.isnogc = f.isnogc; tf.purity = f.purity; tf.trust = f.trust; - auto fd = new FuncDeclaration(loc, loc, Id.require, STCundefined, tf); + auto fd = new FuncDeclaration(loc, loc, Id.require, STC.undefined_, tf); fd.fbody = frequire; Statement s1 = new ExpStatement(loc, fd); Expression e = new CallExp(loc, new VarExp(loc, fd, false), cast(Expressions*)null); @@ -2080,7 +2080,7 @@ extern (C++) class FuncDeclaration : Declaration Parameter p = null; if (outId) { - p = new Parameter(STCref | STCconst, f.nextOf(), outId, null); + p = new Parameter(STC.ref_ | STC.const_, f.nextOf(), outId, null); fparams.push(p); } auto tf = new TypeFunction(fparams, Type.tvoid, 0, LINKd); @@ -2088,7 +2088,7 @@ extern (C++) class FuncDeclaration : Declaration tf.isnogc = f.isnogc; tf.purity = f.purity; tf.trust = f.trust; - auto fd = new FuncDeclaration(loc, loc, Id.ensure, STCundefined, tf); + auto fd = new FuncDeclaration(loc, loc, Id.ensure, STC.undefined_, tf); fd.fbody = fensure; Statement s1 = new ExpStatement(loc, fd); Expression eresult = null; @@ -2127,7 +2127,7 @@ extern (C++) class FuncDeclaration : Declaration { assert(fdv._scope); Scope* sc = fdv._scope.push(); - sc.stc &= ~STCoverride; + sc.stc &= ~STC.override_; fdv.semantic3(sc); sc.pop(); } @@ -2153,7 +2153,7 @@ extern (C++) class FuncDeclaration : Declaration */ auto ei = new ExpInitializer(Loc(), eresult); auto v = new VarDeclaration(Loc(), t1, Identifier.generateId("__covres"), ei); - v.storage_class |= STCtemp; + v.storage_class |= STC.temp; auto de = new DeclarationExp(Loc(), v); auto ve = new VarExp(Loc(), v); eresult = new CommaExp(Loc(), de, ve); @@ -2225,7 +2225,7 @@ extern (C++) class FuncDeclaration : Declaration else { tf = new TypeFunction(fparams, treturn, 0, LINKc, stc); - fd = new FuncDeclaration(Loc(), Loc(), id, STCstatic, tf); + fd = new FuncDeclaration(Loc(), Loc(), id, STC.static_, tf); fd.protection = Prot(PROTpublic); fd.linkage = LINKc; @@ -2250,7 +2250,7 @@ extern (C++) class FuncDeclaration : Declaration if (t.ty != Tarray || t.nextOf().ty != Tarray || t.nextOf().nextOf().ty != Tchar || - fparam0.storageClass & (STCout | STCref | STClazy)) + fparam0.storageClass & (STC.out_ | STC.ref_ | STC.lazy_)) { argerr = true; } @@ -2929,7 +2929,7 @@ extern (C++) final class FuncLiteralDeclaration : FuncDeclaration extern (D) this(Loc loc, Loc endloc, Type type, TOK tok, ForeachStatement fes, Identifier id = null) { - super(loc, endloc, null, STCundefined, type); + super(loc, endloc, null, STC.undefined_, type); this.ident = id ? id : Id.empty; this.tok = tok; this.fes = fes; @@ -3157,7 +3157,7 @@ extern (C++) final class DtorDeclaration : FuncDeclaration { extern (D) this(Loc loc, Loc endloc) { - super(loc, endloc, Id.dtor, STCundefined, null); + super(loc, endloc, Id.dtor, STC.undefined_, null); } extern (D) this(Loc loc, Loc endloc, StorageClass stc, Identifier id) @@ -3220,12 +3220,12 @@ extern (C++) class StaticCtorDeclaration : FuncDeclaration { final extern (D) this(Loc loc, Loc endloc, StorageClass stc) { - super(loc, endloc, Identifier.generateId("_staticCtor"), STCstatic | stc, null); + super(loc, endloc, Identifier.generateId("_staticCtor"), STC.static_ | stc, null); } final extern (D) this(Loc loc, Loc endloc, const(char)* name, StorageClass stc) { - super(loc, endloc, Identifier.generateId(name), STCstatic | stc, null); + super(loc, endloc, Identifier.generateId(name), STC.static_ | stc, null); } override Dsymbol syntaxCopy(Dsymbol s) @@ -3306,12 +3306,12 @@ extern (C++) class StaticDtorDeclaration : FuncDeclaration final extern (D) this(Loc loc, Loc endloc, StorageClass stc) { - super(loc, endloc, Identifier.generateId("_staticDtor"), STCstatic | stc, null); + super(loc, endloc, Identifier.generateId("_staticDtor"), STC.static_ | stc, null); } final extern (D) this(Loc loc, Loc endloc, const(char)* name, StorageClass stc) { - super(loc, endloc, Identifier.generateId(name), STCstatic | stc, null); + super(loc, endloc, Identifier.generateId(name), STC.static_ | stc, null); } override Dsymbol syntaxCopy(Dsymbol s) @@ -3522,7 +3522,7 @@ extern (C++) final class NewDeclaration : FuncDeclaration extern (D) this(Loc loc, Loc endloc, StorageClass stc, Parameters* fparams, int varargs) { - super(loc, endloc, Id.classNew, STCstatic | stc, null); + super(loc, endloc, Id.classNew, STC.static_ | stc, null); this.parameters = fparams; this.varargs = varargs; } @@ -3573,7 +3573,7 @@ extern (C++) final class DeleteDeclaration : FuncDeclaration extern (D) this(Loc loc, Loc endloc, StorageClass stc, Parameters* fparams) { - super(loc, endloc, Id.classDelete, STCstatic | stc, null); + super(loc, endloc, Id.classDelete, STC.static_ | stc, null); this.parameters = fparams; } diff --git a/src/dmd/hdrgen.d b/src/dmd/hdrgen.d index 0514309b9984..d42a1e91af2c 100644 --- a/src/dmd/hdrgen.d +++ b/src/dmd/hdrgen.d @@ -331,7 +331,7 @@ public: { StorageClass stc = p.storageClass; if (!p.type && !stc) - stc = STCauto; + stc = STC.auto_; if (stcToBuffer(buf, stc)) buf.writeByte(' '); if (p.type) @@ -1795,7 +1795,7 @@ public: override void visit(AliasDeclaration d) { - if (d.storage_class & STClocal) + if (d.storage_class & STC.local) return; buf.writestring("alias "); if (d.aliassym) @@ -1828,7 +1828,7 @@ public: override void visit(VarDeclaration d) { - if (d.storage_class & STClocal) + if (d.storage_class & STC.local) return; visitVarDecl(d, false); buf.writeByte(';'); @@ -1873,7 +1873,7 @@ public: if (hgs.hdrgen) { // if the return type is missing (e.g. ref functions or auto) - if (!tf.next || f.storage_class & STCauto) + if (!tf.next || f.storage_class & STC.auto_) { hgs.autoMember++; bodyToBuffer(f); @@ -1989,13 +1989,13 @@ public: override void visit(DtorDeclaration d) { - if (d.storage_class & STCtrusted) + if (d.storage_class & STC.trusted) buf.writestring("@trusted "); - if (d.storage_class & STCsafe) + if (d.storage_class & STC.safe) buf.writestring("@safe "); - if (d.storage_class & STCnogc) + if (d.storage_class & STC.nogc) buf.writestring("@nogc "); - if (d.storage_class & STCdisable) + if (d.storage_class & STC.disable) buf.writestring("@disable "); buf.writestring("~this()"); @@ -2004,7 +2004,7 @@ public: override void visit(StaticCtorDeclaration d) { - if (stcToBuffer(buf, d.storage_class & ~STCstatic)) + if (stcToBuffer(buf, d.storage_class & ~STC.static_)) buf.writeByte(' '); if (d.isSharedStaticCtorDeclaration()) buf.writestring("shared "); @@ -2020,7 +2020,7 @@ public: override void visit(StaticDtorDeclaration d) { - if (stcToBuffer(buf, d.storage_class & ~STCstatic)) + if (stcToBuffer(buf, d.storage_class & ~STC.static_)) buf.writeByte(' '); if (d.isSharedStaticDtorDeclaration()) buf.writestring("shared "); @@ -2056,7 +2056,7 @@ public: override void visit(NewDeclaration d) { - if (stcToBuffer(buf, d.storage_class & ~STCstatic)) + if (stcToBuffer(buf, d.storage_class & ~STC.static_)) buf.writeByte(' '); buf.writestring("new"); parametersToBuffer(d.parameters, d.varargs); @@ -2065,7 +2065,7 @@ public: override void visit(DeleteDeclaration d) { - if (stcToBuffer(buf, d.storage_class & ~STCstatic)) + if (stcToBuffer(buf, d.storage_class & ~STC.static_)) buf.writeByte(' '); buf.writestring("delete"); parametersToBuffer(d.parameters, 0); @@ -3049,26 +3049,26 @@ public: //////////////////////////////////////////////////////////////////////////// override void visit(Parameter p) { - if (p.storageClass & STCauto) + if (p.storageClass & STC.auto_) buf.writestring("auto "); - if (p.storageClass & STCreturn) + if (p.storageClass & STC.return_) buf.writestring("return "); - if (p.storageClass & STCout) + if (p.storageClass & STC.out_) buf.writestring("out "); - else if (p.storageClass & STCref) + else if (p.storageClass & STC.ref_) buf.writestring("ref "); - else if (p.storageClass & STCin) + else if (p.storageClass & STC.in_) buf.writestring("in "); - else if (p.storageClass & STClazy) + else if (p.storageClass & STC.lazy_) buf.writestring("lazy "); - else if (p.storageClass & STCalias) + else if (p.storageClass & STC.alias_) buf.writestring("alias "); StorageClass stc = p.storageClass; if (p.type && p.type.mod & MODshared) - stc &= ~STCshared; - if (stcToBuffer(buf, stc & (STCconst | STCimmutable | STCwild | STCshared | STCscope | STCscopeinferred))) + stc &= ~STC.shared_; + if (stcToBuffer(buf, stc & (STC.const_ | STC.immutable_ | STC.wild | STC.shared_ | STC.scope_ | STC.scopeinferred))) buf.writeByte(' '); - if (p.storageClass & STCalias) + if (p.storageClass & STC.alias_) { if (p.ident) buf.writestring(p.ident.toString()); @@ -3182,10 +3182,10 @@ extern (C++) void toCBuffer(Initializer iz, OutBuffer* buf, HdrGenState* hgs) extern (C++) bool stcToBuffer(OutBuffer* buf, StorageClass stc) { bool result = false; - if ((stc & (STCreturn | STCscope)) == (STCreturn | STCscope)) - stc &= ~STCscope; - if (stc & STCscopeinferred) - stc &= ~(STCscope | STCscopeinferred); + if ((stc & (STC.return_ | STC.scope_)) == (STC.return_ | STC.scope_)) + stc &= ~STC.scope_; + if (stc & STC.scopeinferred) + stc &= ~(STC.scope_ | STC.scopeinferred); while (stc) { const(char)* p = stcToChars(stc); @@ -3216,38 +3216,38 @@ extern (C++) const(char)* stcToChars(ref StorageClass stc) static __gshared SCstring* table = [ - SCstring(STCauto, TOKauto), - SCstring(STCscope, TOKscope), - SCstring(STCstatic, TOKstatic), - SCstring(STCextern, TOKextern), - SCstring(STCconst, TOKconst), - SCstring(STCfinal, TOKfinal), - SCstring(STCabstract, TOKabstract), - SCstring(STCsynchronized, TOKsynchronized), - SCstring(STCdeprecated, TOKdeprecated), - SCstring(STCoverride, TOKoverride), - SCstring(STClazy, TOKlazy), - SCstring(STCalias, TOKalias), - SCstring(STCout, TOKout), - SCstring(STCin, TOKin), - SCstring(STCmanifest, TOKenum), - SCstring(STCimmutable, TOKimmutable), - SCstring(STCshared, TOKshared), - SCstring(STCnothrow, TOKnothrow), - SCstring(STCwild, TOKwild), - SCstring(STCpure, TOKpure), - SCstring(STCref, TOKref), - SCstring(STCreturn, TOKreturn), - SCstring(STCtls), - SCstring(STCgshared, TOKgshared), - SCstring(STCnogc, TOKat, "@nogc"), - SCstring(STCproperty, TOKat, "@property"), - SCstring(STCsafe, TOKat, "@safe"), - SCstring(STCtrusted, TOKat, "@trusted"), - SCstring(STCsystem, TOKat, "@system"), - SCstring(STCdisable, TOKat, "@disable"), - SCstring(STCfuture, TOKat, "@__future"), - SCstring(STClocal, TOKat, "__local"), + SCstring(STC.auto_, TOKauto), + SCstring(STC.scope_, TOKscope), + SCstring(STC.static_, TOKstatic), + SCstring(STC.extern_, TOKextern), + SCstring(STC.const_, TOKconst), + SCstring(STC.final_, TOKfinal), + SCstring(STC.abstract_, TOKabstract), + SCstring(STC.synchronized_, TOKsynchronized), + SCstring(STC.deprecated_, TOKdeprecated), + SCstring(STC.override_, TOKoverride), + SCstring(STC.lazy_, TOKlazy), + SCstring(STC.alias_, TOKalias), + SCstring(STC.out_, TOKout), + SCstring(STC.in_, TOKin), + SCstring(STC.manifest, TOKenum), + SCstring(STC.immutable_, TOKimmutable), + SCstring(STC.shared_, TOKshared), + SCstring(STC.nothrow_, TOKnothrow), + SCstring(STC.wild, TOKwild), + SCstring(STC.pure_, TOKpure), + SCstring(STC.ref_, TOKref), + SCstring(STC.return_, TOKreturn), + SCstring(STC.tls), + SCstring(STC.gshared, TOKgshared), + SCstring(STC.nogc, TOKat, "@nogc"), + SCstring(STC.property, TOKat, "@property"), + SCstring(STC.safe, TOKat, "@safe"), + SCstring(STC.trusted, TOKat, "@trusted"), + SCstring(STC.system, TOKat, "@system"), + SCstring(STC.disable, TOKat, "@disable"), + SCstring(STC.future, TOKat, "@__future"), + SCstring(STC.local, TOKat, "__local"), SCstring(0, TOKreserved) ]; for (int i = 0; table[i].stc; i++) @@ -3257,7 +3257,7 @@ extern (C++) const(char)* stcToChars(ref StorageClass stc) if (stc & tbl) { stc &= ~tbl; - if (tbl == STCtls) // TOKtls was removed + if (tbl == STC.tls) // TOKtls was removed return "__thread"; TOK tok = table[i].tok; if (tok == TOKat) diff --git a/src/dmd/iasm.d b/src/dmd/iasm.d index c8312cdb20dc..2df2ab904a21 100644 --- a/src/dmd/iasm.d +++ b/src/dmd/iasm.d @@ -1054,10 +1054,10 @@ opflag_t asm_determine_operand_flags(OPND *popnd) ps = popnd.s; Declaration ds = ps ? ps.isDeclaration() : null; - if (ds && ds.storage_class & STClazy) + if (ds && ds.storage_class & STC.lazy_) sz = _anysize; else - sz = asm_type_size((ds && ds.storage_class & (STCout | STCref)) ? popnd.ptype.pointerTo() : popnd.ptype); + sz = asm_type_size((ds && ds.storage_class & (STC.out_ | STC.ref_)) ? popnd.ptype.pointerTo() : popnd.ptype); if (popnd.pregDisp1 && !popnd.base) { if (ps && ps.isLabel() && sz == _anysize) @@ -2223,7 +2223,7 @@ void asm_merge_symbol(ref OPND o1, Dsymbol s) o1.disp += v.offset; goto L2; } - if ((v.isConst() || v.isImmutable() || v.storage_class & STCmanifest) && + if ((v.isConst() || v.isImmutable() || v.storage_class & STC.manifest) && !v.type.isfloating() && v.type.ty != Tvector && v._init) { ExpInitializer ei = v._init.isExpInitializer(); diff --git a/src/dmd/inline.d b/src/dmd/inline.d index 810ebbc941e6..085597032ad9 100644 --- a/src/dmd/inline.d +++ b/src/dmd/inline.d @@ -1123,7 +1123,7 @@ public: * S s = S(1); // constructor call */ Declaration d = (cast(VarExp)e.e1).var; - if (d.storage_class & (STCout | STCref)) // refinit + if (d.storage_class & (STC.out_ | STC.ref_)) // refinit goto L1; } else @@ -1544,7 +1544,7 @@ bool canInline(FuncDeclaration fd, bool hasthis, bool hdrscan, bool statementsTo { foreach (param; *fd.parameters) { - if (param.storage_class & STClazy) + if (param.storage_class & STC.lazy_) goto Lno; } } @@ -1761,7 +1761,7 @@ private void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration paren if (eret.op == TOKvar) { vret = (cast(VarExp)eret).var.isVarDeclaration(); - assert(!(vret.storage_class & (STCout | STCref))); + assert(!(vret.storage_class & (STC.out_ | STC.ref_))); eret = null; } else @@ -1772,7 +1772,7 @@ private void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration paren auto ei = new ExpInitializer(callLoc, null); auto tmp = Identifier.generateId("__retvar"); vret = new VarDeclaration(fd.loc, eret.type, tmp, ei); - vret.storage_class |= STCtemp | STCref; + vret.storage_class |= STC.temp | STC.ref_; vret.linkage = LINKd; vret.parent = parent; @@ -1797,7 +1797,7 @@ private void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration paren auto tmp = Identifier.generateId("__retvar"); vret = new VarDeclaration(fd.loc, fd.nrvo_var.type, tmp, new VoidInitializer(fd.loc)); assert(!tf.isref); - vret.storage_class = STCtemp | STCrvalue; + vret.storage_class = STC.temp | STC.rvalue; vret.linkage = tf.linkage; vret.parent = parent; @@ -1833,9 +1833,9 @@ private void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration paren auto ei = new ExpInitializer(fd.loc, ethis); vthis = new VarDeclaration(fd.loc, ethis.type, Id.This, ei); if (ethis.type.ty != Tclass) - vthis.storage_class = STCref; + vthis.storage_class = STC.ref_; else - vthis.storage_class = STCin; + vthis.storage_class = STC.in_; vthis.linkage = LINKd; vthis.parent = parent; @@ -1863,13 +1863,13 @@ private void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration paren auto ei = new ExpInitializer(vfrom.loc, arg); auto vto = new VarDeclaration(vfrom.loc, vfrom.type, vfrom.ident, ei); - vto.storage_class |= vfrom.storage_class & (STCtemp | STCin | STCout | STClazy | STCref); + vto.storage_class |= vfrom.storage_class & (STC.temp | STC.in_ | STC.out_ | STC.lazy_ | STC.ref_); vto.linkage = vfrom.linkage; vto.parent = parent; //printf("vto = '%s', vto.storage_class = x%x\n", vto.toChars(), vto.storage_class); //printf("vto.parent = '%s'\n", parent.toChars()); - // Even if vto is STClazy, `vto = arg` is handled correctly in glue layer. + // Even if vto is STC.lazy_, `vto = arg` is handled correctly in glue layer. ei.exp = new BlitExp(vto.loc, vto, arg); ei.exp.type = vto.type; //arg.type.print(); @@ -1928,7 +1928,7 @@ private void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration paren { // same with ExpStatement.scopeCode() as2 = new Statements(); - vthis.storage_class |= STCnodtor; + vthis.storage_class |= STC.nodtor; } } @@ -1994,7 +1994,7 @@ private void expandInline(Loc callLoc, FuncDeclaration fd, FuncDeclaration paren auto ei = new ExpInitializer(callLoc, e); auto tmp = Identifier.generateId("__inlineretval"); auto vd = new VarDeclaration(callLoc, tf.next, tmp, ei); - vd.storage_class = STCtemp | (tf.isref ? STCref : STCrvalue); + vd.storage_class = STC.temp | (tf.isref ? STC.ref_ : STC.rvalue); vd.linkage = tf.linkage; vd.parent = parent; diff --git a/src/dmd/json.d b/src/dmd/json.d index d043adb5fa0b..9e96e53d0f77 100644 --- a/src/dmd/json.d +++ b/src/dmd/json.d @@ -425,7 +425,7 @@ public: void jsonProperties(Declaration d) { - if (d.storage_class & STClocal) + if (d.storage_class & STC.local) return; jsonProperties(cast(Dsymbol)d); propertyStorageClass("storageClass", d.storage_class); @@ -768,7 +768,7 @@ public: override void visit(VarDeclaration d) { - if (d.storage_class & STClocal) + if (d.storage_class & STC.local) return; objectStart(); jsonProperties(d); diff --git a/src/dmd/mtype.d b/src/dmd/mtype.d index 1ded257afd45..1edc051ade25 100644 --- a/src/dmd/mtype.d +++ b/src/dmd/mtype.d @@ -229,13 +229,13 @@ StorageClass ModToStc(uint mod) pure nothrow @nogc @safe { StorageClass stc = 0; if (mod & MODimmutable) - stc |= STCimmutable; + stc |= STC.immutable_; if (mod & MODconst) - stc |= STCconst; + stc |= STC.const_; if (mod & MODwild) - stc |= STCwild; + stc |= STC.wild; if (mod & MODshared) - stc |= STCshared; + stc |= STC.shared_; return stc; } @@ -805,19 +805,19 @@ extern (C++) abstract class Type : RootObject if (!t1.isref && (t1.isscope || t2.isscope)) { - StorageClass stc1 = t1.isscope ? STCscope : 0; - StorageClass stc2 = t2.isscope ? STCscope : 0; + StorageClass stc1 = t1.isscope ? STC.scope_ : 0; + StorageClass stc2 = t2.isscope ? STC.scope_ : 0; if (t1.isreturn) { - stc1 |= STCreturn; + stc1 |= STC.return_; if (!t1.isscope) - stc1 |= STCref; + stc1 |= STC.ref_; } if (t2.isreturn) { - stc2 |= STCreturn; + stc2 |= STC.return_; if (!t2.isscope) - stc2 |= STCref; + stc2 |= STC.ref_; } if (!Parameter.isCovariantScope(t1.isref, stc1, stc2)) goto Lnotcovariant; @@ -836,7 +836,7 @@ extern (C++) abstract class Type : RootObject //stop attribute inference with const // If adding 'const' will make it covariant if (MODimplicitConv(t2.mod, MODmerge(t1.mod, MODconst))) - stc |= STCconst; + stc |= STC.const_; else goto Lnotcovariant; } @@ -849,20 +849,20 @@ extern (C++) abstract class Type : RootObject /* Can convert pure to impure, nothrow to throw, and nogc to gc */ if (!t1.purity && t2.purity) - stc |= STCpure; + stc |= STC.pure_; if (!t1.isnothrow && t2.isnothrow) - stc |= STCnothrow; + stc |= STC.nothrow_; if (!t1.isnogc && t2.isnogc) - stc |= STCnogc; + stc |= STC.nogc; /* Can convert safe/trusted to system */ if (t1.trust <= TRUSTsystem && t2.trust >= TRUSTtrusted) { // Should we infer trusted or safe? Go with safe. - stc |= STCsafe; + stc |= STC.safe; } if (stc) @@ -1829,13 +1829,13 @@ extern (C++) abstract class Type : RootObject if (t.isImmutable()) { } - else if (stc & STCimmutable) + else if (stc & STC.immutable_) { t = t.makeImmutable(); } else { - if ((stc & STCshared) && !t.isShared()) + if ((stc & STC.shared_) && !t.isShared()) { if (t.isWild()) { @@ -1852,7 +1852,7 @@ extern (C++) abstract class Type : RootObject t = t.makeShared(); } } - if ((stc & STCconst) && !t.isConst()) + if ((stc & STC.const_) && !t.isConst()) { if (t.isShared()) { @@ -1869,7 +1869,7 @@ extern (C++) abstract class Type : RootObject t = t.makeConst(); } } - if ((stc & STCwild) && !t.isWild()) + if ((stc & STC.wild) && !t.isWild()) { if (t.isShared()) { @@ -2053,15 +2053,15 @@ extern (C++) abstract class Type : RootObject /* Just translate to MOD bits and let addMod() do the work */ MOD mod = 0; - if (stc & STCimmutable) + if (stc & STC.immutable_) mod = MODimmutable; else { - if (stc & (STCconst | STCin)) + if (stc & (STC.const_ | STC.in_)) mod |= MODconst; - if (stc & STCwild) + if (stc & STC.wild) mod |= MODwild; - if (stc & STCshared) + if (stc & STC.shared_) mod |= MODshared; } return addMod(mod); @@ -5106,7 +5106,7 @@ extern (C++) final class TypeAArray : TypeArray if (fd_aaLen is null) { auto fparams = new Parameters(); - fparams.push(new Parameter(STCin, this, null, null)); + fparams.push(new Parameter(STC.in_, this, null, null)); fd_aaLen = FuncDeclaration.genCfunc(fparams, Type.tsize_t, Id.aaLen); TypeFunction tf = fd_aaLen.type.toTypeFunction(); tf.purity = PUREconst; @@ -5481,30 +5481,30 @@ extern (C++) final class TypeFunction : TypeNext this.varargs = varargs; this.linkage = linkage; - if (stc & STCpure) + if (stc & STC.pure_) this.purity = PUREfwdref; - if (stc & STCnothrow) + if (stc & STC.nothrow_) this.isnothrow = true; - if (stc & STCnogc) + if (stc & STC.nogc) this.isnogc = true; - if (stc & STCproperty) + if (stc & STC.property) this.isproperty = true; - if (stc & STCref) + if (stc & STC.ref_) this.isref = true; - if (stc & STCreturn) + if (stc & STC.return_) this.isreturn = true; - if (stc & STCscope) + if (stc & STC.scope_) this.isscope = true; - if (stc & STCscopeinferred) + if (stc & STC.scopeinferred) this.isscopeinferred = true; this.trust = TRUSTdefault; - if (stc & STCsafe) + if (stc & STC.safe) this.trust = TRUSTsafe; - if (stc & STCsystem) + if (stc & STC.system) this.trust = TRUSTsystem; - if (stc & STCtrusted) + if (stc & STC.trusted) this.trust = TRUSTtrusted; } @@ -5603,12 +5603,12 @@ extern (C++) final class TypeFunction : TypeNext if (!t) continue; - if (fparam.storageClass & (STClazy | STCout)) + if (fparam.storageClass & (STC.lazy_ | STC.out_)) { purity = PUREweak; break; } - switch (purityOfType((fparam.storageClass & STCref) != 0, t)) + switch (purityOfType((fparam.storageClass & STC.ref_) != 0, t)) { case PUREweak: purity = PUREweak; @@ -5647,7 +5647,7 @@ extern (C++) final class TypeFunction : TypeNext for (size_t i = 0; i < dim; i++) { Parameter fparam = Parameter.getNth(parameters, i); - if (fparam.storageClass & STClazy) + if (fparam.storageClass & STC.lazy_) return true; } return false; @@ -5670,7 +5670,7 @@ extern (C++) final class TypeFunction : TypeNext * as lazy parameters to the next function, but that isn't * escaping. */ - if (parameterStorageClass(p) & (STCscope | STClazy)) + if (parameterStorageClass(p) & (STC.scope_ | STC.lazy_)) return false; return true; } @@ -5679,12 +5679,12 @@ extern (C++) final class TypeFunction : TypeNext /************************************ * Take the specified storage class for p, * and use the function signature to infer whether - * STCscope and STCreturn should be OR'd in. + * STC.scope_ and STC.return_ should be OR'd in. * (This will not affect the name mangling.) * Params: * p = one of the parameters to 'this' * Returns: - * storage class with STCscope or STCreturn OR'd in + * storage class with STC.scope_ or STC.return_ OR'd in */ final StorageClass parameterStorageClass(Parameter p) { @@ -5693,7 +5693,7 @@ extern (C++) final class TypeFunction : TypeNext if (!global.params.vsafe) return stc; - if (stc & (STCscope | STCreturn | STClazy) || purity == PUREimpure) + if (stc & (STC.scope_ | STC.return_ | STC.lazy_) || purity == PUREimpure) return stc; /* If haven't inferred the return type yet, can't infer storage classes @@ -5718,7 +5718,7 @@ extern (C++) final class TypeFunction : TypeNext t = t.baseElemOf(); if (t.isMutable() && t.hasPointers()) { - if (fparam.storageClass & (STCref | STCout)) + if (fparam.storageClass & (STC.ref_ | STC.out_)) { } else if (t.ty == Tarray || t.ty == Tpointer) @@ -5732,9 +5732,9 @@ extern (C++) final class TypeFunction : TypeNext } } - stc |= STCscope; + stc |= STC.scope_; - /* Inferring STCreturn here has false positives + /* Inferring STC.return_ here has false positives * for pure functions, producing spurious error messages * about escaping references. * Give up on it for now. @@ -5747,7 +5747,7 @@ extern (C++) final class TypeFunction : TypeNext /* The result has references, so p could be escaping * that way. */ - stc |= STCreturn; + stc |= STC.return_; } } @@ -5756,13 +5756,13 @@ extern (C++) final class TypeFunction : TypeNext override Type addStorageClass(StorageClass stc) { - //printf("addStorageClass(%llx) %d\n", stc, (stc & STCscope) != 0); + //printf("addStorageClass(%llx) %d\n", stc, (stc & STC.scope_) != 0); TypeFunction t = Type.addStorageClass(stc).toTypeFunction(); - if ((stc & STCpure && !t.purity) || - (stc & STCnothrow && !t.isnothrow) || - (stc & STCnogc && !t.isnogc) || - (stc & STCscope && !t.isscope) || - (stc & STCsafe && t.trust < TRUSTtrusted)) + if ((stc & STC.pure_ && !t.purity) || + (stc & STC.nothrow_ && !t.isnothrow) || + (stc & STC.nogc && !t.isnogc) || + (stc & STC.scope_ && !t.isscope) || + (stc & STC.safe && t.trust < TRUSTtrusted)) { // Klunky to change these auto tf = new TypeFunction(t.parameters, t.next, t.varargs, t.linkage, 0); @@ -5779,18 +5779,18 @@ extern (C++) final class TypeFunction : TypeNext tf.trust = t.trust; tf.iswild = t.iswild; - if (stc & STCpure) + if (stc & STC.pure_) tf.purity = PUREfwdref; - if (stc & STCnothrow) + if (stc & STC.nothrow_) tf.isnothrow = true; - if (stc & STCnogc) + if (stc & STC.nogc) tf.isnogc = true; - if (stc & STCsafe) + if (stc & STC.safe) tf.trust = TRUSTsafe; - if (stc & STCscope) + if (stc & STC.scope_) { tf.isscope = true; - if (stc & STCscopeinferred) + if (stc & STC.scopeinferred) tf.isscopeinferred = true; } @@ -5965,9 +5965,9 @@ extern (C++) final class TypeFunction : TypeNext Type tprm = p.type; Type targ = arg.type; - if (!(p.storageClass & STClazy && tprm.ty == Tvoid && targ.ty != Tvoid)) + if (!(p.storageClass & STC.lazy_ && tprm.ty == Tvoid && targ.ty != Tvoid)) { - bool isRef = (p.storageClass & (STCref | STCout)) != 0; + bool isRef = (p.storageClass & (STC.ref_ | STC.out_)) != 0; wildmatch |= targ.deduceWild(tprm, isRef); } } @@ -6009,7 +6009,7 @@ extern (C++) final class TypeFunction : TypeNext Type targ = arg.type; Type tprm = wildmatch ? p.type.substWildTo(wildmatch) : p.type; - if (p.storageClass & STClazy && tprm.ty == Tvoid && targ.ty != Tvoid) + if (p.storageClass & STC.lazy_ && tprm.ty == Tvoid && targ.ty != Tvoid) m = MATCH.convert; else { @@ -6025,7 +6025,7 @@ extern (C++) final class TypeFunction : TypeNext } // Non-lvalues do not match ref or out parameters - if (p.storageClass & (STCref | STCout)) + if (p.storageClass & (STC.ref_ | STC.out_)) { // https://issues.dlang.org/show_bug.cgi?id=13783 // Don't use toBasetype() to handle enum types. @@ -6035,7 +6035,7 @@ extern (C++) final class TypeFunction : TypeNext if (m && !arg.isLvalue()) { - if (p.storageClass & STCout) + if (p.storageClass & STC.out_) goto Nomatch; if (arg.op == TOKstring && tp.ty == Tsarray) @@ -6253,13 +6253,13 @@ extern (C++) final class TypeDelegate : TypeNext * alias dg_t = void* delegate(); * scope dg_t dg = ...; */ - if(stc & STCscope) + if(stc & STC.scope_) { - auto n = t.next.addStorageClass(STCscope | STCscopeinferred); + auto n = t.next.addStorageClass(STC.scope_ | STC.scopeinferred); if (n != t.next) { t.next = n; - t.deco = t.merge().deco; // mangling supposed to not be changed due to STCscopeinferrred + t.deco = t.merge().deco; // mangling supposed to not be changed due to STC.scope_inferrred } } return t; @@ -6521,7 +6521,7 @@ extern (C++) abstract class TypeQualified : Type { //printf("\t1: s = '%s' %p, kind = '%s'\n",s.toChars(), s, s.kind()); Declaration d = s.isDeclaration(); - if (d && (d.storage_class & STCtemplateparameter)) + if (d && (d.storage_class & STC.templateparameter)) s = s.toAlias(); else { @@ -6575,7 +6575,7 @@ extern (C++) abstract class TypeQualified : Type goto L3; if (VarDeclaration v = s.isVarDeclaration()) { - if (v.storage_class & (STCconst | STCimmutable | STCmanifest) || + if (v.storage_class & (STC.const_ | STC.immutable_ | STC.manifest) || v.type.isConst() || v.type.isImmutable()) { // https://issues.dlang.org/show_bug.cgi?id=13087 @@ -7347,7 +7347,7 @@ extern (C++) final class TypeStruct : Type if (v.type.ty == Terror) return new ErrorExp(); - if ((v.storage_class & STCmanifest) && v._init) + if ((v.storage_class & STC.manifest) && v._init) { if (v.inuse) { @@ -7490,7 +7490,7 @@ extern (C++) final class TypeStruct : Type Declaration d = new SymbolDeclaration(sym.loc, sym); assert(d); d.type = this; - d.storage_class |= STCrvalue; // https://issues.dlang.org/show_bug.cgi?id=14398 + d.storage_class |= STC.rvalue; // https://issues.dlang.org/show_bug.cgi?id=14398 return new VarExp(sym.loc, d); } @@ -7623,7 +7623,7 @@ extern (C++) final class TypeStruct : Type sym.size(Loc()); // give error for forward references foreach (VarDeclaration v; s.fields) { - if (v.storage_class & STCref || v.hasPointers()) + if (v.storage_class & STC.ref_ || v.hasPointers()) return true; } return false; @@ -8299,7 +8299,7 @@ extern (C++) final class TypeClass : Type if (v.type.ty == Terror) return new ErrorExp(); - if ((v.storage_class & STCmanifest) && v._init) + if ((v.storage_class & STC.manifest) && v._init) { if (v.inuse) { @@ -8654,7 +8654,7 @@ extern (C++) final class TypeTuple : Type Expression e = (*exps)[i]; if (e.type.ty == Ttuple) e.error("cannot form tuple of tuples"); - auto arg = new Parameter(STCundefined, e.type, null, null); + auto arg = new Parameter(STC.undefined_, e.type, null, null); (*arguments)[i] = arg; } } @@ -9032,7 +9032,7 @@ extern (C++) final class Parameter : RootObject int isTPLDg(size_t n, Parameter p) { - if (p.storageClass & (STCalias | STCauto | STCstatic)) + if (p.storageClass & (STC.alias_ | STC.auto_ | STC.static_)) return 1; return 0; } @@ -9138,7 +9138,7 @@ extern (C++) final class Parameter : RootObject */ final bool isCovariant(bool returnByRef, const Parameter p) const pure nothrow @nogc @safe { - enum stc = STCref | STCin | STCout | STClazy; + enum stc = STC.ref_ | STC.in_ | STC.out_ | STC.lazy_; if ((this.storageClass & stc) != (p.storageClass & stc)) return false; return isCovariantScope(returnByRef, this.storageClass, p.storageClass); @@ -9157,15 +9157,15 @@ extern (C++) final class Parameter : RootObject static uint buildSR(bool returnByRef, StorageClass stc) pure nothrow @nogc @safe { uint result; - final switch (stc & (STCref | STCscope | STCreturn)) + final switch (stc & (STC.ref_ | STC.scope_ | STC.return_)) { case 0: result = SR.None; break; - case STCref: result = SR.Ref; break; - case STCscope: result = SR.Scope; break; - case STCreturn | STCref: result = SR.ReturnRef; break; - case STCreturn | STCscope: result = SR.ReturnScope; break; - case STCref | STCscope: result = SR.RefScope; break; - case STCreturn | STCref | STCscope: + case STC.ref_: result = SR.Ref; break; + case STC.scope_: result = SR.Scope; break; + case STC.return_ | STC.ref_: result = SR.ReturnRef; break; + case STC.return_ | STC.scope_: result = SR.ReturnScope; break; + case STC.ref_ | STC.scope_: result = SR.RefScope; break; + case STC.return_ | STC.ref_ | STC.scope_: result = returnByRef ? SR.ReturnRef_Scope : SR.Ref_ReturnScope; break; } @@ -9175,7 +9175,7 @@ extern (C++) final class Parameter : RootObject /* result is true if the 'from' can be used as a 'to' */ - if ((from ^ to) & STCref) // differing in 'ref' means no covariance + if ((from ^ to) & STC.ref_) // differing in 'ref' means no covariance return false; return covariant[buildSR(returnByRef, from)][buildSR(returnByRef, to)]; diff --git a/src/dmd/nogc.d b/src/dmd/nogc.d index 305e00b439bc..0f31a57fb506 100644 --- a/src/dmd/nogc.d +++ b/src/dmd/nogc.d @@ -53,7 +53,7 @@ public: { // Note that, walkPostorder does not support DeclarationExp today. VarDeclaration v = e.declaration.isVarDeclaration(); - if (v && !(v.storage_class & STCmanifest) && !v.isDataseg() && v._init) + if (v && !(v.storage_class & STC.manifest) && !v.isDataseg() && v._init) { if (ExpInitializer ei = v._init.isExpInitializer()) { diff --git a/src/dmd/opover.d b/src/dmd/opover.d index b28628c51eb1..daf5e03ad75a 100644 --- a/src/dmd/opover.d +++ b/src/dmd/opover.d @@ -1893,7 +1893,7 @@ extern (C++) bool inferApplyArgTypes(ForeachStatement fes, Scope* sc, ref Dsymbo { p.type = taa.index; // key type p.type = p.type.addStorageClass(p.storageClass); - if (p.storageClass & STCref) // key must not be mutated via ref + if (p.storageClass & STC.ref_) // key must not be mutated via ref p.type = p.type.addMod(MODconst); } p = (*fes.parameters)[1]; diff --git a/src/dmd/optimize.d b/src/dmd/optimize.d index 7b76c901dacf..0c0c75df076b 100644 --- a/src/dmd/optimize.d +++ b/src/dmd/optimize.d @@ -52,20 +52,20 @@ extern (C++) Expression expandVar(int result, VarDeclaration v) return e; if (!v.originalType && v.semanticRun < PASSsemanticdone) // semantic() not yet run v.dsymbolSemantic(null); - if (v.isConst() || v.isImmutable() || v.storage_class & STCmanifest) + if (v.isConst() || v.isImmutable() || v.storage_class & STC.manifest) { if (!v.type) { return e; } Type tb = v.type.toBasetype(); - if (v.storage_class & STCmanifest || v.type.toBasetype().isscalar() || ((result & WANTexpand) && (tb.ty != Tsarray && tb.ty != Tstruct))) + if (v.storage_class & STC.manifest || v.type.toBasetype().isscalar() || ((result & WANTexpand) && (tb.ty != Tsarray && tb.ty != Tstruct))) { if (v._init) { if (v.inuse) { - if (v.storage_class & STCmanifest) + if (v.storage_class & STC.manifest) { v.error("recursive initialization of constant"); return errorReturn(); @@ -75,7 +75,7 @@ extern (C++) Expression expandVar(int result, VarDeclaration v) Expression ei = v.getConstInitializer(); if (!ei) { - if (v.storage_class & STCmanifest) + if (v.storage_class & STC.manifest) { v.error("enum cannot be initialized with `%s`", v._init.toChars()); return errorReturn(); @@ -113,7 +113,7 @@ extern (C++) Expression expandVar(int result, VarDeclaration v) else goto L1; } - else if (!(v.storage_class & STCmanifest) && ei.isConst() != 1 && ei.op != TOKstring && ei.op != TOKaddress) + else if (!(v.storage_class & STC.manifest) && ei.isConst() != 1 && ei.op != TOKstring && ei.op != TOKaddress) { goto L1; } @@ -248,7 +248,7 @@ extern (C++) Expression Expression_optimize(Expression e, int result, bool keepL if (keepLvalue) { VarDeclaration v = e.var.isVarDeclaration(); - if (v && !(v.storage_class & STCmanifest)) + if (v && !(v.storage_class & STC.manifest)) return; } ret = fromConstInitializer(result, e); @@ -535,7 +535,7 @@ extern (C++) Expression Expression_optimize(Expression e, int result, bool keepL for (size_t i = 0; i < e.arguments.dim; i++) { Parameter p = Parameter.getNth(tf.parameters, i); - bool keep = p && (p.storageClass & (STCref | STCout)) != 0; + bool keep = p && (p.storageClass & (STC.ref_ | STC.out_)) != 0; expOptimize((*e.arguments)[i], WANTvalue, keep); } } @@ -925,7 +925,7 @@ extern (C++) Expression Expression_optimize(Expression e, int result, bool keepL if (e.e1.op == TOKvar) { VarDeclaration v = (cast(VarExp)e.e1).var.isVarDeclaration(); - if (v && (v.storage_class & STCstatic) && (v.storage_class & STCimmutable) && v._init) + if (v && (v.storage_class & STC.static_) && (v.storage_class & STC.immutable_) && v._init) { if (Expression ci = v.getConstInitializer()) e.e1 = ci; @@ -997,7 +997,7 @@ extern (C++) Expression Expression_optimize(Expression e, int result, bool keepL } Expression dollar = new IntegerExp(Loc(), len, Type.tsize_t); lengthVar._init = new ExpInitializer(Loc(), dollar); - lengthVar.storage_class |= STCstatic | STCconst; + lengthVar.storage_class |= STC.static_ | STC.const_; } override void visit(IndexExp e) diff --git a/src/dmd/parse.d b/src/dmd/parse.d index 793ed6a997b0..2a1debf38cb2 100644 --- a/src/dmd/parse.d +++ b/src/dmd/parse.d @@ -223,11 +223,11 @@ struct PrefixAttributes(AST) */ private StorageClass getStorageClass(AST)(PrefixAttributes!(AST)* pAttrs) { - StorageClass stc = AST.STCundefined; + StorageClass stc = AST.STC.undefined_; if (pAttrs) { stc = pAttrs.storageClass; - pAttrs.storageClass = AST.STCundefined; + pAttrs.storageClass = AST.STC.undefined_; } return stc; } @@ -321,9 +321,9 @@ final class Parser(AST) : Lexer { AST.Expressions* exps = null; const stc = parseAttribute(&exps); - if (stc == AST.STCproperty || stc == AST.STCnogc - || stc == AST.STCdisable || stc == AST.STCsafe - || stc == AST.STCtrusted || stc == AST.STCsystem) + if (stc == AST.STC.property || stc == AST.STC.nogc + || stc == AST.STC.disable || stc == AST.STC.safe + || stc == AST.STC.trusted || stc == AST.STC.system) { error("`@%s` attribute for module declaration is not supported", token.toChars()); } @@ -599,7 +599,7 @@ final class Parser(AST) : Lexer } // Workaround 14894. Add an empty unittest declaration to keep // the number of symbols in this scope independent of -unittest. - s = new AST.UnitTestDeclaration(loc, token.loc, AST.STCundefined, null); + s = new AST.UnitTestDeclaration(loc, token.loc, AST.STC.undefined_, null); } break; @@ -665,7 +665,7 @@ final class Parser(AST) : Lexer } else { - stc = AST.STCstatic; + stc = AST.STC.static_; goto Lstc; } break; @@ -673,13 +673,13 @@ final class Parser(AST) : Lexer case TOKconst: if (peekNext() == TOKlparen) goto Ldeclaration; - stc = AST.STCconst; + stc = AST.STC.const_; goto Lstc; case TOKimmutable: if (peekNext() == TOKlparen) goto Ldeclaration; - stc = AST.STCimmutable; + stc = AST.STC.immutable_; goto Lstc; case TOKshared: @@ -701,56 +701,56 @@ final class Parser(AST) : Lexer break; } } - stc = AST.STCshared; + stc = AST.STC.shared_; goto Lstc; } case TOKwild: if (peekNext() == TOKlparen) goto Ldeclaration; - stc = AST.STCwild; + stc = AST.STC.wild; goto Lstc; case TOKfinal: - stc = AST.STCfinal; + stc = AST.STC.final_; goto Lstc; case TOKauto: - stc = AST.STCauto; + stc = AST.STC.auto_; goto Lstc; case TOKscope: - stc = AST.STCscope; + stc = AST.STC.scope_; goto Lstc; case TOKoverride: - stc = AST.STCoverride; + stc = AST.STC.override_; goto Lstc; case TOKabstract: - stc = AST.STCabstract; + stc = AST.STC.abstract_; goto Lstc; case TOKsynchronized: - stc = AST.STCsynchronized; + stc = AST.STC.synchronized_; goto Lstc; case TOKnothrow: - stc = AST.STCnothrow; + stc = AST.STC.nothrow_; goto Lstc; case TOKpure: - stc = AST.STCpure; + stc = AST.STC.pure_; goto Lstc; case TOKref: - stc = AST.STCref; + stc = AST.STC.ref_; goto Lstc; case TOKgshared: - stc = AST.STCgshared; + stc = AST.STC.gshared; goto Lstc; - //case TOKmanifest: stc = STCmanifest; goto Lstc; + //case TOKmanifest: stc = STC.manifest; goto Lstc; case TOKat: { @@ -806,7 +806,7 @@ final class Parser(AST) : Lexer a = parseBlock(pLastDecl, pAttrs); auto stc2 = getStorageClass!AST(pAttrs); - if (stc2 != AST.STCundefined) + if (stc2 != AST.STC.undefined_) { s = new AST.StorageClassDeclaration(stc2, a); } @@ -826,7 +826,7 @@ final class Parser(AST) : Lexer { if (peek(&token).value != TOKlparen) { - stc = AST.STCdeprecated; + stc = AST.STC.deprecated_; goto Lstc; } nextToken(); @@ -867,7 +867,7 @@ final class Parser(AST) : Lexer { if (peek(&token).value != TOKlparen) { - stc = AST.STCextern; + stc = AST.STC.extern_; goto Lstc; } @@ -1277,7 +1277,7 @@ final class Parser(AST) : Lexer */ StorageClass appendStorageClass(StorageClass storageClass, StorageClass stc, bool deprec = false) { - if ((storageClass & stc) || (storageClass & AST.STCin && stc & (AST.STCconst | AST.STCscope)) || (stc & AST.STCin && storageClass & (AST.STCconst | AST.STCscope))) + if ((storageClass & stc) || (storageClass & AST.STC.in_ && stc & (AST.STC.const_ | AST.STC.scope_)) || (stc & AST.STC.in_ && storageClass & (AST.STC.const_ | AST.STC.scope_))) { OutBuffer buf; AST.stcToBuffer(&buf, stc); @@ -1290,21 +1290,21 @@ final class Parser(AST) : Lexer storageClass |= stc; - if (stc & (AST.STCconst | AST.STCimmutable | AST.STCmanifest)) + if (stc & (AST.STC.const_ | AST.STC.immutable_ | AST.STC.manifest)) { - StorageClass u = storageClass & (AST.STCconst | AST.STCimmutable | AST.STCmanifest); + StorageClass u = storageClass & (AST.STC.const_ | AST.STC.immutable_ | AST.STC.manifest); if (u & (u - 1)) error("conflicting attribute `%s`", Token.toChars(token.value)); } - if (stc & (AST.STCgshared | AST.STCshared | AST.STCtls)) + if (stc & (AST.STC.gshared | AST.STC.shared_ | AST.STC.tls)) { - StorageClass u = storageClass & (AST.STCgshared | AST.STCshared | AST.STCtls); + StorageClass u = storageClass & (AST.STC.gshared | AST.STC.shared_ | AST.STC.tls); if (u & (u - 1)) error("conflicting attribute `%s`", Token.toChars(token.value)); } - if (stc & (AST.STCsafe | AST.STCsystem | AST.STCtrusted)) + if (stc & (AST.STC.safe | AST.STC.system | AST.STC.trusted)) { - StorageClass u = storageClass & (AST.STCsafe | AST.STCsystem | AST.STCtrusted); + StorageClass u = storageClass & (AST.STC.safe | AST.STC.system | AST.STC.trusted); if (u & (u - 1)) error("conflicting attribute `@%s`", token.toChars()); } @@ -1330,19 +1330,19 @@ final class Parser(AST) : Lexer if (token.value == TOKidentifier) { if (token.ident == Id.property) - stc = AST.STCproperty; + stc = AST.STC.property; else if (token.ident == Id.nogc) - stc = AST.STCnogc; + stc = AST.STC.nogc; else if (token.ident == Id.safe) - stc = AST.STCsafe; + stc = AST.STC.safe; else if (token.ident == Id.trusted) - stc = AST.STCtrusted; + stc = AST.STC.trusted; else if (token.ident == Id.system) - stc = AST.STCsystem; + stc = AST.STC.system; else if (token.ident == Id.disable) - stc = AST.STCdisable; + stc = AST.STC.disable; else if (token.ident == Id.future) - stc = AST.STCfuture; + stc = AST.STC.future; else { // Allow identifier, template instantiation, or function call @@ -1393,35 +1393,35 @@ final class Parser(AST) : Lexer switch (token.value) { case TOKconst: - stc = AST.STCconst; + stc = AST.STC.const_; break; case TOKimmutable: - stc = AST.STCimmutable; + stc = AST.STC.immutable_; break; case TOKshared: - stc = AST.STCshared; + stc = AST.STC.shared_; break; case TOKwild: - stc = AST.STCwild; + stc = AST.STC.wild; break; case TOKnothrow: - stc = AST.STCnothrow; + stc = AST.STC.nothrow_; break; case TOKpure: - stc = AST.STCpure; + stc = AST.STC.pure_; break; case TOKreturn: - stc = AST.STCreturn; + stc = AST.STC.return_; break; case TOKscope: - stc = AST.STCscope; + stc = AST.STC.scope_; break; case TOKat: @@ -1453,7 +1453,7 @@ final class Parser(AST) : Lexer StorageClass parseTypeCtor() { - StorageClass storageClass = AST.STCundefined; + StorageClass storageClass = AST.STC.undefined_; while (1) { @@ -1464,19 +1464,19 @@ final class Parser(AST) : Lexer switch (token.value) { case TOKconst: - stc = AST.STCconst; + stc = AST.STC.const_; break; case TOKimmutable: - stc = AST.STCimmutable; + stc = AST.STC.immutable_; break; case TOKshared: - stc = AST.STCshared; + stc = AST.STC.shared_; break; case TOKwild: - stc = AST.STCwild; + stc = AST.STC.wild; break; default: @@ -2372,7 +2372,7 @@ final class Parser(AST) : Lexer check(TOKrparen); stc = parsePostfix(stc, &udas); - if (stc & AST.STCstatic) + if (stc & AST.STC.static_) error(loc, "postblit cannot be static"); auto f = new AST.PostBlitDeclaration(loc, Loc(), stc, Id.postblit); @@ -2403,14 +2403,14 @@ final class Parser(AST) : Lexer stc = parsePostfix(stc, &udas); if (varargs != 0 || AST.Parameter.dim(parameters) != 0) { - if (stc & AST.STCstatic) + if (stc & AST.STC.static_) error(loc, "constructor cannot be static"); } - else if (StorageClass ss = stc & (AST.STCshared | AST.STCstatic)) // this() + else if (StorageClass ss = stc & (AST.STC.shared_ | AST.STC.static_)) // this() { - if (ss == AST.STCstatic) + if (ss == AST.STC.static_) error(loc, "use `static this()` to declare a static constructor"); - else if (ss == (AST.STCshared | AST.STCstatic)) + else if (ss == (AST.STC.shared_ | AST.STC.static_)) error(loc, "use `shared static this()` to declare a shared static constructor"); } @@ -2456,11 +2456,11 @@ final class Parser(AST) : Lexer check(TOKrparen); stc = parsePostfix(stc, &udas); - if (StorageClass ss = stc & (AST.STCshared | AST.STCstatic)) + if (StorageClass ss = stc & (AST.STC.shared_ | AST.STC.static_)) { - if (ss == AST.STCstatic) + if (ss == AST.STC.static_) error(loc, "use `static ~this()` to declare a static destructor"); - else if (ss == (AST.STCshared | AST.STCstatic)) + else if (ss == (AST.STC.shared_ | AST.STC.static_)) error(loc, "use `shared static ~this()` to declare a shared static destructor"); } @@ -2491,18 +2491,18 @@ final class Parser(AST) : Lexer check(TOKlparen); check(TOKrparen); - stc = parsePostfix(stc & ~AST.STC_TYPECTOR, null) | stc; - if (stc & AST.STCshared) + stc = parsePostfix(stc & ~AST.STC.TYPECTOR, null) | stc; + if (stc & AST.STC.shared_) error(loc, "use `shared static this()` to declare a shared static constructor"); - else if (stc & AST.STCstatic) - appendStorageClass(stc, AST.STCstatic); // complaint for the redundancy - else if (StorageClass modStc = stc & AST.STC_TYPECTOR) + else if (stc & AST.STC.static_) + appendStorageClass(stc, AST.STC.static_); // complaint for the redundancy + else if (StorageClass modStc = stc & AST.STC.TYPECTOR) { OutBuffer buf; AST.stcToBuffer(&buf, modStc); error(loc, "static constructor cannot be `%s`", buf.peekString()); } - stc &= ~(AST.STCstatic | AST.STC_TYPECTOR); + stc &= ~(AST.STC.static_ | AST.STC.TYPECTOR); auto f = new AST.StaticCtorDeclaration(loc, Loc(), stc); AST.Dsymbol s = parseContracts(f); @@ -2526,18 +2526,18 @@ final class Parser(AST) : Lexer check(TOKlparen); check(TOKrparen); - stc = parsePostfix(stc & ~AST.STC_TYPECTOR, &udas) | stc; - if (stc & AST.STCshared) + stc = parsePostfix(stc & ~AST.STC.TYPECTOR, &udas) | stc; + if (stc & AST.STC.shared_) error(loc, "use `shared static ~this()` to declare a shared static destructor"); - else if (stc & AST.STCstatic) - appendStorageClass(stc, AST.STCstatic); // complaint for the redundancy - else if (StorageClass modStc = stc & AST.STC_TYPECTOR) + else if (stc & AST.STC.static_) + appendStorageClass(stc, AST.STC.static_); // complaint for the redundancy + else if (StorageClass modStc = stc & AST.STC.TYPECTOR) { OutBuffer buf; AST.stcToBuffer(&buf, modStc); error(loc, "static destructor cannot be `%s`", buf.peekString()); } - stc &= ~(AST.STCstatic | AST.STC_TYPECTOR); + stc &= ~(AST.STC.static_ | AST.STC.TYPECTOR); auto f = new AST.StaticDtorDeclaration(loc, Loc(), stc); AST.Dsymbol s = parseContracts(f); @@ -2567,16 +2567,16 @@ final class Parser(AST) : Lexer check(TOKlparen); check(TOKrparen); - stc = parsePostfix(stc & ~AST.STC_TYPECTOR, null) | stc; - if (StorageClass ss = stc & (AST.STCshared | AST.STCstatic)) + stc = parsePostfix(stc & ~AST.STC.TYPECTOR, null) | stc; + if (StorageClass ss = stc & (AST.STC.shared_ | AST.STC.static_)) appendStorageClass(stc, ss); // complaint for the redundancy - else if (StorageClass modStc = stc & AST.STC_TYPECTOR) + else if (StorageClass modStc = stc & AST.STC.TYPECTOR) { OutBuffer buf; AST.stcToBuffer(&buf, modStc); error(loc, "shared static constructor cannot be `%s`", buf.peekString()); } - stc &= ~(AST.STCstatic | AST.STC_TYPECTOR); + stc &= ~(AST.STC.static_ | AST.STC.TYPECTOR); auto f = new AST.SharedStaticCtorDeclaration(loc, Loc(), stc); AST.Dsymbol s = parseContracts(f); @@ -2601,16 +2601,16 @@ final class Parser(AST) : Lexer check(TOKlparen); check(TOKrparen); - stc = parsePostfix(stc & ~AST.STC_TYPECTOR, &udas) | stc; - if (StorageClass ss = stc & (AST.STCshared | AST.STCstatic)) + stc = parsePostfix(stc & ~AST.STC.TYPECTOR, &udas) | stc; + if (StorageClass ss = stc & (AST.STC.shared_ | AST.STC.static_)) appendStorageClass(stc, ss); // complaint for the redundancy - else if (StorageClass modStc = stc & AST.STC_TYPECTOR) + else if (StorageClass modStc = stc & AST.STC.TYPECTOR) { OutBuffer buf; AST.stcToBuffer(&buf, modStc); error(loc, "shared static destructor cannot be `%s`", buf.peekString()); } - stc &= ~(AST.STCstatic | AST.STC_TYPECTOR); + stc &= ~(AST.STC.static_ | AST.STC.TYPECTOR); auto f = new AST.SharedStaticDtorDeclaration(loc, Loc(), stc); AST.Dsymbol s = parseContracts(f); @@ -2760,57 +2760,57 @@ final class Parser(AST) : Lexer case TOKconst: if (peek(&token).value == TOKlparen) goto default; - stc = AST.STCconst; + stc = AST.STC.const_; goto L2; case TOKimmutable: if (peek(&token).value == TOKlparen) goto default; - stc = AST.STCimmutable; + stc = AST.STC.immutable_; goto L2; case TOKshared: if (peek(&token).value == TOKlparen) goto default; - stc = AST.STCshared; + stc = AST.STC.shared_; goto L2; case TOKwild: if (peek(&token).value == TOKlparen) goto default; - stc = AST.STCwild; + stc = AST.STC.wild; goto L2; case TOKin: - stc = AST.STCin; + stc = AST.STC.in_; goto L2; case TOKout: - stc = AST.STCout; + stc = AST.STC.out_; goto L2; case TOKref: - stc = AST.STCref; + stc = AST.STC.ref_; goto L2; case TOKlazy: - stc = AST.STClazy; + stc = AST.STC.lazy_; goto L2; case TOKscope: - stc = AST.STCscope; + stc = AST.STC.scope_; goto L2; case TOKfinal: - stc = AST.STCfinal; + stc = AST.STC.final_; goto L2; case TOKauto: - stc = AST.STCauto; + stc = AST.STC.auto_; goto L2; case TOKreturn: - stc = AST.STCreturn; + stc = AST.STC.return_; goto L2; L2: storageClass = appendStorageClass(storageClass, stc); @@ -2819,15 +2819,15 @@ final class Parser(AST) : Lexer version (none) { case TOKstatic: - stc = STCstatic; + stc = STC.static_; goto L2; case TOKauto: - storageClass = STCauto; + storageClass = STC.auto_; goto L4; case TOKalias: - storageClass = STCalias; + storageClass = STC.alias_; goto L4; L4: nextToken(); @@ -2855,11 +2855,11 @@ final class Parser(AST) : Lexer } default: { - stc = storageClass & (AST.STCin | AST.STCout | AST.STCref | AST.STClazy); + stc = storageClass & (AST.STC.in_ | AST.STC.out_ | AST.STC.ref_ | AST.STC.lazy_); // if stc is not a power of 2 - if (stc & (stc - 1) && !(stc == (AST.STCin | AST.STCref))) + if (stc & (stc - 1) && !(stc == (AST.STC.in_ | AST.STC.ref_))) error("incompatible parameter storage classes"); - //if ((storageClass & STCscope) && (storageClass & (STCref | STCout))) + //if ((storageClass & STC.scope_) && (storageClass & (STC.ref_ | STC.out_))) //error("scope cannot be ref or out"); if (tpl && token.value == TOKidentifier) @@ -2902,7 +2902,7 @@ final class Parser(AST) : Lexer /* This is: * at ai ... */ - if (storageClass & (AST.STCout | AST.STCref)) + if (storageClass & (AST.STC.out_ | AST.STC.ref_)) error("variadic argument cannot be `out` or `ref`"); varargs = 2; parameters.push(new AST.Parameter(storageClass, at, ai, ae)); @@ -3327,28 +3327,28 @@ final class Parser(AST) : Lexer case TOKconst: if (peekNext() == TOKlparen) break; // const as type constructor - stc |= AST.STCconst; // const as storage class + stc |= AST.STC.const_; // const as storage class nextToken(); continue; case TOKimmutable: if (peekNext() == TOKlparen) break; - stc |= AST.STCimmutable; + stc |= AST.STC.immutable_; nextToken(); continue; case TOKshared: if (peekNext() == TOKlparen) break; - stc |= AST.STCshared; + stc |= AST.STC.shared_; nextToken(); continue; case TOKwild: if (peekNext() == TOKlparen) break; - stc |= AST.STCwild; + stc |= AST.STC.wild; nextToken(); continue; @@ -3514,7 +3514,7 @@ final class Parser(AST) : Lexer // const(type) nextToken(); check(TOKlparen); - t = parseType().addSTC(AST.STCconst); + t = parseType().addSTC(AST.STC.const_); check(TOKrparen); break; @@ -3522,7 +3522,7 @@ final class Parser(AST) : Lexer // immutable(type) nextToken(); check(TOKlparen); - t = parseType().addSTC(AST.STCimmutable); + t = parseType().addSTC(AST.STC.immutable_); check(TOKrparen); break; @@ -3530,7 +3530,7 @@ final class Parser(AST) : Lexer // shared(type) nextToken(); check(TOKlparen); - t = parseType().addSTC(AST.STCshared); + t = parseType().addSTC(AST.STC.shared_); check(TOKrparen); break; @@ -3538,7 +3538,7 @@ final class Parser(AST) : Lexer // wild(type) nextToken(); check(TOKlparen); - t = parseType().addSTC(AST.STCwild); + t = parseType().addSTC(AST.STC.wild); check(TOKrparen); break; @@ -3756,9 +3756,9 @@ final class Parser(AST) : Lexer int varargs; AST.Parameters* parameters = parseParameters(&varargs); - StorageClass stc = parsePostfix(AST.STCundefined, null); + StorageClass stc = parsePostfix(AST.STC.undefined_, null); auto tf = new AST.TypeFunction(parameters, t, varargs, linkage, stc); - if (stc & (AST.STCconst | AST.STCimmutable | AST.STCshared | AST.STCwild | AST.STCreturn)) + if (stc & (AST.STC.const_ | AST.STC.immutable_ | AST.STC.shared_ | AST.STC.wild | AST.STC.return_)) { if (save == TOKfunction) error("const/immutable/shared/inout/return attributes are only valid for non-static member functions"); @@ -3926,7 +3926,7 @@ final class Parser(AST) : Lexer AST.Type tf = new AST.TypeFunction(parameters, t, varargs, linkage, stc); tf = tf.addSTC(stc); if (pdisable) - *pdisable = stc & AST.STCdisable ? 1 : 0; + *pdisable = stc & AST.STC.disable ? 1 : 0; /* Insert tf into * ts -> ... -> t @@ -3961,77 +3961,77 @@ final class Parser(AST) : Lexer case TOKconst: if (peek(&token).value == TOKlparen) break; // const as type constructor - stc = AST.STCconst; // const as storage class + stc = AST.STC.const_; // const as storage class goto L1; case TOKimmutable: if (peek(&token).value == TOKlparen) break; - stc = AST.STCimmutable; + stc = AST.STC.immutable_; goto L1; case TOKshared: if (peek(&token).value == TOKlparen) break; - stc = AST.STCshared; + stc = AST.STC.shared_; goto L1; case TOKwild: if (peek(&token).value == TOKlparen) break; - stc = AST.STCwild; + stc = AST.STC.wild; goto L1; case TOKstatic: - stc = AST.STCstatic; + stc = AST.STC.static_; goto L1; case TOKfinal: - stc = AST.STCfinal; + stc = AST.STC.final_; goto L1; case TOKauto: - stc = AST.STCauto; + stc = AST.STC.auto_; goto L1; case TOKscope: - stc = AST.STCscope; + stc = AST.STC.scope_; goto L1; case TOKoverride: - stc = AST.STCoverride; + stc = AST.STC.override_; goto L1; case TOKabstract: - stc = AST.STCabstract; + stc = AST.STC.abstract_; goto L1; case TOKsynchronized: - stc = AST.STCsynchronized; + stc = AST.STC.synchronized_; goto L1; case TOKdeprecated: - stc = AST.STCdeprecated; + stc = AST.STC.deprecated_; goto L1; case TOKnothrow: - stc = AST.STCnothrow; + stc = AST.STC.nothrow_; goto L1; case TOKpure: - stc = AST.STCpure; + stc = AST.STC.pure_; goto L1; case TOKref: - stc = AST.STCref; + stc = AST.STC.ref_; goto L1; case TOKgshared: - stc = AST.STCgshared; + stc = AST.STC.gshared; goto L1; case TOKenum: - stc = AST.STCmanifest; + stc = AST.STC.manifest; goto L1; case TOKat: @@ -4050,7 +4050,7 @@ final class Parser(AST) : Lexer { if (peek(&token).value != TOKlparen) { - stc = AST.STCextern; + stc = AST.STC.extern_; goto L1; } @@ -4098,7 +4098,7 @@ final class Parser(AST) : Lexer */ AST.Dsymbols* parseDeclarations(bool autodecl, PrefixAttributes!AST* pAttrs, const(char)* comment) { - StorageClass storage_class = AST.STCundefined; + StorageClass storage_class = AST.STC.undefined_; AST.Type ts; AST.Type t; AST.Type tfirst; @@ -4198,7 +4198,7 @@ final class Parser(AST) : Lexer { // StorageClasses type - storage_class = AST.STCundefined; + storage_class = AST.STC.undefined_; link = linkage; setAlignment = false; ealign = null; @@ -4342,7 +4342,7 @@ final class Parser(AST) : Lexer if (pAttrs) { storage_class |= pAttrs.storageClass; - //pAttrs.storageClass = STCundefined; + //pAttrs.storageClass = STC.undefined_; } while (1) @@ -4404,7 +4404,7 @@ final class Parser(AST) : Lexer * alias @safe void function() FP2; // FP2 is not @safe * alias void function() @safe FP3; */ - pAttrs.storageClass &= (AST.STCsafe | AST.STCsystem | AST.STCtrusted); + pAttrs.storageClass &= (AST.STC.safe | AST.STC.system | AST.STC.trusted); } AST.Dsymbol s = v; @@ -4446,9 +4446,9 @@ final class Parser(AST) : Lexer } //printf("%s funcdecl t = %s, storage_class = x%lx\n", loc.toChars(), t.toChars(), storage_class); - auto f = new AST.FuncDeclaration(loc, Loc(), ident, storage_class | (disable ? AST.STCdisable : 0), t); + auto f = new AST.FuncDeclaration(loc, Loc(), ident, storage_class | (disable ? AST.STC.disable : 0), t); if (pAttrs) - pAttrs.storageClass = AST.STCundefined; + pAttrs.storageClass = AST.STC.undefined_; if (tpl) constraint = parseConstraint(); AST.Dsymbol s = parseContracts(f); @@ -4477,13 +4477,13 @@ final class Parser(AST) : Lexer auto tempdecl = new AST.TemplateDeclaration(loc, tplIdent, tpl, constraint, decldefs); s = tempdecl; - if (storage_class & AST.STCstatic) + if (storage_class & AST.STC.static_) { - assert(f.storage_class & AST.STCstatic); - f.storage_class &= ~AST.STCstatic; + assert(f.storage_class & AST.STC.static_); + f.storage_class &= ~AST.STC.static_; auto ax = new AST.Dsymbols(); ax.push(s); - s = new AST.StorageClassDeclaration(AST.STCstatic, ax); + s = new AST.StorageClassDeclaration(AST.STC.static_, ax); } } a.push(s); @@ -4501,7 +4501,7 @@ final class Parser(AST) : Lexer auto v = new AST.VarDeclaration(loc, t, ident, _init); v.storage_class = storage_class; if (pAttrs) - pAttrs.storageClass = AST.STCundefined; + pAttrs.storageClass = AST.STC.undefined_; AST.Dsymbol s = v; @@ -4595,8 +4595,8 @@ final class Parser(AST) : Lexer // (parameters) => expression // (parameters) { statements... } parameters = parseParameters(&varargs, &tpl); - stc = parsePostfix(AST.STCundefined, null); - if (StorageClass modStc = stc & AST.STC_TYPECTOR) + stc = parsePostfix(AST.STC.undefined_, null); + if (StorageClass modStc = stc & AST.STC.TYPECTOR) { if (save == TOKfunction) { @@ -4890,22 +4890,22 @@ final class Parser(AST) : Lexer switch (token.value) { case TOKref: - stc = AST.STCref; + stc = AST.STC.ref_; goto Lagain; case TOKenum: - stc = AST.STCmanifest; + stc = AST.STC.manifest; goto Lagain; case TOKalias: - storageClass = appendStorageClass(storageClass, AST.STCalias); + storageClass = appendStorageClass(storageClass, AST.STC.alias_); nextToken(); break; case TOKconst: if (peekNext() != TOKlparen) { - stc = AST.STCconst; + stc = AST.STC.const_; goto Lagain; } break; @@ -4913,7 +4913,7 @@ final class Parser(AST) : Lexer case TOKimmutable: if (peekNext() != TOKlparen) { - stc = AST.STCimmutable; + stc = AST.STC.immutable_; goto Lagain; } break; @@ -4921,7 +4921,7 @@ final class Parser(AST) : Lexer case TOKshared: if (peekNext() != TOKlparen) { - stc = AST.STCshared; + stc = AST.STC.shared_; goto Lagain; } break; @@ -4929,7 +4929,7 @@ final class Parser(AST) : Lexer case TOKwild: if (peekNext() != TOKlparen) { - stc = AST.STCwild; + stc = AST.STC.wild; goto Lagain; } break; @@ -5452,17 +5452,17 @@ final class Parser(AST) : Lexer switch (token.value) { case TOKref: - stc = AST.STCref; + stc = AST.STC.ref_; goto LagainStc; case TOKauto: - stc = AST.STCauto; + stc = AST.STC.auto_; goto LagainStc; case TOKconst: if (peekNext() != TOKlparen) { - stc = AST.STCconst; + stc = AST.STC.const_; goto LagainStc; } break; @@ -5470,7 +5470,7 @@ final class Parser(AST) : Lexer case TOKimmutable: if (peekNext() != TOKlparen) { - stc = AST.STCimmutable; + stc = AST.STC.immutable_; goto LagainStc; } break; @@ -5478,7 +5478,7 @@ final class Parser(AST) : Lexer case TOKshared: if (peekNext() != TOKlparen) { - stc = AST.STCshared; + stc = AST.STC.shared_; goto LagainStc; } break; @@ -5486,7 +5486,7 @@ final class Parser(AST) : Lexer case TOKwild: if (peekNext() != TOKlparen) { - stc = AST.STCwild; + stc = AST.STC.wild; goto LagainStc; } break; @@ -5916,8 +5916,8 @@ final class Parser(AST) : Lexer Loc labelloc; nextToken(); - StorageClass stc = parsePostfix(AST.STCundefined, null); - if (stc & (AST.STCconst | AST.STCimmutable | AST.STCshared | AST.STCwild)) + StorageClass stc = parsePostfix(AST.STC.undefined_, null); + if (stc & (AST.STC.const_ | AST.STC.immutable_ | AST.STC.shared_ | AST.STC.wild)) error("const/immutable/shared/inout attributes are not allowed on `asm` blocks"); check(TOKlcurly); diff --git a/src/dmd/semantic2.d b/src/dmd/semantic2.d index 5dea977ef74c..e7ca29604e17 100644 --- a/src/dmd/semantic2.d +++ b/src/dmd/semantic2.d @@ -254,7 +254,7 @@ private extern(C++) final class Semantic2Visitor : Visitor vd._init = vd._init.initializerSemantic(sc, vd.type, sc.intypeof == 1 ? INITnointerpret : INITinterpret); vd.inuse--; } - if (vd._init && vd.storage_class & STCmanifest) + if (vd._init && vd.storage_class & STC.manifest) { /* Cannot initializer enums with CTFE classreferences and addresses of struct literals. * Scan initializer looking for them. Issue error if found. diff --git a/src/dmd/semantic3.d b/src/dmd/semantic3.d index 1632a07f6a17..cdc59d68e3b3 100644 --- a/src/dmd/semantic3.d +++ b/src/dmd/semantic3.d @@ -230,7 +230,7 @@ private extern(C++) final class Semantic3Visitor : Visitor if (funcdecl.ident == Id.assign && !funcdecl.inuse) { - if (funcdecl.storage_class & STCinference) + if (funcdecl.storage_class & STC.inference) { /* https://issues.dlang.org/show_bug.cgi?id=15044 * For generated opAssign function, any errors @@ -243,7 +243,7 @@ private extern(C++) final class Semantic3Visitor : Visitor if (global.endGagging(oldErrors)) // if errors happened { // Disable generated opAssign, because some members forbid identity assignment. - funcdecl.storage_class |= STCdisable; + funcdecl.storage_class |= STC.disable; funcdecl.fbody = null; // remove fbody which contains the error funcdecl.semantic3Errors = false; } @@ -316,7 +316,7 @@ private extern(C++) final class Semantic3Visitor : Visitor sc2.sw = null; sc2.fes = funcdecl.fes; sc2.linkage = LINKd; - sc2.stc &= ~(STCauto | STCscope | STCstatic | STCabstract | STCdeprecated | STCoverride | STC_TYPECTOR | STCfinal | STCtls | STCgshared | STCref | STCreturn | STCproperty | STCnothrow | STCpure | STCsafe | STCtrusted | STCsystem); + sc2.stc &= ~(STC.auto_ | STC.scope_ | STC.static_ | STC.abstract_ | STC.deprecated_ | STC.override_ | STC.TYPECTOR | STC.final_ | STC.tls | STC.gshared | STC.ref_ | STC.return_ | STC.property | STC.nothrow_ | STC.pure_ | STC.safe | STC.trusted | STC.system); sc2.protection = Prot(PROTpublic); sc2.explicitProtection = 0; sc2.aligndecl = null; @@ -378,7 +378,7 @@ private extern(C++) final class Semantic3Visitor : Visitor { // Declare _arguments[] funcdecl.v_arguments = new VarDeclaration(Loc(), Type.typeinfotypelist.type, Id._arguments_typeinfo, null); - funcdecl.v_arguments.storage_class |= STCtemp | STCparameter; + funcdecl.v_arguments.storage_class |= STC.temp | STC.parameter; funcdecl.v_arguments.dsymbolSemantic(sc2); sc2.insert(funcdecl.v_arguments); funcdecl.v_arguments.parent = funcdecl; @@ -386,7 +386,7 @@ private extern(C++) final class Semantic3Visitor : Visitor //Type *t = Type::typeinfo.type.constOf().arrayOf(); Type t = Type.dtypeinfo.type.arrayOf(); _arguments = new VarDeclaration(Loc(), t, Id._arguments, null); - _arguments.storage_class |= STCtemp; + _arguments.storage_class |= STC.temp; _arguments.dsymbolSemantic(sc2); sc2.insert(_arguments); _arguments.parent = funcdecl; @@ -397,7 +397,7 @@ private extern(C++) final class Semantic3Visitor : Visitor Type t = Type.tvalist; // Init is handled in FuncDeclaration_toObjFile funcdecl.v_argptr = new VarDeclaration(Loc(), t, Id._argptr, new VoidInitializer(funcdecl.loc)); - funcdecl.v_argptr.storage_class |= STCtemp; + funcdecl.v_argptr.storage_class |= STC.temp; funcdecl.v_argptr.dsymbolSemantic(sc2); sc2.insert(funcdecl.v_argptr); funcdecl.v_argptr.parent = funcdecl; @@ -426,17 +426,17 @@ private extern(C++) final class Semantic3Visitor : Visitor * because we need it later on. */ fparam.ident = id = Identifier.generateId("_param_", i); - stc |= STCtemp; + stc |= STC.temp; } Type vtype = fparam.type; auto v = new VarDeclaration(funcdecl.loc, vtype, id, null); //printf("declaring parameter %s of type %s\n", v.toChars(), v.type.toChars()); - stc |= STCparameter; + stc |= STC.parameter; if (f.varargs == 2 && i + 1 == nparams) - stc |= STCvariadic; - if (funcdecl.flags & FUNCFLAG.inferScope && !(fparam.storageClass & STCscope)) - stc |= STCmaybescope; - stc |= fparam.storageClass & (STCin | STCout | STCref | STCreturn | STCscope | STClazy | STCfinal | STC_TYPECTOR | STCnodtor); + stc |= STC.variadic; + if (funcdecl.flags & FUNCFLAG.inferScope && !(fparam.storageClass & STC.scope_)) + stc |= STC.maybescope; + stc |= fparam.storageClass & (STC.in_ | STC.out_ | STC.ref_ | STC.return_ | STC.scope_ | STC.lazy_ | STC.final_ | STC.TYPECTOR | STC.nodtor); v.storage_class = stc; v.dsymbolSemantic(sc2); if (!sc2.insert(v)) @@ -557,7 +557,7 @@ private extern(C++) final class Semantic3Visitor : Visitor if (!funcdecl.inferRetType && retStyle(f) != RETstack) funcdecl.nrvo_can = 0; - bool inferRef = (f.isref && (funcdecl.storage_class & STCauto)); + bool inferRef = (f.isref && (funcdecl.storage_class & STC.auto_)); funcdecl.fbody = funcdecl.fbody.statementSemantic(sc2); if (!funcdecl.fbody) @@ -605,8 +605,8 @@ private extern(C++) final class Semantic3Visitor : Visitor } if (f.isref) // Function returns a reference { - if (funcdecl.storage_class & STCauto) - funcdecl.storage_class &= ~STCauto; + if (funcdecl.storage_class & STC.auto_) + funcdecl.storage_class &= ~STC.auto_; } if (retStyle(f) != RETstack) funcdecl.nrvo_can = 0; @@ -647,14 +647,14 @@ private extern(C++) final class Semantic3Visitor : Visitor */ if (v.isCtorinit() && !v.type.isMutable() && cd) funcdecl.error("missing initializer for %s field `%s`", MODtoChars(v.type.mod), v.toChars()); - else if (v.storage_class & STCnodefaultctor) + else if (v.storage_class & STC.nodefaultctor) error(funcdecl.loc, "field `%s` must be initialized in constructor", v.toChars()); else if (v.type.needsNested()) error(funcdecl.loc, "field `%s` must be initialized in constructor, because it is nested struct", v.toChars()); } else { - bool mustInit = (v.storage_class & STCnodefaultctor || v.type.needsNested()); + bool mustInit = (v.storage_class & STC.nodefaultctor || v.type.needsNested()); if (mustInit && !(sc2.fieldinit[i] & CSXthis_ctor)) { funcdecl.error("field `%s` must be initialized but skipped", v.toChars()); @@ -674,7 +674,7 @@ private extern(C++) final class Semantic3Visitor : Visitor { funcdecl.error("no match for implicit `super()` call in constructor"); } - else if (fd.storage_class & STCdisable) + else if (fd.storage_class & STC.disable) { funcdecl.error("cannot call `super()` implicitly because it is annotated with `@disable`"); } @@ -934,7 +934,7 @@ private extern(C++) final class Semantic3Visitor : Visitor for (size_t i = 0; i < funcdecl.parameters.dim; i++) { VarDeclaration v = (*funcdecl.parameters)[i]; - if (v.storage_class & STCout) + if (v.storage_class & STC.out_) { assert(v._init); ExpInitializer ie = v._init.isExpInitializer(); @@ -1015,13 +1015,13 @@ private extern(C++) final class Semantic3Visitor : Visitor { foreach (v; *funcdecl.parameters) { - if (v.storage_class & (STCref | STCout | STClazy)) + if (v.storage_class & (STC.ref_ | STC.out_ | STC.lazy_)) continue; if (v.needsScopeDtor()) { // same with ExpStatement.scopeCode() Statement s = new DtorExpStatement(Loc(), v.edtor, v); - v.storage_class |= STCnodtor; + v.storage_class |= STC.nodtor; s = s.statementSemantic(sc2); @@ -1137,7 +1137,7 @@ private extern(C++) final class Semantic3Visitor : Visitor if (funcdecl.flags & FUNCFLAG.returnInprocess) { funcdecl.flags &= ~FUNCFLAG.returnInprocess; - if (funcdecl.storage_class & STCreturn) + if (funcdecl.storage_class & STC.return_) { if (funcdecl.type == f) f = cast(TypeFunction)f.copy(); @@ -1147,29 +1147,29 @@ private extern(C++) final class Semantic3Visitor : Visitor funcdecl.flags &= ~FUNCFLAG.inferScope; - // Infer STCscope + // Infer STC.scope_ if (funcdecl.parameters && !funcdecl.errors) { size_t nfparams = Parameter.dim(f.parameters); assert(nfparams == funcdecl.parameters.dim); foreach (u, v; *funcdecl.parameters) { - if (v.storage_class & STCmaybescope) + if (v.storage_class & STC.maybescope) { //printf("Inferring scope for %s\n", v.toChars()); Parameter p = Parameter.getNth(f.parameters, u); - v.storage_class &= ~STCmaybescope; - v.storage_class |= STCscope | STCscopeinferred; - p.storageClass |= STCscope | STCscopeinferred; - assert(!(p.storageClass & STCmaybescope)); + v.storage_class &= ~STC.maybescope; + v.storage_class |= STC.scope_ | STC.scopeinferred; + p.storageClass |= STC.scope_ | STC.scopeinferred; + assert(!(p.storageClass & STC.maybescope)); } } } - if (funcdecl.vthis && funcdecl.vthis.storage_class & STCmaybescope) + if (funcdecl.vthis && funcdecl.vthis.storage_class & STC.maybescope) { - funcdecl.vthis.storage_class &= ~STCmaybescope; - funcdecl.vthis.storage_class |= STCscope | STCscopeinferred; + funcdecl.vthis.storage_class &= ~STC.maybescope; + funcdecl.vthis.storage_class |= STC.scope_ | STC.scopeinferred; f.isscope = true; f.isscopeinferred = true; } @@ -1276,7 +1276,7 @@ private extern(C++) final class Semantic3Visitor : Visitor sc3.tinst = sc.tinst; sc3.minst = sc.minst; if (ad.isDeprecated()) - sc3.stc |= STCdeprecated; + sc3.stc |= STC.deprecated_; ti.dsymbolSemantic(sc3); ti.semantic2(sc3); diff --git a/src/dmd/sideeffect.d b/src/dmd/sideeffect.d index 7eb78d0b8d3e..20c8a9445128 100644 --- a/src/dmd/sideeffect.d +++ b/src/dmd/sideeffect.d @@ -240,7 +240,7 @@ extern (C++) bool discardValue(Expression e) case TOKvar: { VarDeclaration v = (cast(VarExp)e).var.isVarDeclaration(); - if (v && (v.storage_class & STCtemp)) + if (v && (v.storage_class & STC.temp)) { // https://issues.dlang.org/show_bug.cgi?id=5810 // Don't complain about an internal generated variable. @@ -371,8 +371,8 @@ VarDeclaration copyToTemp(StorageClass stc, const char* name, Expression e) auto ez = new ExpInitializer(e.loc, e); auto vd = new VarDeclaration(e.loc, e.type, id, ez); vd.storage_class = stc; - vd.storage_class |= STCtemp; - vd.storage_class |= STCctfe; // temporary is always CTFEable + vd.storage_class |= STC.temp; + vd.storage_class |= STC.ctfe; // temporary is always CTFEable return vd; } @@ -388,7 +388,7 @@ VarDeclaration copyToTemp(StorageClass stc, const char* name, Expression e) * When e is trivial and alwaysCopy == false, e itself is returned. * Otherwise, a new VarExp is returned. * Note: - * e's lvalue-ness will be handled well by STCref or STCrvalue. + * e's lvalue-ness will be handled well by STC.ref_ or STC.rvalue. */ Expression extractSideEffect(Scope* sc, const char* name, ref Expression e0, Expression e, bool alwaysCopy = false) @@ -398,9 +398,9 @@ Expression extractSideEffect(Scope* sc, const char* name, auto vd = copyToTemp(0, name, e); if (e.isLvalue()) - vd.storage_class |= STCref; + vd.storage_class |= STC.ref_; else - vd.storage_class |= STCrvalue; + vd.storage_class |= STC.rvalue; Expression de = new DeclarationExp(vd.loc, vd); Expression ve = new VarExp(vd.loc, vd); diff --git a/src/dmd/statement.d b/src/dmd/statement.d index f41cb17d6292..1f6a95313638 100644 --- a/src/dmd/statement.d +++ b/src/dmd/statement.d @@ -660,7 +660,7 @@ extern (C++) class ExpStatement : Statement { //printf("dtor is: "); v.edtor.print(); *sfinally = new DtorExpStatement(loc, v.edtor, v); - v.storage_class |= STCnodtor; // don't add in dtor again + v.storage_class |= STC.nodtor; // don't add in dtor again } } } @@ -1587,7 +1587,7 @@ extern (C++) final class SwitchStatement : Statement { bool checkVar(VarDeclaration vd) { - if (!vd || vd.isDataseg() || (vd.storage_class & STCmanifest)) + if (!vd || vd.isDataseg() || (vd.storage_class & STC.manifest)) return false; VarDeclaration last = lastVar; @@ -2243,7 +2243,7 @@ extern (C++) final class GotoStatement : Statement } VarDeclaration vd = label.statement.lastVar; - if (!vd || vd.isDataseg() || (vd.storage_class & STCmanifest)) + if (!vd || vd.isDataseg() || (vd.storage_class & STC.manifest)) return false; VarDeclaration last = lastVar; @@ -2253,7 +2253,7 @@ extern (C++) final class GotoStatement : Statement { // All good, the label's scope has no variables } - else if (vd.storage_class & STCexptemp) + else if (vd.storage_class & STC.exptemp) { // Lifetime ends at end of expression, so no issue with skipping the statement } diff --git a/src/dmd/statementsem.d b/src/dmd/statementsem.d index 731f71bace2f..d7f384588a60 100644 --- a/src/dmd/statementsem.d +++ b/src/dmd/statementsem.d @@ -605,12 +605,12 @@ private extern (C++) final class StatementSemanticVisitor : Visitor * - ForwardingStatement, for `static foreach` statements. * - ForwardingAttribDeclaration, for `static foreach` declarations. * - * `static foreach` variables are declared as `STClocal`, such + * `static foreach` variables are declared as `STC.local`, such * that they are inserted into the local symbol tables of the * forwarding constructs instead of forwarded. For `static * foreach` with multiple foreach loop variables whose aggregate * has been lowered into a sequence of tuples, this function - * expands the tuples into multiple `STClocal` `static foreach` + * expands the tuples into multiple `STC.local` `static foreach` * variables. */ MakeTupleForeachRet!isDecl makeTupleForeach(bool isStatic, bool isDecl)(ForeachStatement fs, TupleForeachArgs!(isStatic, isDecl) args) @@ -710,7 +710,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor if (!skip && dim == 2) { // Declare key - if (p.storageClass & (STCout | STCref | STClazy)) + if (p.storageClass & (STC.out_ | STC.ref_ | STC.lazy_)) { fs.error("no storage class for key `%s`", p.ident.toChars()); setError(); @@ -745,8 +745,8 @@ private extern (C++) final class StatementSemanticVisitor : Visitor } Initializer ie = new ExpInitializer(Loc(), new IntegerExp(k)); auto var = new VarDeclaration(loc, p.type, p.ident, ie); - var.storage_class |= STCmanifest; - static if(isStatic) var.storage_class |= STClocal; + var.storage_class |= STC.manifest; + static if(isStatic) var.storage_class |= STC.local; static if(!isDecl) { st.push(new ExpStatement(loc, var)); @@ -771,8 +771,8 @@ private extern (C++) final class StatementSemanticVisitor : Visitor */ bool declareVariable(StorageClass storageClass, Type type, Identifier ident, Expression e, Type t) { - if (storageClass & (STCout | STClazy) || - storageClass & STCref && !te) + if (storageClass & (STC.out_ | STC.lazy_) || + storageClass & STC.ref_ && !te) { fs.error("no storage class for value `%s`", ident.toChars()); setError(); @@ -783,9 +783,9 @@ private extern (C++) final class StatementSemanticVisitor : Visitor { Type tb = e.type.toBasetype(); Dsymbol ds = null; - if (!(storageClass & STCmanifest)) + if (!(storageClass & STC.manifest)) { - if ((isStatic || tb.ty == Tfunction || tb.ty == Tsarray || storageClass&STCalias) && e.op == TOKvar) + if ((isStatic || tb.ty == Tfunction || tb.ty == Tsarray || storageClass&STC.alias_) && e.op == TOKvar) ds = (cast(VarExp)e).var; else if (e.op == TOKtemplate) ds = (cast(TemplateExp)e).td; @@ -797,7 +797,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor ds = fe.td ? cast(Dsymbol)fe.td : fe.fd; } } - else if (storageClass & STCalias) + else if (storageClass & STC.alias_) { fs.error("foreach loop variable cannot be both enum and alias"); setError(); @@ -807,7 +807,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor if (ds) { var = new AliasDeclaration(loc, ident, ds); - if (storageClass & STCref) + if (storageClass & STC.ref_) { fs.error("symbol `%s` cannot be ref", ds.toChars()); setError(); @@ -838,14 +838,14 @@ private extern (C++) final class StatementSemanticVisitor : Visitor type = paramtype; Initializer ie = new ExpInitializer(Loc(), e); auto v = new VarDeclaration(loc, type, ident, ie); - if (storageClass & STCref) - v.storage_class |= STCref | STCforeach; - if (isStatic || storageClass&STCmanifest || e.isConst() || + if (storageClass & STC.ref_) + v.storage_class |= STC.ref_ | STC.foreach_; + if (isStatic || storageClass&STC.manifest || e.isConst() || e.op == TOKstring || e.op == TOKstructliteral || e.op == TOKarrayliteral) { - if (v.storage_class & STCref) + if (v.storage_class & STC.ref_) { static if (!isStatic) { @@ -866,7 +866,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor return false; } else - v.storage_class |= STCmanifest; + v.storage_class |= STC.manifest; } var = v; } @@ -883,7 +883,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor } static if (isStatic) { - var.storage_class |= STClocal; + var.storage_class |= STC.local; } static if (!isDecl) { @@ -1025,7 +1025,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor { // https://issues.dlang.org/show_bug.cgi?id=14653 // Extend the life of rvalue aggregate till the end of foreach. - vinit = copyToTemp(STCrvalue, "__aggr", fs.aggr); + vinit = copyToTemp(STC.rvalue, "__aggr", fs.aggr); vinit.endlinnum = fs.endloc.linnum; vinit.dsymbolSemantic(sc); fs.aggr = new VarExp(fs.aggr.loc, vinit); @@ -1111,11 +1111,11 @@ private extern (C++) final class StatementSemanticVisitor : Visitor foreach (i; 0 .. dim) { Parameter p = (*fs.parameters)[i]; - if (p.storageClass & STCmanifest) + if (p.storageClass & STC.manifest) { fs.error("cannot declare enum loop variables for non-unrolled foreach"); } - if (p.storageClass & STCalias) + if (p.storageClass & STC.alias_) { fs.error("cannot declare alias loop variables for non-unrolled foreach"); } @@ -1152,7 +1152,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor if (tnv.ty != tn.ty && (tnv.ty == Tchar || tnv.ty == Twchar || tnv.ty == Tdchar)) { - if (p.storageClass & STCref) + if (p.storageClass & STC.ref_) { fs.error("foreach: value of UTF conversion cannot be ref"); goto case Terror; @@ -1160,7 +1160,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor if (dim == 2) { p = (*fs.parameters)[0]; - if (p.storageClass & STCref) + if (p.storageClass & STC.ref_) { fs.error("foreach: key cannot be ref"); goto case Terror; @@ -1181,12 +1181,12 @@ private extern (C++) final class StatementSemanticVisitor : Visitor if (dim == 2 && i == 0) { var = new VarDeclaration(loc, p.type.mutableOf(), Identifier.generateId("__key"), null); - var.storage_class |= STCtemp | STCforeach; - if (var.storage_class & (STCref | STCout)) - var.storage_class |= STCnodtor; + var.storage_class |= STC.temp | STC.foreach_; + if (var.storage_class & (STC.ref_ | STC.out_)) + var.storage_class |= STC.nodtor; fs.key = var; - if (p.storageClass & STCref) + if (p.storageClass & STC.ref_) { if (var.type.constConv(p.type) <= MATCH.nomatch) { @@ -1211,16 +1211,16 @@ private extern (C++) final class StatementSemanticVisitor : Visitor else { var = new VarDeclaration(loc, p.type, p.ident, null); - var.storage_class |= STCforeach; - var.storage_class |= p.storageClass & (STCin | STCout | STCref | STC_TYPECTOR); - if (var.storage_class & (STCref | STCout)) - var.storage_class |= STCnodtor; + var.storage_class |= STC.foreach_; + var.storage_class |= p.storageClass & (STC.in_ | STC.out_ | STC.ref_ | STC.TYPECTOR); + if (var.storage_class & (STC.ref_ | STC.out_)) + var.storage_class |= STC.nodtor; fs.value = var; - if (var.storage_class & STCref) + if (var.storage_class & STC.ref_) { if (fs.aggr.checkModifiable(sc2, 1) == 2) - var.storage_class |= STCctorinit; + var.storage_class |= STC.ctorinit; Type t = tab.nextOf(); if (t.constConv(p.type) <= MATCH.nomatch) @@ -1246,7 +1246,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor auto ie = new ExpInitializer(loc, new SliceExp(loc, fs.aggr, null, null)); VarDeclaration tmp; if (fs.aggr.op == TOKarrayliteral && - !((*fs.parameters)[dim - 1].storageClass & STCref)) + !((*fs.parameters)[dim - 1].storageClass & STC.ref_)) { auto ale = cast(ArrayLiteralExp)fs.aggr; size_t edim = ale.elements ? ale.elements.dim : 0; @@ -1264,7 +1264,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor } else tmp = new VarDeclaration(loc, tab.nextOf().arrayOf(), id, ie); - tmp.storage_class |= STCtemp; + tmp.storage_class |= STC.temp; Expression tmp_length = new DotIdExp(loc, new VarExp(loc, tmp), Id.length); @@ -1272,7 +1272,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor { Identifier idkey = Identifier.generateId("__key"); fs.key = new VarDeclaration(loc, Type.tsize_t, idkey, null); - fs.key.storage_class |= STCtemp; + fs.key.storage_class |= STC.temp; } if (fs.op == TOKforeach_reverse) fs.key._init = new ExpInitializer(loc, tmp_length); @@ -1314,7 +1314,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor if (dim == 2) { Parameter p = (*fs.parameters)[0]; - if ((p.storageClass & STCref) && p.type.equals(fs.key.type)) + if ((p.storageClass & STC.ref_) && p.type.equals(fs.key.type)) { fs.key.range = null; auto v = new AliasDeclaration(loc, p.ident, fs.key); @@ -1324,7 +1324,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor { auto ei = new ExpInitializer(loc, new IdentifierExp(loc, fs.key.ident)); auto v = new VarDeclaration(loc, p.type, p.ident, ei); - v.storage_class |= STCforeach | (p.storageClass & STCref); + v.storage_class |= STC.foreach_ | (p.storageClass & STC.ref_); fs._body = new CompoundStatement(loc, new ExpStatement(loc, v), fs._body); if (fs.key.range && !p.type.isMutable()) { @@ -1432,14 +1432,14 @@ private extern (C++) final class StatementSemanticVisitor : Visitor { auto p = (*fs.parameters)[0]; auto ve = new VarDeclaration(loc, p.type, p.ident, new ExpInitializer(loc, einit)); - ve.storage_class |= STCforeach; - ve.storage_class |= p.storageClass & (STCin | STCout | STCref | STC_TYPECTOR); + ve.storage_class |= STC.foreach_; + ve.storage_class |= p.storageClass & (STC.in_ | STC.out_ | STC.ref_ | STC.TYPECTOR); makeargs = new ExpStatement(loc, ve); } else { - auto vd = copyToTemp(STCref, "__front", einit); + auto vd = copyToTemp(STC.ref_, "__front", einit); vd.dsymbolSemantic(sc); makeargs = new ExpStatement(loc, vd); @@ -1510,7 +1510,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor goto Lrangeerr; auto var = new VarDeclaration(loc, p.type, p.ident, new ExpInitializer(loc, exp)); - var.storage_class |= STCctfe | STCref | STCforeach; + var.storage_class |= STC.ctfe | STC.ref_ | STC.foreach_; makeargs = new CompoundStatement(loc, makeargs, new ExpStatement(loc, var)); } } @@ -1583,7 +1583,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor foreach (i; 0 .. dim) { Parameter p = (*fs.parameters)[i]; - StorageClass stc = STCref; + StorageClass stc = STC.ref_; Identifier id; p.type = p.type.typeSemantic(loc, sc2); @@ -1591,10 +1591,10 @@ private extern (C++) final class StatementSemanticVisitor : Visitor if (tfld) { Parameter prm = Parameter.getNth(tfld.parameters, i); - //printf("\tprm = %s%s\n", (prm.storageClass&STCref?"ref ":"").ptr, prm.ident.toChars()); - stc = prm.storageClass & STCref; + //printf("\tprm = %s%s\n", (prm.storageClass&STC.ref_?"ref ":"").ptr, prm.ident.toChars()); + stc = prm.storageClass & STC.ref_; id = p.ident; // argument copy is not need. - if ((p.storageClass & STCref) != stc) + if ((p.storageClass & STC.ref_) != stc) { if (!stc) { @@ -1604,7 +1604,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor goto LcopyArg; } } - else if (p.storageClass & STCref) + else if (p.storageClass & STC.ref_) { // default delegate parameters are marked as ref, then // argument copy is not need. @@ -1619,7 +1619,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor Initializer ie = new ExpInitializer(Loc(), new IdentifierExp(Loc(), id)); auto v = new VarDeclaration(Loc(), p.type, p.ident, ie); - v.storage_class |= STCtemp; + v.storage_class |= STC.temp; s = new ExpStatement(Loc(), v); fs._body = new CompoundStatement(loc, s, fs._body); } @@ -1627,7 +1627,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor } // https://issues.dlang.org/show_bug.cgi?id=13840 // Throwable nested function inside nothrow function is acceptable. - StorageClass stc = mergeFuncAttrs(STCsafe | STCpure | STCnogc, fs.func); + StorageClass stc = mergeFuncAttrs(STC.safe | STC.pure_ | STC.nogc, fs.func); tfld = new TypeFunction(params, Type.tint32, 0, LINKd, stc); fs.cases = new Statements(); fs.gotos = new ScopeStatements(); @@ -1664,7 +1664,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor { // Check types Parameter p = (*fs.parameters)[0]; - bool isRef = (p.storageClass & STCref) != 0; + bool isRef = (p.storageClass & STC.ref_) != 0; Type ta = p.type; if (dim == 2) { @@ -1676,7 +1676,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor goto case Terror; } p = (*fs.parameters)[1]; - isRef = (p.storageClass & STCref) != 0; + isRef = (p.storageClass & STC.ref_) != 0; ta = p.type; } Type taav = taa.nextOf(); @@ -1703,7 +1703,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor { params = new Parameters(); params.push(new Parameter(0, Type.tvoid.pointerTo(), null, null)); - params.push(new Parameter(STCin, Type.tsize_t, null, null)); + params.push(new Parameter(STC.in_, Type.tsize_t, null, null)); auto dgparams = new Parameters(); dgparams.push(new Parameter(0, Type.tvoidptr, null, null)); if (dim == 2) @@ -1771,7 +1771,7 @@ private extern (C++) final class StatementSemanticVisitor : Visitor FuncDeclaration fdapply; TypeDelegate dgty; params = new Parameters(); - params.push(new Parameter(STCin, tn.arrayOf(), null, null)); + params.push(new Parameter(STC.in_, tn.arrayOf(), null, null)); auto dgparams = new Parameters(); dgparams.push(new Parameter(0, Type.tvoidptr, null, null)); if (dim == 2) @@ -1921,7 +1921,7 @@ else fs.prm.type = fs.prm.type.addStorageClass(fs.prm.storageClass); fs.lwr = fs.lwr.implicitCastTo(sc, fs.prm.type); - if (fs.upr.implicitConvTo(fs.prm.type) || (fs.prm.storageClass & STCref)) + if (fs.upr.implicitConvTo(fs.prm.type) || (fs.prm.storageClass & STC.ref_)) { fs.upr = fs.upr.implicitCastTo(sc, fs.prm.type); } @@ -1979,7 +1979,7 @@ else */ auto ie = new ExpInitializer(loc, (fs.op == TOKforeach) ? fs.lwr : fs.upr); fs.key = new VarDeclaration(loc, fs.upr.type.mutableOf(), Identifier.generateId("__key"), ie); - fs.key.storage_class |= STCtemp; + fs.key.storage_class |= STC.temp; SignExtendedNumber lower = getIntRange(fs.lwr).imin; SignExtendedNumber upper = getIntRange(fs.upr).imax; if (lower <= upper) @@ -1990,7 +1990,7 @@ else Identifier id = Identifier.generateId("__limit"); ie = new ExpInitializer(loc, (fs.op == TOKforeach) ? fs.upr : fs.lwr); auto tmp = new VarDeclaration(loc, fs.upr.type, id, ie); - tmp.storage_class |= STCtemp; + tmp.storage_class |= STC.temp; auto cs = new Statements(); // Keep order of evaluation as lwr, then upr @@ -2042,7 +2042,7 @@ else //increment = new AddAssignExp(loc, new VarExp(loc, fs.key), new IntegerExp(1)); increment = new PreExp(TOKpreplusplus, loc, new VarExp(loc, fs.key)); } - if ((fs.prm.storageClass & STCref) && fs.prm.type.equals(fs.key.type)) + if ((fs.prm.storageClass & STC.ref_) && fs.prm.type.equals(fs.key.type)) { fs.key.range = null; auto v = new AliasDeclaration(loc, fs.prm.ident, fs.key); @@ -2052,7 +2052,7 @@ else { ie = new ExpInitializer(loc, new CastExp(loc, new VarExp(loc, fs.key), fs.prm.type)); auto v = new VarDeclaration(loc, fs.prm.type, fs.prm.ident, ie); - v.storage_class |= STCtemp | STCforeach | (fs.prm.storageClass & STCref); + v.storage_class |= STC.temp | STC.foreach_ | (fs.prm.storageClass & STC.ref_); fs._body = new CompoundStatement(loc, new ExpStatement(loc, v), fs._body); if (fs.key.range && !fs.prm.type.isMutable()) { @@ -2061,7 +2061,7 @@ else v.range = new IntRange(fs.key.range.imin, fs.key.range.imax - SignExtendedNumber(1)); } } - if (fs.prm.storageClass & STCref) + if (fs.prm.storageClass & STC.ref_) { if (fs.key.type.constConv(fs.prm.type) <= MATCH.nomatch) { @@ -2112,7 +2112,7 @@ else Statement sdtor = new DtorExpStatement(ifs.loc, ifs.match.edtor, ifs.match); sdtor = new OnScopeStatement(ifs.loc, TOKon_scope_exit, sdtor); ifs.ifbody = new CompoundStatement(ifs.loc, sdtor, ifs.ifbody); - ifs.match.storage_class |= STCnodtor; + ifs.match.storage_class |= STC.nodtor; } } else @@ -2933,7 +2933,7 @@ else Type tret = tf.next; Type tbret = tret ? tret.toBasetype() : null; - bool inferRef = (tf.isref && (fd.storage_class & STCauto)); + bool inferRef = (tf.isref && (fd.storage_class & STC.auto_)); Expression e0 = null; bool errors = false; @@ -3167,7 +3167,7 @@ else foreach (i; 0 .. dim) { VarDeclaration v = ad.fields[i]; - bool mustInit = (v.storage_class & STCnodefaultctor || v.type.needsNested()); + bool mustInit = (v.storage_class & STC.nodefaultctor || v.type.needsNested()); if (mustInit && !(sc.fieldinit[i] & CSXthis_ctor)) { rs.error("an earlier return statement skips field `%s` initialization", v.toChars()); @@ -3472,7 +3472,7 @@ else auto id = Identifier.generateId("__critsec"); auto t = Type.tint8.sarrayOf(Target.ptrsize + Target.critsecsize()); auto tmp = new VarDeclaration(ss.loc, t, id, null); - tmp.storage_class |= STCtemp | STCgshared | STCstatic; + tmp.storage_class |= STC.temp | STC.gshared | STC.static_; auto cs = new Statements(); cs.push(new ExpStatement(ss.loc, tmp)); @@ -3487,14 +3487,14 @@ else auto args = new Parameters(); args.push(new Parameter(0, t.pointerTo(), null, null)); - FuncDeclaration fdenter = FuncDeclaration.genCfunc(args, Type.tvoid, Id.criticalenter, STCnothrow); + FuncDeclaration fdenter = FuncDeclaration.genCfunc(args, Type.tvoid, Id.criticalenter, STC.nothrow_); Expression e = new DotIdExp(ss.loc, new VarExp(ss.loc, tmp), Id.ptr); e = e.expressionSemantic(sc); e = new CallExp(ss.loc, new VarExp(ss.loc, fdenter, false), e); e.type = Type.tvoid; // do not run semantic on e cs.push(new ExpStatement(ss.loc, e)); - FuncDeclaration fdexit = FuncDeclaration.genCfunc(args, Type.tvoid, Id.criticalexit, STCnothrow); + FuncDeclaration fdexit = FuncDeclaration.genCfunc(args, Type.tvoid, Id.criticalexit, STC.nothrow_); e = new DotIdExp(ss.loc, new VarExp(ss.loc, tmp), Id.ptr); e = e.expressionSemantic(sc); e = new CallExp(ss.loc, new VarExp(ss.loc, fdexit, false), e); @@ -3929,11 +3929,11 @@ else assert(sc.func); // use setImpure/setGC when the deprecation cycle is over PURE purity; - if (!(cas.stc & STCpure) && (purity = sc.func.isPureBypassingInference()) != PUREimpure && purity != PUREfwdref) + if (!(cas.stc & STC.pure_) && (purity = sc.func.isPureBypassingInference()) != PUREimpure && purity != PUREfwdref) cas.deprecation("asm statement is assumed to be impure - mark it with 'pure' if it is not"); - if (!(cas.stc & STCnogc) && sc.func.isNogcBypassingInference()) + if (!(cas.stc & STC.nogc) && sc.func.isNogcBypassingInference()) cas.deprecation("asm statement is assumed to use the GC - mark it with '@nogc' if it does not"); - if (!(cas.stc & (STCtrusted | STCsafe)) && sc.func.setUnsafe()) + if (!(cas.stc & (STC.trusted | STC.safe)) && sc.func.setUnsafe()) cas.error("asm statement is assumed to be @system - mark it with '@trusted' if it is not"); result = cas; @@ -4043,7 +4043,7 @@ void catchSemantic(Catch c, Scope* sc) } else if (global.params.ehnogc) { - stc |= STCscope; + stc |= STC.scope_; } if (c.ident) @@ -4053,7 +4053,7 @@ void catchSemantic(Catch c, Scope* sc) c.var.dsymbolSemantic(sc); sc.insert(c.var); - if (global.params.ehnogc && stc & STCscope) + if (global.params.ehnogc && stc & STC.scope_) { /* Add a destructor for c.var * try { handler } finally { if (!__ctfe) _d_delThrowable(var); } diff --git a/src/dmd/tocsym.d b/src/dmd/tocsym.d index 62d645f06f97..e51bd7918f11 100644 --- a/src/dmd/tocsym.d +++ b/src/dmd/tocsym.d @@ -153,16 +153,16 @@ Symbol *toSymbol(Dsymbol s) s = symbol_calloc(id, cast(uint)strlen(id)); } s.Salignment = vd.alignment; - if (vd.storage_class & STCtemp) + if (vd.storage_class & STC.temp) s.Sflags |= SFLartifical; TYPE *t; - if (vd.storage_class & (STCout | STCref)) + if (vd.storage_class & (STC.out_ | STC.ref_)) { t = type_allocn(TYnref, Type_toCtype(vd.type)); t.Tcount++; } - else if (vd.storage_class & STClazy) + else if (vd.storage_class & STC.lazy_) { if (config.exe == EX_WIN64 && vd.isParameter()) t = type_fake(TYnptr); @@ -191,7 +191,7 @@ Symbol *toSymbol(Dsymbol s) if (vd.isDataseg()) { - if (vd.isThreadlocal() && !(vd.storage_class & STCtemp)) + if (vd.isThreadlocal() && !(vd.storage_class & STC.temp)) { /* Thread local storage */ @@ -237,7 +237,7 @@ Symbol *toSymbol(Dsymbol s) } } - if (vd.storage_class & STCvolatile) + if (vd.storage_class & STC.volatile_) { type_setcv(&t, t.Tty | mTYvolatile); } diff --git a/src/dmd/toctype.d b/src/dmd/toctype.d index b46ad2e02fae..05abde0f6ab4 100644 --- a/src/dmd/toctype.d +++ b/src/dmd/toctype.d @@ -74,9 +74,9 @@ public: { Parameter p = Parameter.getNth(t.parameters, i); type* tp = Type_toCtype(p.type); - if (p.storageClass & (STCout | STCref)) + if (p.storageClass & (STC.out_ | STC.ref_)) tp = type_allocn(TYnref, tp); - else if (p.storageClass & STClazy) + else if (p.storageClass & STC.lazy_) { // Mangle as delegate type* tf = type_function(TYnfunc, null, 0, false, tp); diff --git a/src/dmd/todt.d b/src/dmd/todt.d index d0f3c0ee78b4..f63f2725c770 100644 --- a/src/dmd/todt.d +++ b/src/dmd/todt.d @@ -1362,7 +1362,7 @@ private extern (C++) class TypeInfoDtVisitor : Visitor // xpostblit FuncDeclaration spostblit = sd.postblit; - if (spostblit && !(spostblit.storage_class & STCdisable)) + if (spostblit && !(spostblit.storage_class & STC.disable)) dtb.xoff(toSymbol(spostblit), 0); else dtb.size(0); // xpostblit diff --git a/src/dmd/toir.d b/src/dmd/toir.d index 7008c0ce4c00..b14e0b52344e 100644 --- a/src/dmd/toir.d +++ b/src/dmd/toir.d @@ -685,7 +685,7 @@ elem *resolveLengthVar(VarDeclaration lengthVar, elem **pe, Type t1) //printf("resolveLengthVar()\n"); elem *einit = null; - if (lengthVar && !(lengthVar.storage_class & STCconst)) + if (lengthVar && !(lengthVar.storage_class & STC.const_)) { elem *elength; Symbol *slength; @@ -738,7 +738,7 @@ void setClosureVarOffset(FuncDeclaration fd) uint memsize; uint memalignsize; structalign_t xalign; - if (v.storage_class & STClazy) + if (v.storage_class & STC.lazy_) { /* Lazy variables are really delegates, * so give same answers that TypeDelegate would @@ -747,7 +747,7 @@ void setClosureVarOffset(FuncDeclaration fd) memalignsize = memsize; xalign = STRUCTALIGN_DEFAULT; } - else if (v.storage_class & (STCout | STCref)) + else if (v.storage_class & (STC.out_ | STC.ref_)) { // reference parameters are just pointers memsize = Target.ptrsize; @@ -846,7 +846,7 @@ void buildClosure(FuncDeclaration fd, IRState *irs) // Hack for the case fail_compilation/fail10666.d, // until proper issue 5730 fix will come. - bool isScopeDtorParam = v.edtor && (v.storage_class & STCparameter); + bool isScopeDtorParam = v.edtor && (v.storage_class & STC.parameter); if (v.needsScopeDtor() || isScopeDtorParam) { /* Because the value needs to survive the end of the scope! @@ -875,7 +875,7 @@ void buildClosure(FuncDeclaration fd, IRState *irs) // Calculate the size of the closure VarDeclaration vlast = fd.closureVars[fd.closureVars.dim - 1]; typeof(Type.size()) lastsize; - if (vlast.storage_class & STClazy) + if (vlast.storage_class & STC.lazy_) lastsize = Target.ptrsize * 2; else if (vlast.isRef() || vlast.isOut()) lastsize = Target.ptrsize; @@ -917,12 +917,12 @@ void buildClosure(FuncDeclaration fd, IRState *irs) bool win64ref = ISWIN64REF(v); if (win64ref) { - if (v.storage_class & STClazy) + if (v.storage_class & STC.lazy_) tym = TYdelegate; } else if (ISREF(v)) tym = TYnptr; // reference parameters are just pointers - else if (v.storage_class & STClazy) + else if (v.storage_class & STC.lazy_) tym = TYdelegate; ex = el_bin(OPadd, TYnptr, el_var(sclosure), el_long(TYsize_t, v.offset)); ex = el_una(OPind, tym, ex); diff --git a/src/dmd/toobj.d b/src/dmd/toobj.d index 21cfb521fd07..a5a440894c8a 100644 --- a/src/dmd/toobj.d +++ b/src/dmd/toobj.d @@ -515,7 +515,7 @@ void toObjFile(Dsymbol ds, bool multiobj) dtb.size(0); // null for now, fix later // defaultConstructor - if (cd.defaultCtor && !(cd.defaultCtor.storage_class & STCdisable)) + if (cd.defaultCtor && !(cd.defaultCtor.storage_class & STC.disable)) dtb.xoff(toSymbol(cd.defaultCtor), 0, TYnptr); else dtb.size(0); @@ -905,7 +905,7 @@ void toObjFile(Dsymbol ds, bool multiobj) return; } - if (!vd.isDataseg() || vd.storage_class & STCextern) + if (!vd.isDataseg() || vd.storage_class & STC.extern_) return; Symbol *s = toSymbol(vd); diff --git a/src/dmd/traits.d b/src/dmd/traits.d index 5a08401abcb5..24ea0836c7d5 100644 --- a/src/dmd/traits.d +++ b/src/dmd/traits.d @@ -520,7 +520,7 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc) if (e.ident == Id.isFinalClass) { return isTypeX(t => t.toBasetype().ty == Tclass && - ((cast(TypeClass)t.toBasetype()).sym.storage_class & STCfinal) != 0); + ((cast(TypeClass)t.toBasetype()).sym.storage_class & STC.final_) != 0); } if (e.ident == Id.isTemplate) { @@ -639,7 +639,7 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc) if (dim != 1) return dimError(1); - return isDeclX(d => (d.storage_class & STClazy) != 0); + return isDeclX(d => (d.storage_class & STC.lazy_) != 0); } if (e.ident == Id.identifier) { @@ -1132,7 +1132,7 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc) // This mirrors hdrgen.visit(Parameter p) if (p.type && p.type.mod & MODshared) - stc &= ~STCshared; + stc &= ~STC.shared_; auto exps = new Expressions; @@ -1141,31 +1141,31 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc) exps.push(new StringExp(e.loc, cast(char*)s.ptr, cast(uint)s.length)); } - if (stc & STCauto) + if (stc & STC.auto_) push("auto"); - if (stc & STCreturn) + if (stc & STC.return_) push("return"); - if (stc & STCout) + if (stc & STC.out_) push("out"); - else if (stc & STCref) + else if (stc & STC.ref_) push("ref"); - else if (stc & STCin) + else if (stc & STC.in_) push("in"); - else if (stc & STClazy) + else if (stc & STC.lazy_) push("lazy"); - else if (stc & STCalias) + else if (stc & STC.alias_) push("alias"); - if (stc & STCconst) + if (stc & STC.const_) push("const"); - if (stc & STCimmutable) + if (stc & STC.immutable_) push("immutable"); - if (stc & STCwild) + if (stc & STC.wild) push("inout"); - if (stc & STCshared) + if (stc & STC.shared_) push("shared"); - if (stc & STCscope && !(stc & STCscopeinferred)) + if (stc & STC.scope_ && !(stc & STC.scopeinferred)) push("scope"); auto tup = new TupleExp(e.loc, exps); @@ -1243,7 +1243,7 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc) // skip local symbols, such as static foreach loop variables if (auto decl = sm.isDeclaration()) { - if (decl.storage_class & STClocal) + if (decl.storage_class & STC.local) { return 0; } diff --git a/src/dmd/typesem.d b/src/dmd/typesem.d index 6a4e8017cc3d..aed8daba1ded 100644 --- a/src/dmd/typesem.d +++ b/src/dmd/typesem.d @@ -735,19 +735,19 @@ private extern (C++) final class TypeSemanticVisitor : Visitor } } - if (sc.stc & STCpure) + if (sc.stc & STC.pure_) tf.purity = PUREfwdref; - if (sc.stc & STCnothrow) + if (sc.stc & STC.nothrow_) tf.isnothrow = true; - if (sc.stc & STCnogc) + if (sc.stc & STC.nogc) tf.isnogc = true; - if (sc.stc & STCref) + if (sc.stc & STC.ref_) tf.isref = true; - if (sc.stc & STCreturn) + if (sc.stc & STC.return_) tf.isreturn = true; - if (sc.stc & STCscope) + if (sc.stc & STC.scope_) tf.isscope = true; - if (sc.stc & STCscopeinferred) + if (sc.stc & STC.scopeinferred) tf.isscopeinferred = true; // if (tf.isreturn && !tf.isref) @@ -755,15 +755,15 @@ private extern (C++) final class TypeSemanticVisitor : Visitor if (tf.trust == TRUSTdefault) { - if (sc.stc & STCsafe) + if (sc.stc & STC.safe) tf.trust = TRUSTsafe; - else if (sc.stc & STCsystem) + else if (sc.stc & STC.system) tf.trust = TRUSTsystem; - else if (sc.stc & STCtrusted) + else if (sc.stc & STC.trusted) tf.trust = TRUSTtrusted; } - if (sc.stc & STCproperty) + if (sc.stc & STC.property) tf.isproperty = true; tf.linkage = sc.linkage; @@ -791,7 +791,7 @@ private extern (C++) final class TypeSemanticVisitor : Visitor if (tf.next) { sc = sc.push(); - sc.stc &= ~(STC_TYPECTOR | STC_FUNCATTR); + sc.stc &= ~(STC.TYPECTOR | STC.FUNCATTR); tf.next = tf.next.typeSemantic(loc, sc); sc = sc.pop(); errors |= tf.checkRetType(loc); @@ -835,7 +835,7 @@ private extern (C++) final class TypeSemanticVisitor : Visitor fparam.type = fparam.type.addStorageClass(fparam.storageClass); - if (fparam.storageClass & (STCauto | STCalias | STCstatic)) + if (fparam.storageClass & (STC.auto_ | STC.alias_ | STC.static_)) { if (!fparam.type) continue; @@ -848,7 +848,7 @@ private extern (C++) final class TypeSemanticVisitor : Visitor mtype.error(loc, "cannot have parameter of function type `%s`", fparam.type.toChars()); errors = true; } - else if (!(fparam.storageClass & (STCref | STCout)) && + else if (!(fparam.storageClass & (STC.ref_ | STC.out_)) && (t.ty == Tstruct || t.ty == Tsarray || t.ty == Tenum)) { Type tb2 = t.baseElemOf(); @@ -859,27 +859,27 @@ private extern (C++) final class TypeSemanticVisitor : Visitor errors = true; } } - else if (!(fparam.storageClass & STClazy) && t.ty == Tvoid) + else if (!(fparam.storageClass & STC.lazy_) && t.ty == Tvoid) { mtype.error(loc, "cannot have parameter of type `%s`", fparam.type.toChars()); errors = true; } - if ((fparam.storageClass & (STCref | STCwild)) == (STCref | STCwild)) + if ((fparam.storageClass & (STC.ref_ | STC.wild)) == (STC.ref_ | STC.wild)) { // 'ref inout' implies 'return' - fparam.storageClass |= STCreturn; + fparam.storageClass |= STC.return_; } - if (fparam.storageClass & STCreturn) + if (fparam.storageClass & STC.return_) { - if (fparam.storageClass & (STCref | STCout)) + if (fparam.storageClass & (STC.ref_ | STC.out_)) { // Disabled for the moment awaiting improvement to allow return by ref // to be transformed into return by scope. if (0 && !tf.isref) { - auto stc = fparam.storageClass & (STCref | STCout); + auto stc = fparam.storageClass & (STC.ref_ | STC.out_); mtype.error(loc, "parameter `%s` is `return %s` but function does not return by `ref`", fparam.ident ? fparam.ident.toChars() : "", stcToChars(stc)); @@ -888,7 +888,7 @@ private extern (C++) final class TypeSemanticVisitor : Visitor } else { - fparam.storageClass |= STCscope; // 'return' implies 'scope' + fparam.storageClass |= STC.scope_; // 'return' implies 'scope' if (tf.isref) { } @@ -901,10 +901,10 @@ private extern (C++) final class TypeSemanticVisitor : Visitor } } - if (fparam.storageClass & (STCref | STClazy)) + if (fparam.storageClass & (STC.ref_ | STC.lazy_)) { } - else if (fparam.storageClass & STCout) + else if (fparam.storageClass & STC.out_) { if (ubyte m = fparam.type.mod & (MODimmutable | MODconst | MODwild)) { @@ -924,11 +924,11 @@ private extern (C++) final class TypeSemanticVisitor : Visitor } } - if (fparam.storageClass & STCscope && !fparam.type.hasPointers() && fparam.type.ty != Ttuple) + if (fparam.storageClass & STC.scope_ && !fparam.type.hasPointers() && fparam.type.ty != Ttuple) { - fparam.storageClass &= ~STCscope; - if (!(fparam.storageClass & STCref)) - fparam.storageClass &= ~STCreturn; + fparam.storageClass &= ~STC.scope_; + if (!(fparam.storageClass & STC.ref_)) + fparam.storageClass &= ~STC.return_; } if (t.hasWild()) @@ -941,7 +941,7 @@ private extern (C++) final class TypeSemanticVisitor : Visitor if (fparam.defaultArg) { Expression e = fparam.defaultArg; - if (fparam.storageClass & (STCref | STCout)) + if (fparam.storageClass & (STC.ref_ | STC.out_)) { e = e.expressionSemantic(argsc); e = resolveProperties(argsc, e); @@ -966,7 +966,7 @@ private extern (C++) final class TypeSemanticVisitor : Visitor e = e.implicitCastTo(argsc, fparam.type); // default arg must be an lvalue - if (fparam.storageClass & (STCout | STCref)) + if (fparam.storageClass & (STC.out_ | STC.ref_)) e = e.toLvalue(argsc, e); fparam.defaultArg = e; @@ -1002,17 +1002,17 @@ private extern (C++) final class TypeSemanticVisitor : Visitor // If the storage classes of narg // conflict with the ones in fparam, it's ignored. StorageClass stc = fparam.storageClass | narg.storageClass; - StorageClass stc1 = fparam.storageClass & (STCref | STCout | STClazy); - StorageClass stc2 = narg.storageClass & (STCref | STCout | STClazy); + StorageClass stc1 = fparam.storageClass & (STC.ref_ | STC.out_ | STC.lazy_); + StorageClass stc2 = narg.storageClass & (STC.ref_ | STC.out_ | STC.lazy_); if (stc1 && stc2 && stc1 != stc2) { - OutBuffer buf1; stcToBuffer(&buf1, stc1 | ((stc1 & STCref) ? (fparam.storageClass & STCauto) : 0)); + OutBuffer buf1; stcToBuffer(&buf1, stc1 | ((stc1 & STC.ref_) ? (fparam.storageClass & STC.auto_) : 0)); OutBuffer buf2; stcToBuffer(&buf2, stc2); mtype.error(loc, "incompatible parameter storage classes `%s` and `%s`", buf1.peekString(), buf2.peekString()); errors = true; - stc = stc1 | (stc & ~(STCref | STCout | STClazy)); + stc = stc1 | (stc & ~(STC.ref_ | STC.out_ | STC.lazy_)); } (*newparams)[j] = new Parameter( @@ -1033,9 +1033,9 @@ private extern (C++) final class TypeSemanticVisitor : Visitor /* Resolve "auto ref" storage class to be either ref or value, * based on the argument matching the parameter */ - if (fparam.storageClass & STCauto) + if (fparam.storageClass & STC.auto_) { - if (mtype.fargs && i < mtype.fargs.dim && (fparam.storageClass & STCref)) + if (mtype.fargs && i < mtype.fargs.dim && (fparam.storageClass & STC.ref_)) { Expression farg = (*mtype.fargs)[i]; if (farg.isLvalue()) @@ -1043,9 +1043,9 @@ private extern (C++) final class TypeSemanticVisitor : Visitor // ref parameter } else - fparam.storageClass &= ~STCref; // value parameter - fparam.storageClass &= ~STCauto; // https://issues.dlang.org/show_bug.cgi?id=14656 - fparam.storageClass |= STCautoref; + fparam.storageClass &= ~STC.ref_; // value parameter + fparam.storageClass &= ~STC.auto_; // https://issues.dlang.org/show_bug.cgi?id=14656 + fparam.storageClass |= STC.autoref; } else { @@ -1055,7 +1055,7 @@ private extern (C++) final class TypeSemanticVisitor : Visitor } // Remove redundant storage classes for type, they are already applied - fparam.storageClass &= ~(STC_TYPECTOR | STCin); + fparam.storageClass &= ~(STC.TYPECTOR | STC.in_); } argsc.pop(); }