test/cfg: Improved testing of std.cfg regarding uninitialized variables.

This commit is contained in:
orbitcowboy 2015-09-09 16:59:26 +02:00
parent 52090f5725
commit 2b416419de
3 changed files with 58 additions and 7 deletions

View File

@ -3751,7 +3751,7 @@
</arg> </arg>
</function> </function>
<!-- /*unspecified*/ setw(int n); --> <!-- /*unspecified*/ setw(int n); -->
<function name="std::setw"> <function name="setw,std::setw">
<noreturn>false</noreturn> <noreturn>false</noreturn>
<leak-ignore/> <leak-ignore/>
<arg nr="1"> <arg nr="1">
@ -3759,7 +3759,7 @@
</arg> </arg>
</function> </function>
<!-- /*unspecified*/ setiosflags(ios_base::fmtflags mask); --> <!-- /*unspecified*/ setiosflags(ios_base::fmtflags mask); -->
<function name="std::setiosflags"> <function name="setiosflags,std::setiosflags">
<noreturn>false</noreturn> <noreturn>false</noreturn>
<leak-ignore/> <leak-ignore/>
<arg nr="1"> <arg nr="1">
@ -3767,7 +3767,7 @@
</arg> </arg>
</function> </function>
<!-- /*unspecified*/ resetiosflags(ios_base::fmtflags mask); --> <!-- /*unspecified*/ resetiosflags(ios_base::fmtflags mask); -->
<function name="resetiosflags"> <function name="resetiosflags,std::resetiosflags">
<noreturn>false</noreturn> <noreturn>false</noreturn>
<leak-ignore/> <leak-ignore/>
<arg nr="1"> <arg nr="1">
@ -3775,7 +3775,7 @@
</arg> </arg>
</function> </function>
<!-- /*unspecified*/ setfill(char_type c); --> <!-- /*unspecified*/ setfill(char_type c); -->
<function name="setfill"> <function name="setfill,std::setfill">
<noreturn>false</noreturn> <noreturn>false</noreturn>
<leak-ignore/> <leak-ignore/>
<arg nr="1"> <arg nr="1">
@ -3783,7 +3783,7 @@
</arg> </arg>
</function> </function>
<!-- /*unspecified*/ setprecision(int n); --> <!-- /*unspecified*/ setprecision(int n); -->
<function name="setprecision"> <function name="setprecision,std::setprecision">
<noreturn>false</noreturn> <noreturn>false</noreturn>
<leak-ignore/> <leak-ignore/>
<arg nr="1"> <arg nr="1">
@ -3791,7 +3791,7 @@
</arg> </arg>
</function> </function>
<!-- /*unspecified*/ setbase(int base); --> <!-- /*unspecified*/ setbase(int base); -->
<function name="setbase"> <function name="setbase,std::setbase">
<noreturn>false</noreturn> <noreturn>false</noreturn>
<leak-ignore/> <leak-ignore/>
<arg nr="1"> <arg nr="1">
@ -3811,7 +3811,8 @@
<not-uninit/> <not-uninit/>
</arg> </arg>
</function> </function>
<!--Not part of standard, but widely supported by runtime libraries--> <!-- Not part of standard, but widely supported by runtime libraries. -->
<!-- char * itoa (int value, char * str, int base); -->
<function name="itoa"> <function name="itoa">
<noreturn>false</noreturn> <noreturn>false</noreturn>
<leak-ignore/> <leak-ignore/>

View File

@ -3350,3 +3350,20 @@ void uninitvar_system(void)
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)system(c); (void)system(c);
} }
void uninitvar_zonetime(void)
{
time_t *tp;
int zone;
// cppcheck-suppress uninitvar
(void)zonetime(tp,zone);
}
void uninitvar_itoa(void)
{
int value;
char * str;
int base;
// cppcheck-suppress uninitvar
(void)itoa(value,str,base);
}

View File

@ -2676,3 +2676,36 @@ void uninitvar_setiosflags(void)
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
std::cout << std::setiosflags(mask); // #6987 - false negative std::cout << std::setiosflags(mask); // #6987 - false negative
} }
void uninitvar_resetiosflags(void)
{
std::ios_base::fmtflags mask;
// cppcheck-suppress uninitvar
std::cout << std::resetiosflags(mask); // #6987 - false negative
}
void uninitvar_setfill(void)
{
char c;
// cppcheck-suppress uninitvar
std::cout << std::setfill(c);
wchar_t wc;
// cppcheck-suppress uninitvar
std::wcout << std::setfill(wc);
}
void uninitvar_setprecision(void)
{
int p;
// cppcheck-suppress uninitvar
std::cout << std::setprecision(p);
}
void uninitvar_setbase(void)
{
int p;
// cppcheck-suppress uninitvar
std::cout << std::setbase(p);
}