Fix #11063 FP unreadVariable with extra parentheses and scope operator (#5122)

This commit is contained in:
chrchr-github 2023-06-07 20:45:27 +02:00 committed by GitHub
parent ae83d53813
commit 12fe652321
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -1459,7 +1459,7 @@ std::pair<const Token *, const Token *> Token::findExpressionStartEndTokens() co
}
}
if (Token::Match(end,"(|[|{") &&
!(Token::Match(end, "( %type%") && !end->astOperand2())) {
!(Token::Match(end, "( ::| %type%") && !end->astOperand2())) {
end = end->link();
break;
}

View File

@ -141,6 +141,7 @@ private:
TEST_CASE(localvar66); // #11143
TEST_CASE(localvar67); // #9946
TEST_CASE(localvar68);
TEST_CASE(localvar69);
TEST_CASE(localvarloops); // loops
TEST_CASE(localvaralias1);
TEST_CASE(localvaralias2); // ticket #1637
@ -3774,6 +3775,16 @@ private:
ASSERT_EQUALS("", errout.str());
}
void localvar69() {
functionVariableUsage("int g();\n" // #11063
"int h(int);\n"
"int f() {\n"
" int i = g();\n"
" return (::h)(i);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void localvarloops() {
// loops
functionVariableUsage("void fun(int c) {\n"