std.cfg: Add configuration and tests for std::bind() (#2207)

TODO:
Somehow Cppcheck fails to print an ignoredReturnValue message when the
return value is not used (see ticket 
https://trac.cppcheck.net/ticket/9369 )
This commit is contained in:
Sebastian 2019-09-24 12:16:13 +02:00 committed by GitHub
parent 7ee1c0aa54
commit 5615da4547
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -7574,6 +7574,16 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
<not-uninit/>
</arg>
</function>
<!-- template< class F, class... Args > /*unspecified*/ bind( F&& f, Args&&... args ); // since C++11 -->
<!-- template< class R, class F, class... Args > /*unspecified*/ bind( F&& f, Args&&... args ); // since C++11 -->
<function name="std::bind">
<noreturn>false</noreturn>
<use-retval/>
<arg nr="1">
<not-uninit/>
</arg>
<arg nr="any"/>
</function>
<memory>
<alloc init="false" buffer-size="malloc">malloc</alloc>
<alloc init="true" buffer-size="calloc">calloc</alloc>

View File

@ -26,6 +26,7 @@
#include <fstream>
#include <vector>
#include <cstdarg>
#include <functional>
void returnValue_std_isgreater(void)
{
@ -3401,3 +3402,21 @@ void stdvector()
// cppcheck-suppress ignoredReturnValue
v.front();
}
void stdbind_helper(int a)
{
printf("%d", a);
}
void stdbind()
{
using namespace std::placeholders;
// TODO cppcheck-suppress ignoredReturnValue #9369
std::bind(stdbind_helper, 1);
// cppcheck-suppress unreadVariable
auto f1 = std::bind(stdbind_helper, _1);
// cppcheck-suppress unreadVariable
auto f2 = std::bind(stdbind_helper, 10);
}