Skip to content

Commit

Permalink
Merge pull request #1668 from 9rnsr/fix8898
Browse files Browse the repository at this point in the history
fix Issue 8898 - false positive dangling else warning
  • Loading branch information
MartinNowak committed Feb 17, 2013
2 parents 187ed1b + 8cc8a41 commit 28e6cc1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/parse.c
Expand Up @@ -309,10 +309,15 @@ Dsymbols *Parser::parseDeclDefs(int once)
s = parseStaticAssert();
else if (token.value == TOKif)
{ condition = parseStaticIfCondition();
Loc lookingForElseSave = lookingForElse;
lookingForElse = loc;
a = parseBlock();
lookingForElse = lookingForElseSave;
if (token.value == TOKcolon)
a = parseBlock();
else
{
Loc lookingForElseSave = lookingForElse;
lookingForElse = loc;
a = parseBlock();
lookingForElse = lookingForElseSave;
}
aelse = NULL;
if (token.value == TOKelse)
{
Expand Down
11 changes: 11 additions & 0 deletions test/compilable/test8898.d
@@ -0,0 +1,11 @@
// REQUIRED_ARGS: -w
// PERMUTE_ARGS:

static if (true):

version (Foo)
{
}
else
{
}

0 comments on commit 28e6cc1

Please sign in to comment.