Same name check: differentiate between version blocks
This commit is contained in:
parent
e2e500f43e
commit
4c74ac2bda
|
@ -50,6 +50,13 @@ class LabelVarNameCheck : BaseAnalyzer
|
||||||
--conditionalDepth;
|
--conditionalDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override void visit(const VersionCondition condition)
|
||||||
|
{
|
||||||
|
++conditionalDepth;
|
||||||
|
condition.accept(this);
|
||||||
|
--conditionalDepth;
|
||||||
|
}
|
||||||
|
|
||||||
alias visit = BaseAnalyzer.visit;
|
alias visit = BaseAnalyzer.visit;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -168,6 +175,21 @@ void main(string[] args)
|
||||||
int b;
|
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);
|
}c, sac);
|
||||||
stderr.writeln("Unittest for LabelVarNameCheck passed.");
|
stderr.writeln("Unittest for LabelVarNameCheck passed.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue