Fixed #7711 (QString::asprintf format string checking.)

This commit is contained in:
Robert Reif 2016-08-24 12:44:57 +02:00 committed by Daniel Marjamäki
parent 706877df2d
commit 28e14f0b94
2 changed files with 16 additions and 0 deletions

View File

@ -78,6 +78,16 @@
<not-uninit/>
</arg>
</function>
<!-- QString & QString::asprintf(const char * cformat, ...); -->
<function name="QString::asprintf">
<noreturn>false</noreturn>
<leak-ignore/>
<formatstr/>
<arg nr="1">
<formatstr/>
<not-uninit/>
</arg>
</function>
<define name="Q_DECL_EXPORT" value=""/>
<define name="Q_DECL_IMPORT" value=""/>
<define name="Q_DECLARE_FLAGS(x,y)" value=""/>

View File

@ -2828,6 +2828,12 @@ private:
" string.sprintf(\"%d\", f);\n"
"}", false, false, Settings::Win32A);
ASSERT_EQUALS("[test.cpp:3]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'float'.\n", errout.str());
check("void foo(float f) {\n"
" QString string;\n"
" string = QString::asprintf(\"%d\", f);\n"
"}", false, false, Settings::Win32A);
ASSERT_EQUALS("[test.cpp:3]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'float'.\n", errout.str());
}
void testTernary() { // ticket #6182