From 38f90dae09efaea20572a955c66a89ac5b2956b3 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Fri, 25 Jun 2010 07:52:12 +0200 Subject: [PATCH] Fixed #1813 (false negative: Member variable not assigned a value in operator=) --- lib/tokenize.cpp | 2 +- test/testunusedvar.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index fd4ab59c9..2ecb7fdc4 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4312,7 +4312,7 @@ bool Tokenizer::simplifyQuestionMark() { if (endTok->str() == ";") { - Token::eraseTokens(semicolon->previous(), endTok->next()); + Token::eraseTokens(semicolon->previous(), endTok); ret = true; break; } diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index cdfe00c3f..0e12833bf 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -67,6 +67,7 @@ private: TEST_CASE(localvar19); // ticket #1776 TEST_CASE(localvar20); // ticket #1799 TEST_CASE(localvar21); // ticket #1807 + TEST_CASE(localvar22); // ticket #1811 TEST_CASE(localvaralias1); TEST_CASE(localvaralias2); // ticket #1637 TEST_CASE(localvaralias3); // ticket #1639 @@ -1190,6 +1191,18 @@ private: ASSERT_EQUALS("", errout.str()); } + void localvar22() // ticket #1811 + { + functionVariableUsage("int foo(int u, int v)\n" + "{\n" + " int h, i;\n" + " h = 0 ? u : v;\n" + " i = 1 ? u : v;\n" + " return h + i;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + void localvaralias1() { functionVariableUsage("void foo()\n"