Skip to content

Commit 3962241

Browse files
committed
Improved std.cfg and added coressponding test cases to test/cfg.
1 parent 841ad54 commit 3962241

3 files changed

Lines changed: 72 additions & 2 deletions

File tree

cfg/std.cfg

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
<not-bool/>
1616
</arg>
1717
</function>
18+
<!-- intmax_t imaxabs(intmax_t n); -->
19+
<function name="imaxabs,std::imaxabs">
20+
<use-retval/>
21+
<pure/>
22+
<noreturn>false</noreturn>
23+
<leak-ignore/>
24+
<arg nr="1">
25+
<not-uninit/>
26+
</arg>
27+
</function>
1828
<!-- std::proj(std::complex) -->
1929
<function name="std::proj">
2030
<use-retval/>
@@ -634,6 +644,19 @@
634644
<valid>:-1,1:</valid>
635645
</arg>
636646
</function>
647+
<!-- imaxdiv_t imaxdiv (intmax_t numer, intmax_t denom); -->
648+
<function name="imaxdiv,std::imaxdiv">
649+
<pure/>
650+
<noreturn>false</noreturn>
651+
<leak-ignore/>
652+
<arg nr="1">
653+
<not-uninit/>
654+
</arg>
655+
<arg nr="2">
656+
<not-uninit/>
657+
<valid>:-1,1:</valid>
658+
</arg>
659+
</function>
637660
<!-- void exit(int status); -->
638661
<function name="exit,std::exit">
639662
<noreturn>true</noreturn>
@@ -3414,7 +3437,9 @@
34143437
<!-- unsigned long strtoul(const char *s, char **endp, int base); -->
34153438
<!-- long long strtoll(const char *s, char **endp, int base); -->
34163439
<!-- unsigned long long strtoull(const char *s, char **endp, int base); -->
3417-
<function name="strtol,std::strtol,strtoul,std::strtoul,strtoll,std::strtoll,strtoull,std::strtoull">
3440+
<!-- intmax_t strtoimax (const char* str, char** endptr, int base); -->
3441+
<!-- uintmax_t strtoumax (const char* str, char** endptr, int base); -->
3442+
<function name="strtol,std::strtol,strtoul,std::strtoul,strtoll,std::strtoll,strtoull,std::strtoull,strtoimax,std::strtoimax,strtoumax,std::strtoumax">
34183443
<noreturn>false</noreturn>
34193444
<leak-ignore/>
34203445
<arg nr="1">
@@ -3593,7 +3618,9 @@
35933618
<!-- long long wcstoll(const wchar_t *s, wchar ** endp, int base); -->
35943619
<!-- unsigned long wcstoul(const wchar_t *s, wchar ** endp, int base); -->
35953620
<!-- unsigned long long wcstoull(const wchar_t *s, wchar ** endp, int base); -->
3596-
<function name="wcstol,std::wcstol,wcstoll,std::wcstoll,wcstoul,std::wcstoul,wcstoull,std::wcstoull">
3621+
<!-- intmax_t wcstoimax (const wchar_t* wcs, wchar_t** endptr, int base); -->
3622+
<!-- uintmax_t wcstoumax (const wchar_t* wcs, wchar_t** endptr, int base); -->
3623+
<function name="wcstol,std::wcstol,wcstoll,std::wcstoll,wcstoul,std::wcstoul,wcstoull,std::wcstoull,wcstoimax,std::wcstoimax,wcstoumax,std::wcstoumax">
35973624
<use-retval/>
35983625
<noreturn>false</noreturn>
35993626
<leak-ignore/>

test/cfg/std.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <setjmp.h>
1818
#include <time.h>
1919
#include <stdbool.h>
20+
#include <stdint.h>
2021

2122
void bufferAccessOutOfBounds(void)
2223
{
@@ -191,6 +192,13 @@ void nullpointerMemcmp(char *p)
191192

192193
// uninit pointers
193194

195+
void uninivar_abs(void)
196+
{
197+
int i;
198+
// cppcheck-suppress uninitvar
199+
(void)abs(i);
200+
}
201+
194202
void uninit_clearerr(void)
195203
{
196204
FILE *fp;

test/cfg/std.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ void uninitvar_abs(void)
4545
(void)std::abs(i);
4646
}
4747

48+
void uninivar_imaxabs(void)
49+
{
50+
intmax_t i;
51+
// cppcheck-suppress uninitvar
52+
(void)std::imaxabs(i);
53+
// cppcheck-suppress uninitvar
54+
(void)imaxabs(i);
55+
}
56+
4857
void uninitvar_isalnum(void)
4958
{
5059
int i;
@@ -523,6 +532,16 @@ void uninitvar_div(void)
523532
(void)std::div(num,denom);
524533
}
525534

535+
void uninitvar_imaxdiv(void)
536+
{
537+
intmax_t numer;
538+
intmax_t denom;
539+
// cppcheck-suppress uninitvar
540+
(void)std::imaxdiv(numer,denom);
541+
// cppcheck-suppress uninitvar
542+
(void)imaxdiv(numer,denom);
543+
}
544+
526545
void uninitvar_exit(void)
527546
{
528547
int i;
@@ -2447,6 +2466,14 @@ void uninivar_strtol(void)
24472466
(void)std::strtoul(s,endp,base);
24482467
// cppcheck-suppress uninitvar
24492468
(void)std::strtoull(s,endp,base);
2469+
// cppcheck-suppress uninitvar
2470+
(void)std::strtoimax(s,endp,base);
2471+
// cppcheck-suppress uninitvar
2472+
(void)strtoimax(s,endp,base);
2473+
// cppcheck-suppress uninitvar
2474+
(void)std::strtoumax(s,endp,base);
2475+
// cppcheck-suppress uninitvar
2476+
(void)strtoumax(s,endp,base);
24502477
}
24512478

24522479
void uninitvar_time(void)
@@ -2633,6 +2660,14 @@ void uninivar_wcstol(void)
26332660
(void)std::wcstoul(s,endp,base);
26342661
// cppcheck-suppress uninitvar
26352662
(void)std::wcstoull(s,endp,base);
2663+
// cppcheck-suppress uninitvar
2664+
(void)std::wcstoimax(s,endp,base);
2665+
// cppcheck-suppress uninitvar
2666+
(void)wcstoimax(s,endp,base);
2667+
// cppcheck-suppress uninitvar
2668+
(void)std::wcstoumax(s,endp,base);
2669+
// cppcheck-suppress uninitvar
2670+
(void)wcstoumax(s,endp,base);
26362671
}
26372672

26382673
void uninitvar_wprintf(wchar_t *format, int input)

0 commit comments

Comments
 (0)