Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std.cfg: Added support for std::unexpected(). #6343

Merged
merged 2 commits into from
Apr 26, 2024
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
8 changes: 4 additions & 4 deletions cfg/cppcheck-cfg.rng
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
</attribute>
</optional>
<empty/>
</element>
</element>
</optional>
<optional>
<element name="pure"><empty/></element>
Expand Down Expand Up @@ -573,7 +573,7 @@
</element>
</choice>
</zeroOrMore>
</element>
</element>
</optional>
</element>

Expand Down Expand Up @@ -651,7 +651,7 @@
<param name="maxInclusive">2</param>
</data>
</define>

<define name="ARG-DIRECTION">
<choice>
<value>in</value>
Expand Down Expand Up @@ -720,7 +720,7 @@
<value>empty</value>
</choice>
</define>

<define name="MINSIZE-VALUE">
<data type="unsignedLong">
<param name="minInclusive">1</param>
Expand Down
7 changes: 7 additions & 0 deletions cfg/std.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
<function name="abort,std::abort,std::terminate">
<noreturn>true</noreturn>
</function>
<!-- void unexpected(); (until C++11) -->
<!-- [[noreturn]] void unexpected(); (since C++11) -->
<!-- (deprecated)(removed in C++17) -->
<function name="std::unexpected">
<noreturn>true</noreturn>
<warn severity="style" alternatives="std::terminate" reason="Obsolete"/>
</function>
<!-- int abs(int j); -->
<function name="abs,std::abs">
<use-retval/>
Expand Down
10 changes: 10 additions & 0 deletions test/cfg/std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@
#include <span>
#endif

#if __cplusplus <= 201402L
void unreachableCode_std_unexpected(int &x)
{
// cppcheck-suppress unexpectedCalled
std::unexpected();
// cppcheck-suppress unreachableCode
x=42;
}
#endif

void unreachableCode_std_terminate(int &x)
{
std::terminate();
Expand Down
Loading