Fixed #4729 (Tokenizer::setVarId: Varid not tracked properly after function declaration with 'shadow' parameter name)
This commit is contained in:
parent
8d9ad2ae0d
commit
9f8ce6f77f
|
@ -2753,6 +2753,14 @@ void Tokenizer::setVarId()
|
|||
(Token::simpleMatch(tok->link(), ") {") || Token::Match(tok->link(), ") %type% {") || isInitList(tok->link()))) {
|
||||
scopeInfo.push(variableId);
|
||||
initlist = Token::simpleMatch(tok->link(), ") :");
|
||||
|
||||
// function declarations
|
||||
} else if (!executableScope.top() && tok->str() == "(" && Token::simpleMatch(tok->link(), ") ;")) {
|
||||
scopeInfo.push(variableId);
|
||||
} else if (!executableScope.top() && Token::simpleMatch(tok, ") ;")) {
|
||||
variableId.swap(scopeInfo.top());
|
||||
scopeInfo.pop();
|
||||
|
||||
} else if (tok->str() == "{") {
|
||||
initlist = false;
|
||||
// parse anonymous unions as part of the current scope
|
||||
|
|
|
@ -3614,13 +3614,28 @@ private:
|
|||
tokenizeDebugListing(code, false, "test.c"));
|
||||
}
|
||||
|
||||
void varid47() { // #3768
|
||||
void varid47() { // function parameters
|
||||
// #3768
|
||||
{
|
||||
const std::string code("void f(std::string &string, std::string &len) {}");
|
||||
ASSERT_EQUALS("\n\n##file 0\n"
|
||||
"1: void f ( std :: string & string@1 , std :: string & len@2 ) { }\n",
|
||||
tokenizeDebugListing(code, false, "test.cpp"));
|
||||
}
|
||||
|
||||
// #4729
|
||||
{
|
||||
const char code[] = "int x;\n"
|
||||
"void a(int x);\n"
|
||||
"void b() { x = 0; }\n";
|
||||
ASSERT_EQUALS("\n\n##file 0\n"
|
||||
"1: int x@1 ;\n"
|
||||
"2: void a ( int x@2 ) ;\n"
|
||||
"3: void b ( ) { x@1 = 0 ; }\n",
|
||||
tokenizeDebugListing(code));
|
||||
}
|
||||
}
|
||||
|
||||
void varid48() { // #3785 - return (a*b)
|
||||
const std::string code("int X::f(int b) const { return(a*b); }");
|
||||
ASSERT_EQUALS("\n\n##file 0\n"
|
||||
|
|
Loading…
Reference in New Issue