diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-06-05 19:27:29 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-06-05 20:13:50 +0200 |
commit | 0cdc55f5ed881436c49d313b6cead244bdcf0654 (patch) | |
tree | f3ac3c20cabb0912a167dd0aecc8c034b2194fea /gcc/d/dmd | |
parent | 5094c4400a8687dcf44f5993aee3a88e98519f3b (diff) | |
download | gcc-0cdc55f5ed881436c49d313b6cead244bdcf0654.zip gcc-0cdc55f5ed881436c49d313b6cead244bdcf0654.tar.gz gcc-0cdc55f5ed881436c49d313b6cead244bdcf0654.tar.bz2 |
d: Merge upstream dmd f5638c7b8.
Adds a CHECKENABLE enum, uses it for all contract parameters for
consistency in state checking.
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd f5638c7b8.
* d-builtins.cc (d_init_versions): Use new CHECKENABLE enum.
* d-codegen.cc (array_bounds_check): Likewise.
(build_frame_type): Likewise.
(get_frameinfo): Likewise.
* d-lang.cc (d_init_options): Likewise.
(d_init_options_struct): Don't initialize x_flag_bounds_check.
(d_handle_option): Use new CHECKENABLE enum.
(d_post_options): Likewise. Set flag_bounds_check here.
* expr.cc (ExprVisitor::visit(AssertExp *)): Use new CHECKENABLE enum.
Diffstat (limited to 'gcc/d/dmd')
-rw-r--r-- | gcc/d/dmd/MERGE | 2 | ||||
-rw-r--r-- | gcc/d/dmd/expressionsem.c | 2 | ||||
-rw-r--r-- | gcc/d/dmd/func.c | 18 | ||||
-rw-r--r-- | gcc/d/dmd/globals.h | 25 | ||||
-rw-r--r-- | gcc/d/dmd/statementsem.c | 4 |
5 files changed, 27 insertions, 24 deletions
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index f413bd1..3248bf7 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -56f0a65c493463633a293d71faf37cdf710041ef +f5638c7b8a6912858a9b51987df6a725e6796dc9 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/expressionsem.c b/gcc/d/dmd/expressionsem.c index ffcfeb4..75e4d13 100644 --- a/gcc/d/dmd/expressionsem.c +++ b/gcc/d/dmd/expressionsem.c @@ -2451,7 +2451,7 @@ public: sc->fieldinit[i] |= CSXhalt; } - if (!global.params.useAssert) + if (global.params.useAssert == CHECKENABLEoff) { Expression *e = new HaltExp(exp->loc); e = semantic(e, sc); diff --git a/gcc/d/dmd/func.c b/gcc/d/dmd/func.c index 807565d..eb8d5db 100644 --- a/gcc/d/dmd/func.c +++ b/gcc/d/dmd/func.c @@ -1668,7 +1668,7 @@ void FuncDeclaration::semantic3(Scope *sc) Scope *scout = NULL; if (needEnsure || addPostInvariant()) { - if ((needEnsure && global.params.useOut) || fpostinv) + if ((needEnsure && global.params.useOut == CHECKENABLEon) || fpostinv) { returnLabel = new LabelDsymbol(Id::returnLabel); } @@ -1915,7 +1915,7 @@ void FuncDeclaration::semantic3(Scope *sc) error("has no return statement, but is expected to return a value of type %s", f->next->toChars()); else error("no return exp; or assert(0); at end of function"); - if (global.params.useAssert && + if (global.params.useAssert == CHECKENABLEon && !global.params.useInline) { /* Add an assert(0, msg); where the missing return @@ -2048,7 +2048,7 @@ void FuncDeclaration::semantic3(Scope *sc) sc2 = sc2->pop(); - if (!global.params.useIn) + if (global.params.useIn == CHECKENABLEoff) freq = NULL; } @@ -2072,7 +2072,7 @@ void FuncDeclaration::semantic3(Scope *sc) sc2 = sc2->pop(); - if (!global.params.useOut) + if (global.params.useOut == CHECKENABLEoff) fens = NULL; } @@ -4135,7 +4135,7 @@ bool FuncDeclaration::addPreInvariant() AggregateDeclaration *ad = isThis(); ClassDeclaration *cd = ad ? ad->isClassDeclaration() : NULL; return (ad && !(cd && cd->isCPPclass()) && - global.params.useInvariants && + global.params.useInvariants == CHECKENABLEon && (protection.kind == PROTprotected || protection.kind == PROTpublic || protection.kind == PROTexport) && !naked); } @@ -4146,7 +4146,7 @@ bool FuncDeclaration::addPostInvariant() ClassDeclaration *cd = ad ? ad->isClassDeclaration() : NULL; return (ad && !(cd && cd->isCPPclass()) && ad->inv && - global.params.useInvariants && + global.params.useInvariants == CHECKENABLEon && (protection.kind == PROTprotected || protection.kind == PROTpublic || protection.kind == PROTexport) && !naked); } @@ -4927,7 +4927,7 @@ bool CtorDeclaration::addPreInvariant() bool CtorDeclaration::addPostInvariant() { - return (isThis() && vthis && global.params.useInvariants); + return (isThis() && vthis && global.params.useInvariants == CHECKENABLEon); } @@ -4995,7 +4995,7 @@ bool PostBlitDeclaration::addPreInvariant() bool PostBlitDeclaration::addPostInvariant() { - return (isThis() && vthis && global.params.useInvariants); + return (isThis() && vthis && global.params.useInvariants == CHECKENABLEon); } bool PostBlitDeclaration::isVirtual() @@ -5067,7 +5067,7 @@ bool DtorDeclaration::overloadInsert(Dsymbol *) bool DtorDeclaration::addPreInvariant() { - return (isThis() && vthis && global.params.useInvariants); + return (isThis() && vthis && global.params.useInvariants == CHECKENABLEon); } bool DtorDeclaration::addPostInvariant() diff --git a/gcc/d/dmd/globals.h b/gcc/d/dmd/globals.h index aac4abc..be75fc0 100644 --- a/gcc/d/dmd/globals.h +++ b/gcc/d/dmd/globals.h @@ -28,12 +28,13 @@ enum }; // The state of array bounds checking -enum BOUNDSCHECK +typedef unsigned char CHECKENABLE; +enum { - BOUNDSCHECKdefault, // initial value - BOUNDSCHECKoff, // never do bounds checking - BOUNDSCHECKon, // always do bounds checking - BOUNDSCHECKsafeonly // do bounds checking only in @safe functions + CHECKENABLEdefault, // initial value + CHECKENABLEoff, // never do bounds checking + CHECKENABLEon, // always do bounds checking + CHECKENABLEsafeonly // do bounds checking only in @safe functions }; typedef unsigned char CHECKACTION; @@ -105,12 +106,7 @@ struct Param bool hasObjectiveC; // target supports Objective-C bool mscoff; // for Win32: write COFF object files instead of OMF Diagnostic useDeprecated; - bool useAssert; // generate runtime code for assert()'s - bool useInvariants; // generate class invariant checks - bool useIn; // generate precondition checks - bool useOut; // generate postcondition checks bool stackstomp; // add stack stomping code - bool useSwitchError; // check for switches without a default bool useUnitTests; // generate unittest code bool useInline; // inline expand functions bool useDIP25; // implement http://wiki.dlang.org/DIP25 @@ -138,7 +134,14 @@ struct Param CPU cpu; // CPU instruction set to target - BOUNDSCHECK useArrayBounds; // when to generate code for array bounds checks + CHECKENABLE useInvariants; // generate class invariant checks + CHECKENABLE useIn; // generate precondition checks + CHECKENABLE useOut; // generate postcondition checks + CHECKENABLE useArrayBounds; // when to generate code for array bounds checks + CHECKENABLE useAssert; // when to generate code for assert()'s + CHECKENABLE useSwitchError; // check for switches without a default + CHECKENABLE boundscheck; // state of -boundscheck switch + CHECKACTION checkAction; // action to take when bounds, asserts or switch defaults are violated const char *argv0; // program name diff --git a/gcc/d/dmd/statementsem.c b/gcc/d/dmd/statementsem.c index bfcb4b4..cd48d9c 100644 --- a/gcc/d/dmd/statementsem.c +++ b/gcc/d/dmd/statementsem.c @@ -2329,7 +2329,7 @@ public: needswitcherror = true; } - if (!sc->sw->sdefault && (!ss->isFinal || needswitcherror || global.params.useAssert)) + if (!sc->sw->sdefault && (!ss->isFinal || needswitcherror || global.params.useAssert == CHECKENABLEon)) { ss->hasNoDefault = 1; @@ -2341,7 +2341,7 @@ public: CompoundStatement *cs; Statement *s; - if (global.params.useSwitchError && + if (global.params.useSwitchError == CHECKENABLEon && global.params.checkAction != CHECKACTION_halt) { if (global.params.checkAction == CHECKACTION_C) |