Fixed #8039 (Tokenizer: wrong simplification of string)
This commit is contained in:
parent
bce0776417
commit
b68c8d91ab
|
@ -7371,9 +7371,6 @@ bool Tokenizer::IsScopeNoReturn(const Token *endScopeToken, bool *unknown) const
|
||||||
|
|
||||||
bool Tokenizer::isFunctionParameterPassedByValue(const Token *fpar) const
|
bool Tokenizer::isFunctionParameterPassedByValue(const Token *fpar) const
|
||||||
{
|
{
|
||||||
if (isC()) // C does not support references
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// TODO: If symbol database is available, use it.
|
// TODO: If symbol database is available, use it.
|
||||||
const Token *ftok;
|
const Token *ftok;
|
||||||
|
|
||||||
|
|
|
@ -2361,6 +2361,20 @@ private:
|
||||||
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true));
|
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const char code[] = "void f() {\n"
|
||||||
|
" char a[10];\n"
|
||||||
|
" strcpy(a, \"hello\");\n"
|
||||||
|
" strcat(a, \"!\");\n"
|
||||||
|
"}";
|
||||||
|
const char expected[] = "void f ( ) {\n"
|
||||||
|
"char a [ 10 ] ;\n"
|
||||||
|
"strcpy ( a , \"hello\" ) ;\n"
|
||||||
|
"strcat ( a , \"!\" ) ;\n"
|
||||||
|
"}";
|
||||||
|
ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Settings::Native, "test.c"));
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const char code[] = "void f() {"
|
const char code[] = "void f() {"
|
||||||
" char *s = malloc(10);"
|
" char *s = malloc(10);"
|
||||||
|
|
|
@ -3790,14 +3790,14 @@ private:
|
||||||
ASSERT_THROW(checkUninitVar(code), InternalError);
|
ASSERT_THROW(checkUninitVar(code), InternalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trac_5970() { // Ticket #5073
|
void trac_5970() { // Ticket #5970
|
||||||
checkUninitVar("void DES_ede3_ofb64_encrypt() {\n"
|
checkUninitVar("void DES_ede3_ofb64_encrypt() {\n"
|
||||||
" DES_cblock d; \n"
|
" DES_cblock d; \n"
|
||||||
" char *dp; \n"
|
" char *dp; \n"
|
||||||
" dp=(char *)d; \n"
|
" dp=(char *)d; \n"
|
||||||
" init(dp); \n"
|
" init(dp); \n"
|
||||||
"}", "test.c");
|
"}", "test.c");
|
||||||
ASSERT_EQUALS("", errout.str());
|
TODO_ASSERT_EQUALS("", "[test.c:4]: (error) Uninitialized variable: d\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue