fixed #4195 segmentation fault of cppcheck (invalid code); Added a testcase
This commit is contained in:
parent
07d2935e81
commit
3f89e38275
|
@ -7282,6 +7282,9 @@ void Tokenizer::simplifyEnum()
|
|||
bool simplify = false;
|
||||
bool hasClass = false;
|
||||
EnumValue *ev = NULL;
|
||||
|
||||
if (!tok1)
|
||||
return;
|
||||
for (Token *tok2 = tok1->next(); tok2; tok2 = tok2->next()) {
|
||||
if (tok2->str() == "}") {
|
||||
--level;
|
||||
|
|
|
@ -56,6 +56,7 @@ private:
|
|||
TEST_CASE(tokenize21); // tokenize 0x0E-7
|
||||
TEST_CASE(tokenize22); // special marker $ from preprocessor
|
||||
TEST_CASE(tokenize23); // tokenize "return - __LINE__;"
|
||||
TEST_CASE(tokenize24); // #4195 (segmentation fault)
|
||||
|
||||
// don't freak out when the syntax is wrong
|
||||
TEST_CASE(wrong_syntax1);
|
||||
|
@ -641,6 +642,11 @@ private:
|
|||
ASSERT_EQUALS("return -1 ;", tokenizeAndStringify("return - __LINE__;"));
|
||||
}
|
||||
|
||||
// #4195 - segfault for "enum { int f ( ) { return = } r = f ( ) ; }"
|
||||
void tokenize24() {
|
||||
tokenizeAndStringify("enum { int f ( ) { return = } r = f ( ) ; }");
|
||||
}
|
||||
|
||||
void wrong_syntax1() {
|
||||
{
|
||||
const std::string code("TR(kvmpio, PROTO(int rw), ARGS(rw), TP_(aa->rw;))");
|
||||
|
|
Loading…
Reference in New Issue