Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cfg/std.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
<noreturn>true</noreturn>
<warn severity="style" alternatives="std::terminate" reason="Obsolete"/>
</function>
<!-- [[noreturn]] void std::unreachable(); (since C++23) -->
<function name="std::unreachable">
<noreturn>true</noreturn>
</function>
<!-- int abs(int j); -->
<function name="abs,std::abs">
<use-retval/>
Expand Down
16 changes: 16 additions & 0 deletions test/cfg/std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ void unreachableCode_std_terminate(int &x)
x=42;
}

#ifdef __cpp_lib_unreachable
void unreachableCode_std_unreachable(int &x)
{
std::unreachable();
// cppcheck-suppress unreachableCode
x=42;
}

int missingReturn_std_unreachable(int x) // #15277
{
if (x == 0)
return 1;
std::unreachable();
}
#endif

bool ignoredReturnValue_std_filesystem_exists(const std::filesystem::path &path, std::error_code& ec)
{
// cppcheck-suppress ignoredReturnValue
Expand Down
Loading