Same name check: differentiate between version blocks

This commit is contained in:
Sebastian Wilzbach 2017-02-20 14:53:44 +01:00
parent e2e500f43e
commit 4c74ac2bda
1 changed files with 22 additions and 0 deletions

View File

@ -50,6 +50,13 @@ class LabelVarNameCheck : BaseAnalyzer
--conditionalDepth;
}
override void visit(const VersionCondition condition)
{
++conditionalDepth;
condition.accept(this);
--conditionalDepth;
}
alias visit = BaseAnalyzer.visit;
private:
@ -168,6 +175,21 @@ void main(string[] args)
int b;
}
unittest
{
version (Windows)
int c = 10;
else
int c = 20;
int c; // [warn]: Variable "c" has the same name as a variable defined on line 51.
}
unittest
{
version(LittleEndian) { enum string NAME = "UTF-16LE"; }
else version(BigEndian) { enum string NAME = "UTF-16BE"; }
}
}c, sac);
stderr.writeln("Unittest for LabelVarNameCheck passed.");
}