Fixed ticket #3571 (segmentation fault of cppcheck while scanning gcc-testsuite).
This commit is contained in:
parent
f8578a380a
commit
66e1761ffe
|
@ -5166,19 +5166,28 @@ void Tokenizer::simplifyVarDecl(bool only_k_r_fpar)
|
||||||
tok2 = tok2->tokAt(2);
|
tok2 = tok2->tokAt(2);
|
||||||
if (tok2 && tok2->previous()->str() == "::")
|
if (tok2 && tok2->previous()->str() == "::")
|
||||||
continue;
|
continue;
|
||||||
size_t indentlevel = 1;
|
unsigned int indentlevel = 0;
|
||||||
|
unsigned int parens = 0;
|
||||||
|
|
||||||
for (Token *tok3 = tok2; tok3; tok3 = tok3->next()) {
|
for (Token *tok3 = tok2; tok3; tok3 = tok3->next()) {
|
||||||
++typelen;
|
++typelen;
|
||||||
|
|
||||||
if (tok3->str() == "<") {
|
if (tok3->str() == "<" && !parens) {
|
||||||
++indentlevel;
|
++indentlevel;
|
||||||
} else if (tok3->str() == ">") {
|
} else if (tok3->str() == ">" && !parens) {
|
||||||
--indentlevel;
|
if (!indentlevel) {
|
||||||
if (indentlevel == 0) {
|
|
||||||
tok2 = tok3->next();
|
tok2 = tok3->next();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
--indentlevel;
|
||||||
|
} else if (tok3->str() == "(") {
|
||||||
|
++parens;
|
||||||
|
} else if (tok3->str() == ")") {
|
||||||
|
if (!parens) {
|
||||||
|
tok2 = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
--parens;
|
||||||
} else if (tok3->str() == ";") {
|
} else if (tok3->str() == ";") {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4426,6 +4426,8 @@ private:
|
||||||
const char code1[] = "b<(1<<24),10,24> u, v;";
|
const char code1[] = "b<(1<<24),10,24> u, v;";
|
||||||
const char res1[] = "b < ( 1 << 24 ) , 10 , 24 > u ; b < ( 1 << 24 ) , 10 , 24 > v ;";
|
const char res1[] = "b < ( 1 << 24 ) , 10 , 24 > u ; b < ( 1 << 24 ) , 10 , 24 > v ;";
|
||||||
ASSERT_EQUALS(res1, tokenizeAndStringify(code1));
|
ASSERT_EQUALS(res1, tokenizeAndStringify(code1));
|
||||||
|
// ticket #3571 (segmentation fault)
|
||||||
|
tokenizeAndStringify("template <int i = (3>4) > class X4 {};");
|
||||||
}
|
}
|
||||||
|
|
||||||
void vardecl_union() {
|
void vardecl_union() {
|
||||||
|
|
Loading…
Reference in New Issue