From 2f606e96c3a11ee1c867a54a9a1b6407e8328296 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 11 Jan 2024 20:40:03 +0100 Subject: [PATCH] Improve support for std::priority_queue, std::tie (#5871) --- cfg/std.cfg | 23 +++++++++++++++++------ test/cfg/std.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/cfg/std.cfg b/cfg/std.cfg index b32b4cae74a..753cd006ae1 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -6642,7 +6642,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun - + false @@ -6678,7 +6678,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun - + false @@ -6811,10 +6811,10 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun - + false - + false @@ -8587,6 +8587,17 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init false + + false + + + + + + false + + + malloc calloc @@ -8675,7 +8686,7 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init - + @@ -8684,7 +8695,7 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init - + diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 28279b77a6f..1d2c17e8de6 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -25,6 +25,7 @@ #define __STDC_WANT_LIB_EXT1__ 1 #include #include +#include #include #include #ifndef __STDC_NO_THREADS__ @@ -38,7 +39,10 @@ #include #include #include +#include +#include #include +#include #include #include #include @@ -899,6 +903,34 @@ int std_map_find_constref(std::map& m) // #11857 return ++*p; } +void std_queue_front_ignoredReturnValue(const std::queue& q) { + // cppcheck-suppress ignoredReturnValue + q.front(); +} + +void std_priority_queue_top_ignoredReturnValue(const std::priority_queue& pq) { + // cppcheck-suppress ignoredReturnValue + pq.top(); +} + +void std_tie_ignoredReturnValue(int a, int b) +{ + std::set s; + std::set::iterator it; + bool success; + std::tie(it, success) = s.insert(1); + // cppcheck-suppress ignoredReturnValue + std::tie(); + // cppcheck-suppress ignoredReturnValue + std::tie(a, b); +} + +void std_exception_ignoredReturnValue(const std::exception& e) +{ + // cppcheck-suppress ignoredReturnValue + e.what(); +} + void valid_code() { std::vector vecInt{0, 1, 2};