Tokenizer::simplifyVarDecl: Fixed crash when checking garbage code.

This commit is contained in:
Martin Ettl 2014-01-01 19:15:32 +01:00
parent 0dccd3a632
commit 5a5277f2fa
2 changed files with 4 additions and 3 deletions

View File

@ -5465,8 +5465,8 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, Token * tokEnd, bool only_k_r_
}
break;
}
tok2 = tok2->next();
if (tok2)
tok2 = tok2->next();
}
}
finishedwithkr = (only_k_r_fpar && tok2 && tok2->strAt(1) == "{");

View File

@ -996,7 +996,8 @@ private:
}
void garbageCode7() {
tokenizeAndStringify(" 1 (int j) { return return (c) * sizeof } y[1];", /*simplify=*/true);
tokenizeAndStringify("1 (int j) { return return (c) * sizeof } y[1];", /*simplify=*/true);
tokenizeAndStringify("foo(Args&&...) fn void = { } auto template<typename... bar(Args&&...)", /*simplify=*/true);
}
void simplifyFileAndLineMacro() { // tokenize 'return - __LINE__' correctly