Skip to content

Commit

Permalink
Merge pull request #3835 from 9rnsr/fix13201
Browse files Browse the repository at this point in the history
[REG2.066a] Issue 13201 - Wrong "Warning: statement is not reachable" error with -w
  • Loading branch information
yebblies authored and 9rnsr committed Jul 30, 2014
1 parent 7119ce5 commit 64da724
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/statement.c
Expand Up @@ -632,11 +632,15 @@ int Statement::blockExit(FuncDeclaration *func, bool mustNotThrow)
s->finalbody->blockExit(func, mustNotThrow);
}

#if 0
// Bugzilla 13201: Mask to prevent spurious warnings for
// destructor call, exit of synchronized statement, etc.
if (result == BEhalt && finalresult != BEhalt && s->finalbody &&
s->finalbody->hasCode())
{
s->finalbody->warning("statement is not reachable");
}
#endif

if (!(finalresult & BEfallthru))
result &= ~BEfallthru;
Expand Down
18 changes: 9 additions & 9 deletions test/fail_compilation/warn12809.d
Expand Up @@ -3,19 +3,19 @@
/*
TEST_OUTPUT:
---
fail_compilation/warn12809.d(16): Warning: statement is not reachable
fail_compilation/warn12809.d(25): Warning: statement is not reachable
fail_compilation/warn12809.d(33): Warning: statement is not reachable
---
*/
void test_unrachable1()
{
try assert(0);
finally
{
int x = 1; // unreachable
}
}

//void test_unrachable1()
//{
// try assert(0);
// finally
// {
// int x = 1; // unreachable
// }
//}

void test_unrachable2()
{
Expand Down
31 changes: 31 additions & 0 deletions test/runnable/warning1.d
Expand Up @@ -153,6 +153,37 @@ struct S9332
}
}

/******************************************/
// 13201

class C13201
{
void foo()
{
synchronized(this)
{
assert(0);
}
}
}

void test13201a()
{
auto c = new C13201();
synchronized(c)
{
assert(0);
}
}

void test13201b()
{
struct S { ~this() {} }

S s;
assert(0);
}

/******************************************/

void main()
Expand Down

0 comments on commit 64da724

Please sign in to comment.