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;
|
return;
|
||||||
}
|
}
|
||||||
Token *parent = tok->astParent();
|
Token *parent = tok->astParent();
|
||||||
while (parent && (parent->isArithmeticalOp() || parent->str() == ","))
|
while (parent && parent->str() == ",")
|
||||||
parent = parent->astParent();
|
parent = parent->astParent();
|
||||||
if (!parent)
|
if (!parent)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2421,6 +2421,17 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
"};\n");
|
"};\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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() {
|
void danglingLifetime() {
|
||||||
|
|
Loading…
Reference in New Issue