Fix issue 9714: FP invalidContainer related to auto and std::string::insert (#2660)
This commit is contained in:
parent
526abd4b52
commit
6162ebd608
|
@ -827,7 +827,7 @@ void CheckStl::invalidContainer()
|
||||||
continue;
|
continue;
|
||||||
ErrorPath ep;
|
ErrorPath ep;
|
||||||
// Check the iterator is created before the change
|
// Check the iterator is created before the change
|
||||||
if (reaches(val.tokvalue, tok, library, &ep)) {
|
if (val.tokvalue != tok && reaches(val.tokvalue, tok, library, &ep)) {
|
||||||
v = &val;
|
v = &val;
|
||||||
errorPath = ep;
|
errorPath = ep;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -4123,6 +4123,15 @@ private:
|
||||||
" *it;\n"
|
" *it;\n"
|
||||||
"}\n",true);
|
"}\n",true);
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #9714
|
||||||
|
check("void f() {\n"
|
||||||
|
" auto v = std::vector<std::string>();\n"
|
||||||
|
" std::string x;\n"
|
||||||
|
" v.push_back(x.insert(0, \"x\"));\n"
|
||||||
|
" v.push_back(\"y\");\n"
|
||||||
|
"}\n",true);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void invalidContainerLoop() {
|
void invalidContainerLoop() {
|
||||||
|
|
Loading…
Reference in New Issue