Fix #8477 (False positive caused by anonymous enum in method body) (#1154)

This commit is contained in:
IOBYTE 2018-04-08 02:00:12 -04:00 committed by Daniel Marjamäki
parent 4f9073159a
commit 90983303f0
2 changed files with 4 additions and 1 deletions

View File

@ -2223,7 +2223,7 @@ void Tokenizer::simplifyLabelsCaseDefault()
syntaxError(tok);
}
} else if (Token::Match(tok, "[;{}] %name% : !!;")) {
if (!cpp || !Token::Match(tok->next(), "class|struct")) {
if (!cpp || !Token::Match(tok->next(), "class|struct|enum")) {
tok = tok->tokAt(2);
tok->insertToken(";");
}

View File

@ -4761,6 +4761,9 @@ private:
//ticket #8345
ASSERT_EQUALS("void foo ( ) { switch ( 0 ) { case 0 : ; default : ; } }",
tokenizeAndStringify("void foo () { switch(0) case 0 : default : ; }"));
//ticket #8477
ASSERT_EQUALS("void foo ( ) { enum Anonymous0 : int { Six = 6 } ; return Six ; }",
tokenizeAndStringify("void foo () { enum : int { Six = 6 } ; return Six ; }"));
}
void simplifyPointerToStandardType() {