std.cfg: Add std::vector function configurations and tests (#1180)

This commit is contained in:
Sebastian 2018-04-19 16:41:25 +02:00 committed by amai2012
parent e256ce8ea8
commit b53c4b2032
2 changed files with 47 additions and 0 deletions

View File

@ -6058,6 +6058,31 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<noreturn>false</noreturn>
<returnValue type="void"/>
</function>
<!-- void reserve(size_type new_capacity); -->
<function name="std::vector::reserve">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1">
<not-uninit/>
<not-bool/>
<valid>0:</valid>
</arg>
</function>
<!-- void resize(size_type count, T value = T()); // until C++11 -->
<!-- void resize(size_type count); // since C++11 -->
<!-- void resize(size_type count, const value_type& value); // since C++11 -->
<function name="std::vector::resize">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1">
<not-uninit/>
<not-bool/>
<valid>0:</valid>
</arg>
<arg nr="2" default="0">
<not-uninit/>
</arg>
</function>
<function name="std::stack::pop,std::queue::pop">
<noreturn>false</noreturn>
</function>

View File

@ -3277,8 +3277,28 @@ void stdvector()
std::vector<int> v;
// cppcheck-suppress ignoredReturnValue
v.size();
// cppcheck-suppress ignoredReturnValue
v.capacity();
// cppcheck-suppress uselessCallsEmpty
// cppcheck-suppress ignoredReturnValue
v.empty();
// cppcheck-suppress ignoredReturnValue
v.max_size();
// cppcheck-suppress uninitvar
v.push_back(uninit);
// cppcheck-suppress uninitvar
v.reserve(uninit);
// cppcheck-suppress invalidFunctionArg
v.reserve(-1);
// no warning is expected for capacity 0 as it simply has no effect
v.reserve(0);
// cppcheck-suppress uninitvar
v.resize(uninit);
// cppcheck-suppress invalidFunctionArg
v.resize(-1);
v.clear();
v.shrink_to_fit();
// no warning is expected for pop_back()
v.push_back(42);
@ -3287,4 +3307,6 @@ void stdvector()
v.push_back(42);
// cppcheck-suppress ignoredReturnValue
v.back();
// cppcheck-suppress ignoredReturnValue
v.front();
}