From f72ddbb2e95f3297c50dddd7ba662a6a3906c32e Mon Sep 17 00:00:00 2001 From: Thomas Sondergaard Date: Tue, 3 Jul 2012 06:34:14 +0200 Subject: [PATCH] Fixed #3912 (Analysis failed) --- lib/tokenize.cpp | 2 +- test/testtokenize.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7798c454f..7346221ef 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2955,7 +2955,7 @@ void Tokenizer::createLinks2() } else if (token->str() == ">" || token->str() == ">>") { if (links.empty()) // < and > don't match. continue; - if (token->next() && !token->next()->isName() && !Token::Match(token->next(), ">|&|*|::|,|(")) + if (token->next() && !token->next()->isName() && !Token::Match(token->next(), ">|&|*|::|,|(|)")) continue; // Check type of open link diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index c85cec9c5..ffcfb782d 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -324,6 +324,7 @@ private: TEST_CASE(vardecl_template_2); TEST_CASE(vardecl_union); TEST_CASE(vardecl_par); // #2743 - set links if variable type contains parentheses + TEST_CASE(vardecl_par2) // #3912 - set correct links TEST_CASE(volatile_variables); TEST_CASE(syntax_error); TEST_CASE(syntax_error_templates_1); @@ -4738,6 +4739,17 @@ private: ASSERT_EQUALS(true, tokenizer.validate()); } + void vardecl_par2() { + // ticket #3912 - set correct links + const char code[] = "function)> v;"; + + Settings settings; + Tokenizer tokenizer(&settings, this); + std::istringstream istr(code); + tokenizer.tokenize(istr, "test.cpp", "", false); + ASSERT_EQUALS(true, tokenizer.validate()); + } + void vardec_static() { { // don't simplify declarations of static variables