From 5f0d5d667ab94f7fdef3818fe2998a7062e27c72 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Thu, 25 Apr 2024 18:12:29 +0200 Subject: [PATCH 1/2] std.cfg: Added support for std::unexpected(). --- cfg/cppcheck-cfg.rng | 8 ++++---- cfg/std.cfg | 7 +++++++ test/cfg/std.cpp | 8 ++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/cfg/cppcheck-cfg.rng b/cfg/cppcheck-cfg.rng index 5dd446c1778..49dae39b483 100644 --- a/cfg/cppcheck-cfg.rng +++ b/cfg/cppcheck-cfg.rng @@ -122,7 +122,7 @@ - + @@ -573,7 +573,7 @@ - + @@ -651,7 +651,7 @@ 2 - + in @@ -720,7 +720,7 @@ empty - + 1 diff --git a/cfg/std.cfg b/cfg/std.cfg index 64ee508e69e..a8e08a4ac31 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -68,6 +68,13 @@ true + + + + + true + + diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 66eeb6598eb..53db9c06eff 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -58,6 +58,14 @@ #include #endif +void unreachableCode_std_unexpected(int &x) +{ + // cppcheck-suppress unexpectedCalled + std::unexpected(); + // cppcheck-suppress unreachableCode + x=42; +} + void unreachableCode_std_terminate(int &x) { std::terminate(); From 44222f6ee93d8c33b2fc68510544102977fd2138 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Fri, 26 Apr 2024 20:10:34 +0200 Subject: [PATCH 2/2] Fix --- test/cfg/std.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 53db9c06eff..11efa81f5d3 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -58,6 +58,7 @@ #include #endif +#if __cplusplus <= 201402L void unreachableCode_std_unexpected(int &x) { // cppcheck-suppress unexpectedCalled @@ -65,6 +66,7 @@ void unreachableCode_std_unexpected(int &x) // cppcheck-suppress unreachableCode x=42; } +#endif void unreachableCode_std_terminate(int &x) {