Tokenizer::setVarIdNew: Fixed issue found through TestUnusedVar tests
This commit is contained in:
parent
aeac38b673
commit
d63093d9bb
|
@ -2816,6 +2816,8 @@ static bool setVarIdParseDeclaration(const Token **tok, const std::map<std::stri
|
||||||
if (tok2->str() == "class" || tok2->str() == "struct" || tok2->str() == "union") {
|
if (tok2->str() == "class" || tok2->str() == "struct" || tok2->str() == "union") {
|
||||||
hasstruct = true;
|
hasstruct = true;
|
||||||
typeCount = 0;
|
typeCount = 0;
|
||||||
|
} else if (tok2->str() == "const") {
|
||||||
|
; // just skip "const"
|
||||||
} else if (!hasstruct && variableId.find(tok2->str()) != variableId.end()) {
|
} else if (!hasstruct && variableId.find(tok2->str()) != variableId.end()) {
|
||||||
++typeCount;
|
++typeCount;
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
|
@ -2841,9 +2843,11 @@ static bool setVarIdParseDeclaration(const Token **tok, const std::map<std::stri
|
||||||
|
|
||||||
// In executable scopes, references must be assigned
|
// In executable scopes, references must be assigned
|
||||||
// Catching by reference is an exception
|
// Catching by reference is an exception
|
||||||
if (executableScope && ref && tok2->str() != "=" &&
|
if (executableScope && ref) {
|
||||||
(tok2->str() != ")" || !Token::simpleMatch(tok2->link()->previous(), "catch"))) {
|
if (tok2->str() == "(" || tok2->str() == "=")
|
||||||
return false;
|
; // reference is assigned => ok
|
||||||
|
else if (tok2->str() != ")" || !Token::simpleMatch(tok2->link()->previous(), "catch"))
|
||||||
|
return false; // not catching by reference => not declaration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue