Fixed #1988 (segmentation fault of cppcheck with wrong syntax of -std=c++0x)

This commit is contained in:
Robert Reif 2010-08-30 07:25:17 +02:00 committed by Daniel Marjamäki
parent a862e982ff
commit 0d530711f6
2 changed files with 14 additions and 0 deletions

View File

@ -6646,6 +6646,12 @@ void Tokenizer::simplifyEnum()
typeTokenEnd = typeTokenStart;
while (Token::Match(typeTokenEnd->next(), "signed|unsigned|char|short|int|long"))
typeTokenEnd = typeTokenEnd->next();
if (!Token::Match(typeTokenEnd->next(), "{|;"))
{
syntaxError(typeTokenEnd->next());
return;
}
}
if (tok->tokAt(1)->str() == "{")

View File

@ -250,6 +250,7 @@ private:
TEST_CASE(enum13);
TEST_CASE(enum14);
TEST_CASE(enum15);
TEST_CASE(enum16); // ticket #1988
// remove "std::" on some standard functions
TEST_CASE(removestd);
@ -5513,6 +5514,13 @@ private:
}
}
void enum16() // ticket #1988
{
const char code[] = "enum D : auto * { FF = 0 };";
checkSimplifyEnum(code);
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
}
void removestd()
{
ASSERT_EQUALS("; strcpy ( a , b ) ;", tok("; std::strcpy(a,b);"));