Add support for InvalidFunctionArg lgamma() (#5845)

Reference: https://en.cppreference.com/w/cpp/numeric/math/lgamma
This commit is contained in:
orbitcowboy 2024-01-05 23:34:08 +01:00 committed by GitHub
parent fde7ea6d17
commit 32cabecca9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View File

@ -3035,6 +3035,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<not-uninit/>
</arg>
</function>
<!-- https://cplusplus.com/reference/cmath/lgamma/ -->
<!-- double lgamma(double x); -->
<function name="lgamma,std::lgamma">
<use-retval/>
@ -3044,8 +3045,11 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<!-- If x is zero or a negative integer for which the function is asymptotic, it may cause a pole error (depending on implementation).-->
<valid>!0.0:</valid>
</arg>
</function>
<!-- https://cplusplus.com/reference/cmath/lgamma/ -->
<!-- float lgammaf(float x); -->
<function name="lgammaf,std::lgammaf">
<use-retval/>
@ -3055,8 +3059,11 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<!-- If x is zero or a negative integer for which the function is asymptotic, it may cause a pole error (depending on implementation).-->
<valid>!0.0:</valid>
</arg>
</function>
<!-- https://cplusplus.com/reference/cmath/lgamma/ -->
<!-- long double lgammal(long double x); -->
<function name="lgammal,std::lgammal">
<use-retval/>
@ -3066,6 +3073,8 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<!-- If x is zero or a negative integer for which the function is asymptotic, it may cause a pole error (depending on implementation).-->
<valid>!0.0:</valid>
</arg>
</function>
<!-- double rint(double x); -->

View File

@ -2382,6 +2382,30 @@ void uninitvar_ldexp(void)
(void)std::ldexp(ldc,e3);
}
void invalidFunctionArg_lgamma(float f, double d, long double ld)
{
(void)lgamma(d);
// cppcheck-suppress invalidFunctionArg
(void)lgamma(-0.1);
// cppcheck-suppress invalidFunctionArg
(void)lgamma(0.0);
(void)lgamma(0.1);
(void)lgammaf(f);
// cppcheck-suppress invalidFunctionArg
(void)lgammaf(-0.1f);
// cppcheck-suppress invalidFunctionArg
(void)lgammaf(0.0f);
(void)lgammaf(0.1f);
(void)lgammal(ld);
// cppcheck-suppress invalidFunctionArg
(void)lgammal(-0.1L);
// cppcheck-suppress invalidFunctionArg
(void)lgammal(0.0L);
(void)lgammal(0.1L);
}
void uninitvar_lgamma(void)
{
float f;