Skip to content

Commit

Permalink
Merge pull request #9195 from wilzbach/tests-dip1006
Browse files Browse the repository at this point in the history
Fix Issue 19549 - -check=in=off doesn't work
  • Loading branch information
wilzbach authored Jan 7, 2019
2 parents 06b3141 + 11cc425 commit de293a1
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/dmd/semantic3.d
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
if (auto s = funcdecl.fensure.isScopeStatement())
fensure_endlin = s.endloc.linnum;

if ((needEnsure && global.params.useOut) || fpostinv)
if ((needEnsure && global.params.useOut == CHECKENABLE.on) || fpostinv)
{
funcdecl.returnLabel = new LabelDsymbol(Id.returnLabel);
}
Expand Down Expand Up @@ -903,7 +903,7 @@ private extern(C++) final class Semantic3Visitor : Visitor

sc2 = sc2.pop();

if (!global.params.useIn)
if (global.params.useIn == CHECKENABLE.off)
freq = null;
}
if (fens)
Expand Down Expand Up @@ -937,7 +937,7 @@ private extern(C++) final class Semantic3Visitor : Visitor

sc2 = sc2.pop();

if (!global.params.useOut)
if (global.params.useOut == CHECKENABLE.off)
fens = null;
}
if (funcdecl.fbody && funcdecl.fbody.isErrorStatement())
Expand Down
38 changes: 38 additions & 0 deletions test/runnable/test_dip1006.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// REQUIRED_ARGS: -check=in=off -check=out=off -check=invariant=off
// PERMUTE_ARGS:
class C
{
int foo(int a)
in { assert(a != 0); } // skipped
out(res) { assert(res != 0); } // skipped
body
{
return a;
}

invariant // skipped
{
assert(false);
}

void bar(int a)
{
assert(a != 0); // triggered
}
}

void main()
{
import core.exception : AssertError;

auto c = new C;
c.foo(0);

bool catched;
try
c.bar(0);
catch (AssertError e)
catched = true;
if (!catched)
assert(0);
}
35 changes: 35 additions & 0 deletions test/runnable/test_dip1006b.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// REQUIRED_ARGS: -check=in=off -check=invariant=off
// PERMUTE_ARGS:
class C
{
int foo(int a)
in { assert(a != 0); } // skipped
out(res) { assert(res != 0, "out"); } // triggered
body
{
return a;
}

invariant // skipped
{
assert(false);
}
}

void main()
{
import core.exception : AssertError;

auto c = new C;
bool catched;
try
c.foo(0);
catch (AssertError e)
{
assert(e.msg == "out");
catched = e.msg == "out";
}

if (!catched)
assert(0);
}

0 comments on commit de293a1

Please sign in to comment.