Fixed #3912 (Analysis failed)

This commit is contained in:
Thomas Sondergaard 2012-07-03 06:34:14 +02:00 committed by Daniel Marjamäki
parent 2de6ea4627
commit f72ddbb2e9
2 changed files with 13 additions and 1 deletions

View File

@ -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

View File

@ -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<void (shared_ptr<MyClass>)> 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