Fixed #3449 (segmentation fault of cppcheck)
This commit is contained in:
parent
0e1fb5f75b
commit
8a6b1dc1c9
|
@ -2834,6 +2834,10 @@ static void removeTemplates(Token *tok)
|
|||
tok->deleteThis();
|
||||
goback = true;
|
||||
break;
|
||||
} else if (tok2->str() == "}") { // garbage code! (#3449)
|
||||
Token::eraseTokens(tok,tok2);
|
||||
tok->deleteThis();
|
||||
break;
|
||||
}
|
||||
// don't remove constructor
|
||||
if (tok2->str() == "explicit") {
|
||||
|
|
|
@ -119,6 +119,7 @@ private:
|
|||
TEST_CASE(template26); // #2721 - passing 'char[2]' as template parameter
|
||||
TEST_CASE(template27); // #3350 - removing unused template in macro call
|
||||
TEST_CASE(template28);
|
||||
TEST_CASE(template29); // #3449
|
||||
TEST_CASE(template_unhandled);
|
||||
TEST_CASE(template_default_parameter);
|
||||
TEST_CASE(template_default_type);
|
||||
|
@ -2086,6 +2087,14 @@ private:
|
|||
ASSERT_EQUALS("Fred<int,Fred<int,int>> x ; class Fred<int,int> { } class Fred<int,Fred<int,int>> { }", sizeof_(code));
|
||||
}
|
||||
|
||||
void template29() {
|
||||
// #3449 - garbage code (don't segfault)
|
||||
const char code[] = "template<typename T> struct A;\n"
|
||||
"struct B { template<typename T> struct C };\n"
|
||||
"{};";
|
||||
ASSERT_EQUALS("struct B { } ; { } ;", sizeof_(code));
|
||||
}
|
||||
|
||||
void template_unhandled() {
|
||||
// An unhandled template usage should be simplified..
|
||||
ASSERT_EQUALS("x<int> ( ) ;", sizeof_("x<int>();"));
|
||||
|
|
Loading…
Reference in New Issue