From f1ebd99dc28eaf67d03914852658f16f2eb8d04d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 15 Sep 2012 11:55:08 +0200 Subject: [PATCH] Fixed #3507 (false positive: comma-separated statements before return in methods) --- lib/tokenize.cpp | 3 +++ test/testtokenize.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 9c0b2d4ce..603af52c8 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5793,6 +5793,9 @@ void Tokenizer::simplifyInitVar() if (!tok->isName() || (tok->previous() && !Token::Match(tok->previous(), "[;{}]"))) continue; + if (tok->str() == "return") + continue; + if (Token::Match(tok, "class|struct|union| %type% *| %var% ( &| %any% ) ;") || Token::Match(tok, "%type% *| %var% ( %type% (")) { tok = initVar(tok); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 675aa99d4..b8a26de5a 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6110,6 +6110,12 @@ private: ASSERT_EQUALS("int x ; x = f ( ) ;", tokenizeAndStringify(code, false)); ASSERT_EQUALS("", errout.str()); } + + { + const char code[] = "return doSomething(X), 0;"; + ASSERT_EQUALS("return doSomething ( X ) , 0 ;", tokenizeAndStringify(code, false)); + ASSERT_EQUALS("", errout.str()); + } } void bitfields1() {