fix #2720 (false positive: syntax error with c++0x code)

This commit is contained in:
Robert Reif 2011-04-14 19:50:17 -04:00
parent 58dbbb0cab
commit 3159df958d
2 changed files with 9 additions and 1 deletions

View File

@ -7871,7 +7871,7 @@ void Tokenizer::simplifyEnum()
typeTokenStart = tok->tokAt(offset);
typeTokenEnd = typeTokenStart;
while (Token::Match(typeTokenEnd->next(), "signed|unsigned|char|short|int|long"))
while (Token::Match(typeTokenEnd->next(), "signed|unsigned|char|short|int|long|const"))
typeTokenEnd = typeTokenEnd->next();
if (!Token::Match(typeTokenEnd->next(), "{|;"))

View File

@ -300,6 +300,7 @@ private:
TEST_CASE(enum18); // #2466 (array with same name as enum constant)
TEST_CASE(enum19); // ticket #2536
TEST_CASE(enum20); // ticket #2600
TEST_CASE(enum21); // ticket #2720
// remove "std::" on some standard functions
TEST_CASE(removestd);
@ -6382,6 +6383,13 @@ private:
ASSERT_EQUALS(";", tok(code, false));
}
void enum21() // ticket #2720 syntax error
{
const char code[] = "enum E2 : signed const short { };\n";
ASSERT_EQUALS(";", tok(code, false));
ASSERT_EQUALS("", errout.str());
}
void removestd()
{
ASSERT_EQUALS("; strcpy ( a , b ) ;", tok("; std::strcpy(a,b);"));