Fix 10318: iterator converted to type, wrong scope check (#3433)
This commit is contained in:
parent
15eb53b403
commit
7ce17f076a
|
@ -3253,7 +3253,7 @@ static void valueFlowForwardLifetime(Token * tok, TokenList *tokenlist, ErrorLog
|
|||
return;
|
||||
}
|
||||
Token *parent = tok->astParent();
|
||||
while (parent && (parent->isArithmeticalOp() || parent->str() == ","))
|
||||
while (parent && parent->str() == ",")
|
||||
parent = parent->astParent();
|
||||
if (!parent)
|
||||
return;
|
||||
|
|
|
@ -2421,6 +2421,17 @@ private:
|
|||
" }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("int f() {\n"
|
||||
" int i;\n"
|
||||
" {\n"
|
||||
" std::vector<int> vec;\n"
|
||||
" const auto iter = vec.begin();\n"
|
||||
" i = (int)(iter - vec.begin());\n"
|
||||
" }\n"
|
||||
" return i;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void danglingLifetime() {
|
||||
|
|
Loading…
Reference in New Issue