Fixed #4276 (segmentation fault of cppcheck (invalid code))

This commit is contained in:
Edoardo Prezioso 2012-10-20 21:39:29 +02:00
parent be52a1404b
commit f0f216390e
2 changed files with 9 additions and 0 deletions

View File

@ -4995,6 +4995,10 @@ void Tokenizer::simplifyVarDecl(bool only_k_r_fpar)
//skip combinations of templates and namespaces
while (Token::Match(tok2, "%type% <") || Token::Match(tok2, "%type% ::")) {
if (tok2->next()->str() == "<" && !TemplateSimplifier::templateParameters(tok2->next())) {
tok2 = NULL;
break;
}
typelen += 2;
tok2 = tok2->tokAt(2);
if (tok2 && tok2->previous()->str() == "::")

View File

@ -334,6 +334,7 @@ private:
TEST_CASE(vardecl20); // #3700 - register const int H = 0;
TEST_CASE(vardecl21); // #4042 - a::b const *p = 0;
TEST_CASE(vardecl22); // #4211 - segmentation fault
TEST_CASE(vardecl23); // #4276 - segmentation fault
TEST_CASE(vardecl_stl_1);
TEST_CASE(vardecl_stl_2);
TEST_CASE(vardecl_template_1);
@ -5252,6 +5253,10 @@ private:
tokenizeAndStringify("A<B<C<int>> >* p = 0;");
}
void vardecl23() { // #4276 - segmentation fault
tokenizeAndStringify("class a { protected : template < class int x = 1 ; public : int f ( ) ; }");
}
void volatile_variables() {
const char code[] = "volatile int a=0;\n"
"volatile int b=0;\n"