Fixed #4211 (Tokenizer::simplifyVarDecl: Improved handling of >> in templates)

This commit is contained in:
Daniel Marjamäki 2012-09-17 19:45:42 +02:00
parent 3ff792560f
commit 1f7d9ca22c
2 changed files with 12 additions and 1 deletions

View File

@ -5042,11 +5042,17 @@ void Tokenizer::simplifyVarDecl(bool only_k_r_fpar)
if (tok3->str() == "<" && !parens) {
++indentlevel;
} else if (tok3->str() == ">" && !parens) {
if (!indentlevel) {
if (indentlevel == 0) {
tok2 = tok3->next();
break;
}
--indentlevel;
} else if (tok3->str() == ">>" && !parens) {
if (indentlevel <= 1U) {
tok2 = tok3->next();
break;
}
indentlevel -= 2;
} else if (tok3->str() == "(") {
++parens;
} else if (tok3->str() == ")") {

View File

@ -325,6 +325,7 @@ private:
TEST_CASE(vardecl19);
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(vardecl_stl_1);
TEST_CASE(vardecl_stl_2);
TEST_CASE(vardecl_template_1);
@ -5107,6 +5108,10 @@ private:
, tokenizeAndStringify(code));
}
void vardecl22() { // #4211 - segmentation fault
tokenizeAndStringify("A<B<C<int>> >* p = 0;");
}
void volatile_variables() {
const char code[] = "volatile int a=0;\n"
"volatile int b=0;\n"