Fixed #3350 (Analysis failed)

This commit is contained in:
Daniel Marjamäki 2011-12-03 15:14:53 +01:00
parent c90558f730
commit 50dfdf7c2e
2 changed files with 13 additions and 1 deletions

View File

@ -2671,11 +2671,16 @@ static void removeTemplates(Token *tok)
if (!tok2)
break;
}
if (tok2->str() == ";") {
else if (tok2->str() == ";") {
Token::eraseTokens(tok, tok2->next());
tok->str(";");
break;
}
else if (Token::Match(tok2, ">|>> class %var% [,)]")) {
Token::eraseTokens(tok,tok2->next());
tok->deleteThis();
break;
}
}
}
}

View File

@ -117,6 +117,7 @@ private:
TEST_CASE(template24); // #2648 - using sizeof in template parameter
TEST_CASE(template25); // #2648 - another test for sizeof template parameter
TEST_CASE(template26); // #2721 - passing 'char[2]' as template parameter
TEST_CASE(template27); // #3350 - removing unused template in macro call
TEST_CASE(template_unhandled);
TEST_CASE(template_default_parameter);
TEST_CASE(template_default_type);
@ -2095,6 +2096,12 @@ private:
ASSERT_EQUALS("; C<2> a ; class C<2> : public A < char [ 2 ] > { }", sizeof_(code));
}
void template27() {
// #3350 - template inside macro call
const char code[] = "X(template<class T> class Fred);";
ASSERT_EQUALS("X ( class Fred ) ;", sizeof_(code));
}
void template_unhandled() {
// An unhandled template usage should be simplified..
ASSERT_EQUALS("; x<int> ( ) ;", sizeof_(";x<int>();"));