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