2019-01-08 20:30:21 +01:00
|
|
|
|
|
|
|
// Test library configuration for boost.cfg
|
|
|
|
//
|
|
|
|
// Usage:
|
2023-01-26 22:28:04 +01:00
|
|
|
// $ cppcheck --check-library --library=boost --enable=style --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/boost.cpp
|
2019-01-08 20:30:21 +01:00
|
|
|
// =>
|
|
|
|
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <boost/config.hpp>
|
2019-03-15 11:13:08 +01:00
|
|
|
#include <boost/math/special_functions/round.hpp>
|
|
|
|
#include <boost/endian/conversion.hpp>
|
2019-09-25 12:49:05 +02:00
|
|
|
#include <boost/bind.hpp>
|
|
|
|
#include <boost/function.hpp>
|
2019-01-08 20:30:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
BOOST_FORCEINLINE void boost_forceinline_test()
|
2021-08-07 20:51:18 +02:00
|
|
|
{}
|
2019-01-08 20:30:21 +01:00
|
|
|
|
|
|
|
BOOST_NOINLINE void boost_noinline_test()
|
2021-08-07 20:51:18 +02:00
|
|
|
{}
|
2019-01-08 20:30:21 +01:00
|
|
|
|
|
|
|
BOOST_NORETURN void boost_noreturn_test()
|
2021-08-07 20:51:18 +02:00
|
|
|
{}
|
2019-01-08 20:30:21 +01:00
|
|
|
|
2019-09-25 12:49:05 +02:00
|
|
|
void print_hello()
|
|
|
|
{
|
|
|
|
printf("hello");
|
|
|
|
}
|
|
|
|
|
|
|
|
void valid_code(boost::function<void(void)> &pf_print_hello)
|
2019-01-08 20:30:21 +01:00
|
|
|
{
|
2021-08-07 20:51:18 +02:00
|
|
|
if (BOOST_LIKELY(1)) {}
|
|
|
|
if (BOOST_UNLIKELY(0)) {}
|
2019-03-15 11:13:08 +01:00
|
|
|
|
|
|
|
int int1 = 5;
|
|
|
|
boost::endian::endian_reverse_inplace(int1);
|
2019-09-25 12:49:05 +02:00
|
|
|
boost::bind(print_hello)();
|
|
|
|
pf_print_hello = boost::bind(print_hello);
|
2019-03-15 11:13:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ignoredReturnValue(char * buf)
|
|
|
|
{
|
|
|
|
// cppcheck-suppress ignoredReturnValue
|
|
|
|
boost::math::round(1.5);
|
|
|
|
// cppcheck-suppress ignoredReturnValue
|
|
|
|
boost::math::iround(1.5);
|
|
|
|
// cppcheck-suppress ignoredReturnValue
|
|
|
|
boost::math::lround(1.5);
|
|
|
|
// cppcheck-suppress ignoredReturnValue
|
|
|
|
boost::math::llround(1.5);
|
|
|
|
// cppcheck-suppress ignoredReturnValue
|
|
|
|
boost::endian::endian_reverse(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void uninitvar()
|
|
|
|
{
|
|
|
|
int intUninit1;
|
|
|
|
int intUninit2;
|
|
|
|
// cppcheck-suppress uninitvar
|
|
|
|
boost::endian::endian_reverse_inplace(intUninit1);
|
|
|
|
// cppcheck-suppress uninitvar
|
|
|
|
(void)boost::math::round(intUninit2);
|
2019-01-08 20:30:21 +01:00
|
|
|
}
|
2020-06-17 19:01:32 +02:00
|
|
|
|
|
|
|
void throwexception(int * buf)
|
|
|
|
{
|
|
|
|
if (!buf)
|
|
|
|
boost::throw_exception(std::bad_alloc());
|
|
|
|
*buf = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void throwexception2(int * buf)
|
|
|
|
{
|
|
|
|
if (!buf)
|
|
|
|
BOOST_THROW_EXCEPTION(std::bad_alloc());
|
|
|
|
*buf = 0;
|
|
|
|
}
|
2021-02-20 13:19:06 +01:00
|
|
|
|
|
|
|
void macros()
|
|
|
|
{
|
2021-02-20 13:33:57 +01:00
|
|
|
#define DECL(z, n, text) text ## n = n;
|
2021-02-20 13:19:06 +01:00
|
|
|
BOOST_PP_REPEAT(5, DECL, int x)
|
|
|
|
|
2021-02-20 13:33:57 +01:00
|
|
|
BOOST_SCOPED_ENUM_DECLARE_BEGIN(future_errc) {
|
2021-02-20 13:19:06 +01:00
|
|
|
no_state
|
|
|
|
}
|
|
|
|
BOOST_SCOPED_ENUM_DECLARE_END(future_errc)
|
|
|
|
}
|