std.cfg: Added returnValue calculation for isless(), islessgreater() etc.

This commit is contained in:
orbitcowboy 2018-11-20 16:58:33 +01:00
parent a722ba4f89
commit b4aa04db41
2 changed files with 49 additions and 5 deletions

View File

@ -3178,7 +3178,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<function name="isgreater,std::isgreater">
<use-retval/>
<pure/>
<returnValue type="int"/>
<returnValue type="int">arg1&gt;arg2?1:0</returnValue>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -3192,7 +3192,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<function name="isgreaterequal,std::isgreaterequal">
<use-retval/>
<pure/>
<returnValue type="int"/>
<returnValue type="int">arg1 &gt;= arg2?1:0</returnValue>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -3255,7 +3255,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<function name="isless,std::isless">
<use-retval/>
<pure/>
<returnValue type="int"/>
<returnValue type="int">arg1&lt;arg2?1:0</returnValue>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -3269,7 +3269,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<function name="islessequal,std::islessequal">
<use-retval/>
<pure/>
<returnValue type="int"/>
<returnValue type="int">arg1 &lt;= arg2?1:0</returnValue>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -3283,7 +3283,8 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<function name="islessgreater,std::islessgreater">
<use-retval/>
<pure/>
<returnValue type="int"/>
<returnValue type="int">(arg1&lt;arg2 || arg1&gt;arg2)?1:0</returnValue>
<!-- true if x < y || x > y, false otherwise -->
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">

View File

@ -27,6 +27,49 @@
#include <vector>
#include <cstdarg>
void returnValue_std_isgreater(void)
{
// cppcheck-suppress knownConditionTrueFalse
if (std::isgreater(4,2) == 0) {}
// @todo support floats
if (std::isgreater(4.0f,2.0f) == 0) {}
}
void returnValue_std_isgreaterequal(void)
{
// cppcheck-suppress knownConditionTrueFalse
if (std::isgreaterequal(4,2) == 0) {}
// @todo support floats
if (std::isgreaterequal(4.0f,2.0f) == 0) {}
}
void returnValue_std_isless(void)
{
// cppcheck-suppress knownConditionTrueFalse
if (std::isless(4,2) == 0) {}
// @todo support floats
if (std::isless(4.0f,2.0f) == 0) {}
}
void returnValue_std_islessequal(void)
{
// cppcheck-suppress knownConditionTrueFalse
if (std::islessequal(4,2) == 0) {}
// @todo support floats
if (std::islessequal(4.0f,2.0f) == 0) {}
}
void returnValue_std_islessgreater(void)
{
// cppcheck-suppress knownConditionTrueFalse
if (std::islessgreater(4,2) == 0) {}
// cppcheck-suppress knownConditionTrueFalse
if (std::islessgreater(2,4) == 0) {}
if (std::islessgreater(4.0f,2.0f) == 0) {} // @todo support floats
if (std::islessgreater(2.0f,4.0f) == 0) {} // @todo support floats
}
void bufferAccessOutOfBounds(void)
{
char a[5];