C++: Fix crashes with the pattern "enum class operator A"

Parser parsed the pattern as an enum declaration the name of
which is a conversion operator. Add check to disallow keywords
after enum-key (enum, enum class, enum struct).
Add tests tst_AST::enumDeclaration and
invalidEnumClassDeclaration.

Task-number: QTCREATORBUG-15341
Change-Id: Ia037f00184c1d7e5b0374f39331bb6748f8d90b1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Lassi Hämäläinen
2015-11-15 00:16:34 +02:00
committed by Nikolai Kosjar
parent c62ad6c450
commit 10e947f65f
2 changed files with 29 additions and 0 deletions

View File

@@ -1789,6 +1789,11 @@ bool Parser::parseEnumSpecifier(SpecifierListAST *&node)
if (_languageFeatures.cxx11Enabled && (LA() == T_CLASS || LA() == T_STRUCT))
ast->key_token = consumeToken();
if (tok().isKeyword()) {
error(cursor(), "expected identifier before '%s'", tok().spell());
return false;
}
parseName(ast->name);
if (_languageFeatures.cxx11Enabled && LA() == T_COLON) {