confirmed!
yes, it was definitely a bug in CC. This bug was due to the parser in CC does not treat the "scope" information correctly.
Say:
void main(void)
{
for (int i=0; i<10; i++)
{
float ff = 0; // place one
ff = ff + i;
} // place two
for (int i=0; i<10; i++)
{
float ff = 0; // place three
ff = ff + i; // place four
}
....
for example, the code above, your caret was put in the "place four", what cc's parser do was :
1, locate which function body your caret in. OK, it find it's location in "main()"
2, next, the parser try to parse the function body
from the { to the current caret, and collect all the local variables. if it meet a for statement, it will just "dig into" its body (because the parser has no idea whether your currently caret position was in the "for body" or not.
3, when the parser meet "place one", he just add the variable "ff" as a member of the "main()".
4, even it step out of the for body and step into the "place three", he will recognize another variable "ff" and added again as a child of "main()"
That's way you see the wrong tip.
To solve this. I'm not sure it was easy?? the Scope information is quite complex in the C++ language. a lot of directive can introduce a scope, like
using namespace directive
using directive
....
So, a full C++ parser framework(I'd like to say, currently Clang) can solve all the problem.