From 435cffa8585e4688cfc3caafa96b0205da7ecced Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Wed, 14 Jul 2021 10:12:49 +0200 Subject: [PATCH] std.cfg: Improved configuration of std::next(),std::prev() and added TODO tests --- cfg/std.cfg | 10 ++++-- test/cfg/std.cpp | 79 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 71 insertions(+), 18 deletions(-) diff --git a/cfg/std.cfg b/cfg/std.cfg index c3d13b9a0..0c9500257 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -7747,7 +7747,10 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init false - + + + + @@ -7758,7 +7761,10 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init false - + + + + diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index d45c8a695..1d10031a7 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -7,28 +7,75 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include #include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include #include -#include +#include +#include +#include +#include +#include + +void uninitvar_std_next(const std::vector &v, int count) +{ + // No warning shall be shown: + if (std::next(v.begin()) != v.end()) {} + if (std::next(v.begin(), count) != v.end()) {} + + std::vector::iterator it; + // TODO-cppcheck-suppress uninitvar + if (std::next(it) != v.end()) {} + + std::vector::const_iterator const_it; + // TODO-cppcheck-suppress uninitvar + if (std::next(const_it) != v.end()) {} + + std::vector::reverse_iterator rit; + // TODO-cppcheck-suppress uninitvar + if (std::next(rit) != v.rend()) {} + + std::vector::const_reverse_iterator const_rit; + // TODO-cppcheck-suppress uninitvar + if (std::next(const_rit) != v.rend()) {} +} + +void uninitvar_std_prev(const std::vector &v, int count) +{ + // No warning shall be shown: + if (std::prev(v.begin()) != v.end()) {} + if (std::prev(v.begin(), count) != v.end()) {} + + std::vector::iterator it; + // TODO-cppcheck-suppress uninitvar + if (std::prev(it) != v.end()) {} + + std::vector::const_iterator const_it; + // TODO-cppcheck-suppress uninitvar + if (std::prev(const_it) != v.end()) {} + + std::vector::reverse_iterator rit; + // TODO-cppcheck-suppress uninitvar + if (std::prev(rit) != v.rend()) {} + + std::vector::const_reverse_iterator const_rit; + // TODO-cppcheck-suppress uninitvar + if (std::prev(const_rit) != v.rend()) {} +} void overlappingWriteFunction_wcscat(wchar_t *src, wchar_t *dest) {