Skip to content

Commit ccd4104

Browse files
authored
Fix #15164 std.cfg: std::isnan, std::signbit, ... return bool (#8986)
1 parent 0f2d722 commit ccd4104

2 files changed

Lines changed: 143 additions & 7 deletions

File tree

‎cfg/std.cfg‎

Lines changed: 94 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3461,7 +3461,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
34613461
</arg>
34623462
</function>
34633463
<!-- int isless(double x, double y); -->
3464-
<function name="isless,std::isless">
3464+
<function name="isless">
34653465
<use-retval/>
34663466
<pure/>
34673467
<returnValue type="int">arg1&lt;arg2?1:0</returnValue>
@@ -3474,8 +3474,21 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
34743474
<not-uninit/>
34753475
</arg>
34763476
</function>
3477+
<function name="std::isless">
3478+
<use-retval/>
3479+
<pure/>
3480+
<returnValue type="bool">arg1&lt;arg2?1:0</returnValue>
3481+
<noreturn>false</noreturn>
3482+
<leak-ignore/>
3483+
<arg nr="1" direction="in">
3484+
<not-uninit/>
3485+
</arg>
3486+
<arg nr="2" direction="in">
3487+
<not-uninit/>
3488+
</arg>
3489+
</function>
34773490
<!-- int islessequal(double x, double y); -->
3478-
<function name="islessequal,std::islessequal">
3491+
<function name="islessequal">
34793492
<use-retval/>
34803493
<pure/>
34813494
<returnValue type="int">arg1 &lt;= arg2?1:0</returnValue>
@@ -3488,8 +3501,21 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
34883501
<not-uninit/>
34893502
</arg>
34903503
</function>
3504+
<function name="std::islessequal">
3505+
<use-retval/>
3506+
<pure/>
3507+
<returnValue type="bool">arg1 &lt;= arg2?1:0</returnValue>
3508+
<noreturn>false</noreturn>
3509+
<leak-ignore/>
3510+
<arg nr="1" direction="in">
3511+
<not-uninit/>
3512+
</arg>
3513+
<arg nr="2" direction="in">
3514+
<not-uninit/>
3515+
</arg>
3516+
</function>
34913517
<!-- int islessgreater(double x, double y); -->
3492-
<function name="islessgreater,std::islessgreater">
3518+
<function name="islessgreater">
34933519
<use-retval/>
34943520
<pure/>
34953521
<returnValue type="int">(arg1&lt;arg2 || arg1&gt;arg2)?1:0</returnValue>
@@ -3503,6 +3529,20 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
35033529
<not-uninit/>
35043530
</arg>
35053531
</function>
3532+
<function name="std::islessgreater">
3533+
<use-retval/>
3534+
<pure/>
3535+
<returnValue type="bool">(arg1&lt;arg2 || arg1&gt;arg2)?1:0</returnValue>
3536+
<!-- true if x < y || x > y, false otherwise -->
3537+
<noreturn>false</noreturn>
3538+
<leak-ignore/>
3539+
<arg nr="1" direction="in">
3540+
<not-uninit/>
3541+
</arg>
3542+
<arg nr="2" direction="in">
3543+
<not-uninit/>
3544+
</arg>
3545+
</function>
35063546
<!-- double nan(const char *tagp); -->
35073547
<function name="nan,std::nan">
35083548
<use-retval/>
@@ -3547,7 +3587,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
35473587
<!-- bool isnan(double x); // since C++11 -->
35483588
<!-- bool isnan(long double x); // since C++11 -->
35493589
<!-- bool isnan(Integral x); // since C++11 -->
3550-
<function name="isnan,std::isnan">
3590+
<function name="isnan">
35513591
<use-retval/>
35523592
<pure/>
35533593
<returnValue type="int"/>
@@ -3558,12 +3598,23 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
35583598
<not-bool/>
35593599
</arg>
35603600
</function>
3601+
<function name="std::isnan">
3602+
<use-retval/>
3603+
<pure/>
3604+
<returnValue type="bool"/>
3605+
<noreturn>false</noreturn>
3606+
<leak-ignore/>
3607+
<arg nr="1" direction="in">
3608+
<not-uninit/>
3609+
<not-bool/>
3610+
</arg>
3611+
</function>
35613612
<!-- int isnormal(double x); -->
35623613
<!--bool isnormal(float x); // since C++11 -->
35633614
<!--bool isnormal(double x); // since C++11 -->
35643615
<!--bool isnormal(long double x); // since C++11 -->
35653616
<!--bool isnormal(Integral x); // since C++11 -->
3566-
<function name="isnormal,std::isnormal">
3617+
<function name="isnormal">
35673618
<use-retval/>
35683619
<pure/>
35693620
<returnValue type="int"/>
@@ -3574,12 +3625,23 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
35743625
<not-bool/>
35753626
</arg>
35763627
</function>
3628+
<function name="std::isnormal">
3629+
<use-retval/>
3630+
<pure/>
3631+
<returnValue type="bool"/>
3632+
<noreturn>false</noreturn>
3633+
<leak-ignore/>
3634+
<arg nr="1" direction="in">
3635+
<not-uninit/>
3636+
<not-bool/>
3637+
</arg>
3638+
</function>
35773639
<!-- int isunordered(double x, double y);-->
35783640
<!-- bool isunordered(float x, float y); // since C++11 -->
35793641
<!-- bool isunordered(double x, double y); // since C++11 -->
35803642
<!-- bool isunordered(long double x, long double y); // since C++11 -->
35813643
<!-- bool isunordered(Arithmetic x, Arithmetic y); // since C++11 -->
3582-
<function name="isunordered,std::isunordered">
3644+
<function name="isunordered">
35833645
<use-retval/>
35843646
<pure/>
35853647
<returnValue type="int"/>
@@ -3594,6 +3656,21 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
35943656
<not-bool/>
35953657
</arg>
35963658
</function>
3659+
<function name="std::isunordered">
3660+
<use-retval/>
3661+
<pure/>
3662+
<returnValue type="bool"/>
3663+
<noreturn>false</noreturn>
3664+
<leak-ignore/>
3665+
<arg nr="1" direction="in">
3666+
<not-uninit/>
3667+
<not-bool/>
3668+
</arg>
3669+
<arg nr="2" direction="in">
3670+
<not-uninit/>
3671+
<not-bool/>
3672+
</arg>
3673+
</function>
35973674
<!-- int ilogb(double x); -->
35983675
<function name="ilogb,std::ilogb">
35993676
<use-retval/>
@@ -4671,7 +4748,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
46714748
</arg>
46724749
</function>
46734750
<!-- int signbit(double x); -->
4674-
<function name="signbit,std::signbit">
4751+
<function name="signbit">
46754752
<use-retval/>
46764753
<pure/>
46774754
<returnValue type="int"/>
@@ -4681,6 +4758,16 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
46814758
<not-uninit/>
46824759
</arg>
46834760
</function>
4761+
<function name="std::signbit">
4762+
<use-retval/>
4763+
<pure/>
4764+
<returnValue type="bool"/>
4765+
<noreturn>false</noreturn>
4766+
<leak-ignore/>
4767+
<arg nr="1" direction="in">
4768+
<not-uninit/>
4769+
</arg>
4770+
</function>
46844771
<!-- void (*signal(int sig, void (*func)(int)))(int); -->
46854772
<function name="signal,std::signal">
46864773
<noreturn>false</noreturn>

