Skip to content

Commit

Permalink
std.cfg: Added support for std::terminate() (danmar#6334)
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitcowboy authored Apr 23, 2024
1 parent 24be0e5 commit 7dab204
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cfg/std.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
<!-- errno_t is a typedef for int -->
<define name="errno_t" value="int"/>
<!-- void abort(void); -->
<function name="abort,std::abort">
<!-- void std::terminate(); (until C++11) -->
<!-- [[noreturn]] void std::terminate() noexcept; (since C++11) -->
<function name="abort,std::abort,std::terminate">
<noreturn>true</noreturn>
</function>
<!-- int abs(int j); -->
Expand Down
9 changes: 8 additions & 1 deletion test/cfg/std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
#include <span>
#endif

void unreachableCode_std_terminate(int &x)
{
std::terminate();
// cppcheck-suppress unreachableCode
x=42;
}

bool ignoredReturnValue_std_filesystem_exists(const std::filesystem::path &path, std::error_code& ec)
{
// cppcheck-suppress ignoredReturnValue
Expand Down Expand Up @@ -554,7 +561,7 @@ void bufferAccessOutOfBounds_std_ifstream_get(std::ifstream& in, std::streambuf&
in.getline(cBuf, 100, 'a');

in.get(sb, 'a');

in.close();
}

Expand Down

0 comments on commit 7dab204

Please sign in to comment.