From b53c4b2032acf970d85bf5a50dba2043fa7587c9 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 19 Apr 2018 16:41:25 +0200 Subject: [PATCH] std.cfg: Add std::vector function configurations and tests (#1180) --- cfg/std.cfg | 25 +++++++++++++++++++++++++ test/cfg/std.cpp | 22 ++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/cfg/std.cfg b/cfg/std.cfg index 002c784c6..7576e9742 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -6058,6 +6058,31 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun false + + + false + + + + + 0: + + + + + + + false + + + + + 0: + + + + + false diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 1c9406f25..59e160b20 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -3277,8 +3277,28 @@ void stdvector() std::vector 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(); }