Improved testing of std.cfg regarding uninitialized variables.

This commit is contained in:
orbitcowboy 2015-09-02 17:08:25 +02:00
parent 89c4e08fc4
commit 34551203a6
3 changed files with 167 additions and 6 deletions

View File

@ -2187,7 +2187,7 @@
<!-- double nextafter(double x, double y); -->
<!-- float nextafterf(float x, float y); -->
<!-- long double nextafterl(long double x, long double y);-->
<function name="nextafter,nextafterf,nextafterl">
<function name="nextafter,std::nextafter,nextafterf,std::nextafterf,nextafterl,std::nextafterl">
<pure/>
<use-retval/>
<noreturn>false</noreturn>
@ -2202,7 +2202,7 @@
<!-- double nexttoward(double x, long double y); -->
<!-- float nexttowardf(float x, long double y); -->
<!-- long double nexttowardl(long double x, long double y); -->
<function name="nexttoward,nexttowardf,nexttowardl">
<function name="nexttoward,std::nexttoward,nexttowardf,std::nexttowardf,nexttowardl,std::nexttowardl">
<pure/>
<use-retval/>
<noreturn>false</noreturn>
@ -2215,7 +2215,7 @@
</arg>
</function>
<!-- void longjmp(jmp_buf env, int val); -->
<function name="longjmp">
<function name="longjmp,std::longjmp">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -2226,13 +2226,14 @@
</arg>
</function>
<!-- void * malloc(size_t size); -->
<function name="malloc">
<function name="malloc,std::malloc">
<use-retval/>
<noreturn>false</noreturn>
<arg nr="1">
<not-uninit/>
</arg>
</function>
<!-- void *alloca(size_t size); -->
<function name="alloca">
<use-retval/>
<noreturn>false</noreturn>
@ -2241,7 +2242,7 @@
</arg>
</function>
<!-- int memchr(const void *cs, int c, size_t n);-->
<function name="memchr">
<function name="memchr,std::memchr">
<use-retval/>
<pure/>
<noreturn>false</noreturn>
@ -2257,12 +2258,13 @@
<valid>0:</valid>
</arg>
<arg nr="3">
<not-uninit/>
<not-bool/>
<valid>0:</valid>
</arg>
</function>
<!-- wchar_t *wmemchr(const wchar_t *cs, wchar_t c, size_t n);-->
<function name="wmemchr">
<function name="wmemchr,std::wmemchr">
<use-retval/>
<pure/>
<noreturn>false</noreturn>
@ -2278,6 +2280,7 @@
<valid>0:</valid>
</arg>
<arg nr="3">
<not-uninit/>
<not-bool/>
<valid>0:</valid>
</arg>
@ -2299,6 +2302,7 @@
<minsize type="argvalue" arg="3"/>
</arg>
<arg nr="3">
<not-uninit/>
<not-bool/>
<valid>0:</valid>
</arg>

View File

@ -14,6 +14,7 @@
#include <wchar.h>
#include <wctype.h>
#include <fenv.h>
#include <setjmp.h>
void bufferAccessOutOfBounds(void)
{
@ -2292,3 +2293,84 @@ void uninitvar_nearbyint(void)
// cppcheck-suppress uninitvar
(void)nearbyintl(ld);
}
void uninitvar_nextafter(void)
{
float f1,f2;
// cppcheck-suppress uninitvar
(void)nextafterf(f1,f2);
double d1,d2;
// cppcheck-suppress uninitvar
(void)nextafter(d1,d2);
long double ld1,ld2;
// cppcheck-suppress uninitvar
(void)nextafterl(ld1,ld2);
}
void uninitvar_nexttoward(void)
{
float f1,f2;
// cppcheck-suppress uninitvar
(void)nexttowardf(f1,f2);
double d1,d2;
// cppcheck-suppress uninitvar
(void)nexttoward(d1,d2);
long double ld1,ld2;
// cppcheck-suppress uninitvar
(void)nexttowardl(ld1,ld2);
}
void uninitvar_longjmp(void)
{
jmp_buf env;
int val;
// cppcheck-suppress uninitvar
(void)longjmp(env,val);
}
void uninitvar_malloc(void)
{
size_t size;
// cppcheck-suppress uninitvar
int *p = (int*)malloc(size);
free(p);
}
void uninitvar_alloca(void)
{
size_t size;
// cppcheck-suppress obsoleteFunctionsalloca
// cppcheck-suppress uninitvar
(void)alloca(size);
}
void uninitvar_memchr(void)
{
void *cs;
int c;
size_t n;
// cppcheck-suppress uninitvar
(void)memchr(cs,c,n);
}
void uninitvar_wmemchr(void)
{
wchar_t *cs;
wchar_t c;
size_t n;
// cppcheck-suppress uninitvar
(void)wmemchr(cs,c,n);
}
void uninitvar_memcmp(void)
{
void *s1;
void *s2;
size_t n;
// cppcheck-suppress uninitvar
(void)memcmp(s1,s2,n);
}

View File

@ -16,6 +16,8 @@
#include <cassert>
#include <cwchar>
#include <cfenv>
#include <csetjmp>
#include <cmath>
void bufferAccessOutOfBounds(void)
{
@ -1640,3 +1642,76 @@ void uninitvar_nearbyint(void)
// cppcheck-suppress uninitvar
(void)std::nearbyintl(ld);
}
void uninitvar_nextafter(void)
{
float f1,f2;
// cppcheck-suppress uninitvar
(void)std::nextafterf(f1,f2);
double d1,d2;
// cppcheck-suppress uninitvar
(void)std::nextafter(d1,d2);
long double ld1,ld2;
// cppcheck-suppress uninitvar
(void)std::nextafterl(ld1,ld2);
}
void uninitvar_nexttoward(void)
{
float f1,f2;
// cppcheck-suppress uninitvar
(void)std::nexttowardf(f1,f2);
double d1,d2;
// cppcheck-suppress uninitvar
(void)std::nexttoward(d1,d2);
long double ld1,ld2;
// cppcheck-suppress uninitvar
(void)std::nexttowardl(ld1,ld2);
}
void uninitvar_longjmp(void)
{
jmp_buf env;
int val;
// cppcheck-suppress uninitvar
(void)std::longjmp(env,val);
}
void uninitvar_malloc(void)
{
size_t size;
// cppcheck-suppress uninitvar
int *p = (int*)std::malloc(size);
free(p);
}
void uninitvar_memchr(void)
{
void *cs;
int c;
size_t n;
// cppcheck-suppress uninitvar
(void)std::memchr(cs,c,n);
}
void uninitvar_wmemchr(void)
{
wchar_t *cs;
wchar_t c;
size_t n;
// cppcheck-suppress uninitvar
(void)std::wmemchr(cs,c,n);
}
void uninitvar_memcmp(void)
{
void *s1;
void *s2;
size_t n;
// cppcheck-suppress uninitvar
(void)std::memcmp(s1,s2,n);
}