From fac9f66cc076b468669e30f8adc3770df4e9c3e7 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Tue, 22 Jun 2010 17:07:41 +0200 Subject: [PATCH] Fixed #1810 (False positive: Variable 'separator' is assigned a value that is never used) --- lib/tokenize.cpp | 1 + test/testtokenize.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 6ddc47e52..fd4ab59c9 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2822,6 +2822,7 @@ void Tokenizer::setVarId() if (Token::Match(tok2->next(), "%num%") || Token::Match(tok2->next(), "%bool%") || tok2->next()->str()[0] == '"' || + tok2->next()->str()[0] == '\'' || tok2->next()->varId() != 0) { // This is not a function diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index b87b6000c..f3f83dd0c 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -134,6 +134,7 @@ private: TEST_CASE(varid14); TEST_CASE(varid15); TEST_CASE(varid16); + TEST_CASE(varid17); // ticket #1810 TEST_CASE(varidStl); TEST_CASE(varid_delete); TEST_CASE(varid_functions); @@ -1869,6 +1870,24 @@ private: ASSERT_EQUALS(expected, tokenizeDebugListing(code)); } + void varid17() // ticket #1810 + { + const std::string code("char foo()\n" + "{\n" + " char c('c');\n" + " return c;\n" + "}\n"); + + const std::string expected("\n\n##file 0\n" + "1: char foo ( )\n" + "2: {\n" + "3: char c@1 ( 'c' ) ;\n" + "4: return c@1 ;\n" + "5: }\n"); + + ASSERT_EQUALS(expected, tokenizeDebugListing(code)); + } + void varidStl() {