Fix issue 9329: FP knownConditionTrueFalse - vector modified by function calls (#2145)
This commit is contained in:
parent
e657cf4073
commit
9e140831eb
|
@ -5426,6 +5426,8 @@ static bool isContainerSizeChanged(nonneg int varId, const Token *start, const T
|
|||
break;
|
||||
};
|
||||
}
|
||||
if (isContainerSizeChangedByFunction(tok))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -3218,6 +3218,33 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void alwaysTrueContainer() {
|
||||
// #9329
|
||||
check("void c1(std::vector<double>&);\n"
|
||||
"void c2(std::vector<double>&);\n"
|
||||
"void foo(int flag) {\n"
|
||||
" std::vector<double> g;\n"
|
||||
" if (flag)\n"
|
||||
" c1(g );\n"
|
||||
" else\n"
|
||||
" c2(g );\n"
|
||||
" if ( !g.empty() )\n"
|
||||
" return;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(int flag) {\n"
|
||||
" std::vector<double> g;\n"
|
||||
" if (flag)\n"
|
||||
" c1(g );\n"
|
||||
" else\n"
|
||||
" c2(g );\n"
|
||||
" if ( !g.empty() )\n"
|
||||
" return;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void multiConditionAlwaysTrue() {
|
||||
check("void f() {\n"
|
||||
" int val = 0;\n"
|
||||
|
|
Loading…
Reference in New Issue