From 2d00cabee1b85bbf1695e68c19ba1ed7bf849968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 9 Nov 2011 18:49:17 +0100 Subject: [PATCH] Fixed #3279 (Token::Match called with varid 0) --- lib/tokenize.cpp | 3 +++ test/testtokenize.cpp | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index fdb244d0f..2697bc887 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3483,6 +3483,9 @@ void Tokenizer::setVarId() } while (again); } + if (Token::Match(tok, "%str%")) + continue; + // Determine name of declared variable.. std::string varname; Token *tok2 = tok ? tok->next() : 0; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 0e3f530a2..e42794bcb 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -188,6 +188,7 @@ private: TEST_CASE(varid37); // ticket #3092 (varid for 'Bar bar(*this);') TEST_CASE(varid38); // ticket #3272 (varid for 'FOO class C;') TEST_CASE(varid39); // ticket #3279 (varid for 'FOO::BAR const') + TEST_CASE(varid40); // ticket #3279 TEST_CASE(varidFunctionCall1); TEST_CASE(varidFunctionCall2); TEST_CASE(varidFunctionCall3); @@ -2999,6 +3000,13 @@ private: } } + void varid40() { + const std::string code("extern \"C\" int (*a())();"); + ASSERT_EQUALS("\n\n##file 0\n" + "1: extern \"C\" int ( * a ( ) ) ( ) ;\n", + tokenizeDebugListing(code)); + } + void varidFunctionCall1() { const std::string code("void f() {\n" " int x;\n"