From b68c8d91ab32b905eb133e5a97a046d1476f3047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 1 Jun 2017 22:21:02 +0200 Subject: [PATCH] Fixed #8039 (Tokenizer: wrong simplification of string) --- lib/tokenize.cpp | 3 --- test/testtokenize.cpp | 14 ++++++++++++++ test/testuninitvar.cpp | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 14b48f2e9..9c372c9eb 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7371,9 +7371,6 @@ bool Tokenizer::IsScopeNoReturn(const Token *endScopeToken, bool *unknown) 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. const Token *ftok; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 933449bd5..1f15e2d1a 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -2361,6 +2361,20 @@ private: 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() {" " char *s = malloc(10);" diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index c6d16050e..3ed0c5d93 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -3790,14 +3790,14 @@ private: ASSERT_THROW(checkUninitVar(code), InternalError); } - void trac_5970() { // Ticket #5073 + void trac_5970() { // Ticket #5970 checkUninitVar("void DES_ede3_ofb64_encrypt() {\n" " DES_cblock d; \n" " char *dp; \n" " dp=(char *)d; \n" " init(dp); \n" "}", "test.c"); - ASSERT_EQUALS("", errout.str()); + TODO_ASSERT_EQUALS("", "[test.c:4]: (error) Uninitialized variable: d\n", errout.str()); }