Fixed #2586 (segmentation fault of cppcheck (template<>))

This commit is contained in:
Daniel Marjamäki 2011-02-17 21:15:17 +01:00
parent 96c3ab87f2
commit cf2a04377e
2 changed files with 14 additions and 2 deletions

View File

@ -5528,6 +5528,9 @@ void Tokenizer::simplifyVarDecl()
}
}
if (!tok2)
break;
if (Token::Match(tok2, ":: %type%"))
{
typelen += 2;

View File

@ -234,7 +234,8 @@ private:
TEST_CASE(vardecl_union);
TEST_CASE(volatile_variables);
TEST_CASE(syntax_error);
TEST_CASE(syntax_error_templates);
TEST_CASE(syntax_error_templates_1);
TEST_CASE(syntax_error_templates_2);
TEST_CASE(removeKeywords);
@ -4165,7 +4166,7 @@ private:
}
void syntax_error_templates()
void syntax_error_templates_1()
{
// ok code.. using ">" for a comparison
{
@ -4235,6 +4236,14 @@ private:
}
}
void syntax_error_templates_2()
{
std::istringstream istr("template<>\n");
Settings settings;
Tokenizer tokenizer(&settings, this);
tokenizer.tokenize(istr, "test.cpp"); // shouldn't segfault
}
void removeKeywords()
{
const char code[] = "if (__builtin_expect(!!(x), 1));";