Skip to content

Commit 71212c7

Browse files
authored
std.cfg: Added support for invalidFunctionArg check to tgamma(). (#5850)
Reference: https://en.cppreference.com/w/cpp/numeric/math/tgamma
1 parent 32cabec commit 71212c7

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

cfg/std.cfg

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@
737737
<not-uninit/>
738738
</arg>
739739
</function>
740+
<!-- https://en.cppreference.com/w/cpp/numeric/math/tgamma -->
740741
<!-- double tgamma(double x); -->
741742
<function name="tgamma,std::tgamma">
742743
<use-retval/>
@@ -746,8 +747,11 @@
746747
<leak-ignore/>
747748
<arg nr="1" direction="in">
748749
<not-uninit/>
750+
<!-- If x is zero or a negative integer for which the function is asymptotic, it may cause a pole error (depending on implementation).-->
751+
<valid>!0.0:</valid>
749752
</arg>
750753
</function>
754+
<!-- https://en.cppreference.com/w/cpp/numeric/math/tgamma -->
751755
<!-- float tgammaf(float x); -->
752756
<function name="tgammaf,std::tgammaf">
753757
<use-retval/>
@@ -757,8 +761,11 @@
757761
<leak-ignore/>
758762
<arg nr="1" direction="in">
759763
<not-uninit/>
764+
<!-- If x is zero or a negative integer for which the function is asymptotic, it may cause a pole error (depending on implementation).-->
765+
<valid>!0.0:</valid>
760766
</arg>
761767
</function>
768+
<!-- https://en.cppreference.com/w/cpp/numeric/math/tgamma -->
762769
<!-- long double tgammal(long double x); -->
763770
<function name="tgammal,std::tgammal">
764771
<use-retval/>
@@ -768,6 +775,8 @@
768775
<leak-ignore/>
769776
<arg nr="1" direction="in">
770777
<not-uninit/>
778+
<!-- If x is zero or a negative integer for which the function is asymptotic, it may cause a pole error (depending on implementation).-->
779+
<valid>!0.0:</valid>
771780
</arg>
772781
</function>
773782
<!-- double trunc(double x); -->

test/cfg/std.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,6 +2406,30 @@ void invalidFunctionArg_lgamma(float f, double d, long double ld)
24062406
(void)lgammal(0.1L);
24072407
}
24082408

2409+
void invalidFunctionArg_tgamma(float f, double d, long double ld)
2410+
{
2411+
(void)tgamma(d);
2412+
// cppcheck-suppress invalidFunctionArg
2413+
(void)tgamma(-0.1);
2414+
// cppcheck-suppress invalidFunctionArg
2415+
(void)tgamma(0.0);
2416+
(void)tgamma(0.1);
2417+
2418+
(void)tgammaf(f);
2419+
// cppcheck-suppress invalidFunctionArg
2420+
(void)tgammaf(-0.1f);
2421+
// cppcheck-suppress invalidFunctionArg
2422+
(void)tgammaf(0.0f);
2423+
(void)tgammaf(0.1f);
2424+
2425+
(void)tgammal(ld);
2426+
// cppcheck-suppress invalidFunctionArg
2427+
(void)tgammal(-0.1L);
2428+
// cppcheck-suppress invalidFunctionArg
2429+
(void)tgammal(0.0L);
2430+
(void)tgammal(0.1L);
2431+
}
2432+
24092433
void uninitvar_lgamma(void)
24102434
{
24112435
float f;

0 commit comments

Comments
 (0)