‎test/cfg/std.cpp‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,6 +2838,13 @@ void uninitvar_logb(void)
28382838
(void)std::logbl(ld);
28392839
}
28402840

2841+
void bool_isless(float f1, float f2)
2842+
{
2843+
// cppcheck-suppress compareBoolExpressionWithInt
2844+
// cppcheck-suppress compareValueOutOfTypeRangeError
2845+
if (std::isless(f1,f2)==123) {}
2846+
}
2847+
28412848
void uninitvar_isless(void)
28422849
{
28432850
float f1,f2;
@@ -2853,6 +2860,13 @@ void uninitvar_isless(void)
28532860
(void)std::isless(ld1,ld2);
28542861
}
28552862

2863+
void bool_islessequal(float f1, float f2)
2864+
{
2865+
// cppcheck-suppress compareBoolExpressionWithInt
2866+
// cppcheck-suppress compareValueOutOfTypeRangeError
2867+
if (std::islessequal(f1,f2)==123) {}
2868+
}
2869+
28562870
void uninitvar_islessequal(void)
28572871
{
28582872
float f1,f2;
@@ -2868,6 +2882,13 @@ void uninitvar_islessequal(void)
28682882
(void)std::islessequal(ld1,ld2);
28692883
}
28702884

2885+
void bool_islessgreater(float f1, float f2)
2886+
{
2887+
// cppcheck-suppress compareBoolExpressionWithInt
2888+
// cppcheck-suppress compareValueOutOfTypeRangeError
2889+
if (std::islessgreater(f1,f2)==123) {}
2890+
}
2891+
28712892
void uninitvar_islessgreater(void)
28722893
{
28732894
float f1,f2;
@@ -2894,20 +2915,41 @@ void uninitvar_nan(void)
28942915
(void)std::nanl(tagp3);
28952916
}
28962917

2918+
void bool_isnan(float f)
2919+
{
2920+
// cppcheck-suppress compareBoolExpressionWithInt
2921+
// cppcheck-suppress compareValueOutOfTypeRangeError
2922+
if (std::isnan(f)==123) {}
2923+
}
2924+
28972925
void uninitvar_isnan(void)
28982926
{
28992927
double d;
29002928
// cppcheck-suppress uninitvar
29012929
(void)std::isnan(d);
29022930
}
29032931

2932+
void bool_isnormal(float f)
2933+
{
2934+
// cppcheck-suppress compareBoolExpressionWithInt
2935+
// cppcheck-suppress compareValueOutOfTypeRangeError
2936+
if (std::isnormal(f)==123) {}
2937+
}
2938+
29042939
void uninitvar_isnormal(void)
29052940
{
29062941
double d;
29072942
// cppcheck-suppress uninitvar
29082943
(void)std::isnormal(d);
29092944
}
29102945

2946+
void bool_isunordered(float f1, float f2)
2947+
{
2948+
// cppcheck-suppress compareBoolExpressionWithInt
2949+
// cppcheck-suppress compareValueOutOfTypeRangeError
2950+
if (std::isunordered(f1,f2)==123) {}
2951+
}
2952+
29112953
void uninitvar_isunordered(void)
29122954
{
29132955
double d1,d2;
@@ -3443,6 +3485,13 @@ void uninivar_scalbln(void)
34433485
(void)std::scalblnl(ld,i3);
34443486
}
34453487

3488+
void bool_signbit(float f)
3489+
{
3490+
// cppcheck-suppress compareBoolExpressionWithInt
3491+
// cppcheck-suppress compareValueOutOfTypeRangeError
3492+
if (std::signbit(f)==123) {}
3493+
}
3494+
34463495
void uninitvar_signbit(void)
34473496
{
34483497
double d;

0 commit comments

Comments
 (0)