Commit 1af05166 authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Removed Q_DECLARE_FLAGS parsing, leaving it to the CPP to expand it.

parent bd1b9e6c
......@@ -540,20 +540,6 @@ bool CheckUndefinedSymbols::visit(ObjCPropertyDeclarationAST *ast)
return false;
}
bool CheckUndefinedSymbols::visit(QtDeclareFlagsDeclarationAST *ast)
{
// ### check flags name too?
if (ast->enum_name && ast->enum_name->name) {
const Identifier *enumId = ast->enum_name->name->identifier();
if (!isType(enumId)) // ### we're only checking if the enum name is known as a type name, not as an *enum*.
translationUnit()->warning(ast->enum_name->firstToken(),
"unknown enum '%s'",
enumId->chars());
}
return false;
}
bool CheckUndefinedSymbols::visit(QtEnumDeclarationAST *ast)
{
for (NameListAST *iter = ast->enumerator_list; iter; iter = iter->next) {
......
......@@ -98,7 +98,6 @@ protected:
virtual bool visit(ObjCProtocolRefsAST *ast);
virtual bool visit(ObjCPropertyDeclarationAST *ast);
virtual bool visit(QtDeclareFlagsDeclarationAST *ast);
virtual bool visit(QtEnumDeclarationAST *ast);
virtual bool visit(QtFlagsDeclarationAST *ast);
virtual bool visit(QtPropertyDeclarationAST *ast);
......
......@@ -766,8 +766,10 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source,
expandBuiltinMacro(identifierToken, spell);
else {
if (spell != "Q_PROPERTY" && spell != "Q_INVOKABLE" && spell != "Q_ENUMS"
&& spell != "Q_FLAGS" && spell != "Q_DECLARE_FLAGS") {
if (spell != "Q_PROPERTY"
&& spell != "Q_INVOKABLE"
&& spell != "Q_ENUMS"
&& spell != "Q_FLAGS") {
// ### FIXME: shouldn't this be T_Q_PROPERTY & friends?
......
......@@ -235,27 +235,6 @@ unsigned QtFlagsDeclarationAST::lastToken() const
return flags_specifier_token + 1;
}
unsigned QtDeclareFlagsDeclarationAST::firstToken() const
{
return declareflags_specifier_token;
}
unsigned QtDeclareFlagsDeclarationAST::lastToken() const
{
if (rparen_token)
return rparen_token + 1;
else if (flags_name)
return flags_name->lastToken();
else if (comma_token)
return comma_token + 1;
else if (enum_name)
return enum_name->lastToken();
else if (lparen_token)
return lparen_token + 1;
else
return declareflags_specifier_token + 1;
}
unsigned ArrayAccessAST::firstToken() const
{
return lbracket_token;
......
......@@ -256,7 +256,6 @@ public:
virtual PostfixDeclaratorAST *asPostfixDeclarator() { return 0; }
virtual PostfixExpressionAST *asPostfixExpression() { return 0; }
virtual PtrOperatorAST *asPtrOperator() { return 0; }
virtual QtDeclareFlagsDeclarationAST *asQtDeclareFlagsDeclaration() { return 0; }
virtual QtEnumDeclarationAST *asQtEnumDeclaration() { return 0; }
virtual QtFlagsDeclarationAST *asQtFlagsDeclaration() { return 0; }
virtual QtMemberDeclarationAST *asQtMemberDeclaration() { return 0; }
......@@ -683,29 +682,6 @@ protected:
virtual bool match0(AST *, ASTMatcher *);
};
class CPLUSPLUS_EXPORT QtDeclareFlagsDeclarationAST: public DeclarationAST
{
public:
unsigned declareflags_specifier_token;
unsigned lparen_token;
SimpleNameAST *flags_name;
unsigned comma_token;
SimpleNameAST *enum_name;
unsigned rparen_token;
public:
virtual QtDeclareFlagsDeclarationAST *asQtDeclareFlagsDeclaration() { return this; }
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual QtDeclareFlagsDeclarationAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
virtual bool match0(AST *, ASTMatcher *);
};
class CPLUSPLUS_EXPORT AsmDefinitionAST: public DeclarationAST
{
public:
......
......@@ -200,20 +200,6 @@ QtFlagsDeclarationAST *QtFlagsDeclarationAST::clone(MemoryPool *pool) const
return ast;
}
QtDeclareFlagsDeclarationAST *QtDeclareFlagsDeclarationAST::clone(MemoryPool *pool) const
{
QtDeclareFlagsDeclarationAST *ast = new (pool) QtDeclareFlagsDeclarationAST;
ast->declareflags_specifier_token = declareflags_specifier_token;
ast->lparen_token = lparen_token;
if (flags_name)
ast->flags_name = flags_name->clone(pool);
ast->comma_token = comma_token;
if (enum_name)
ast->enum_name = enum_name->clone(pool);
ast->rparen_token = rparen_token;
return ast;
}
AsmDefinitionAST *AsmDefinitionAST::clone(MemoryPool *pool) const
{
AsmDefinitionAST *ast = new (pool) AsmDefinitionAST;
......
......@@ -153,14 +153,6 @@ bool QtFlagsDeclarationAST::match0(AST *pattern, ASTMatcher *matcher)
return false;
}
bool QtDeclareFlagsDeclarationAST::match0(AST *pattern, ASTMatcher *matcher)
{
if (QtDeclareFlagsDeclarationAST *_other = pattern->asQtDeclareFlagsDeclaration())
return matcher->match(this, _other);
return false;
}
bool AsmDefinitionAST::match0(AST *pattern, ASTMatcher *matcher)
{
if (AsmDefinitionAST *_other = pattern->asAsmDefinition())
......
......@@ -307,32 +307,6 @@ bool ASTMatcher::match(QtFlagsDeclarationAST *node, QtFlagsDeclarationAST *patte
return true;
}
bool ASTMatcher::match(QtDeclareFlagsDeclarationAST *node, QtDeclareFlagsDeclarationAST *pattern)
{
(void) node;
(void) pattern;
pattern->declareflags_specifier_token = node->declareflags_specifier_token;
pattern->lparen_token = node->lparen_token;
if (! pattern->flags_name)
pattern->flags_name = node->flags_name;
else if (! AST::match(node->flags_name, pattern->flags_name, this))
return false;
pattern->comma_token = node->comma_token;
if (! pattern->enum_name)
pattern->enum_name = node->enum_name;
else if (! AST::match(node->enum_name, pattern->enum_name, this))
return false;
pattern->rparen_token = node->rparen_token;
return true;
}
bool ASTMatcher::match(AsmDefinitionAST *node, AsmDefinitionAST *pattern)
{
(void) node;
......
......@@ -43,7 +43,6 @@ public:
virtual bool match(QtPropertyDeclarationAST *node, QtPropertyDeclarationAST *pattern);
virtual bool match(QtEnumDeclarationAST *node, QtEnumDeclarationAST *pattern);
virtual bool match(QtFlagsDeclarationAST *node, QtFlagsDeclarationAST *pattern);
virtual bool match(QtDeclareFlagsDeclarationAST *node, QtDeclareFlagsDeclarationAST *pattern);
virtual bool match(ArrayAccessAST *node, ArrayAccessAST *pattern);
virtual bool match(ArrayDeclaratorAST *node, ArrayDeclaratorAST *pattern);
virtual bool match(ArrayInitializerAST *node, ArrayInitializerAST *pattern);
......
......@@ -157,15 +157,6 @@ void QtFlagsDeclarationAST::accept0(ASTVisitor *visitor)
visitor->endVisit(this);
}
void QtDeclareFlagsDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
accept(flags_name, visitor);
accept(enum_name, visitor);
}
visitor->endVisit(this);
}
void AsmDefinitionAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
......
......@@ -106,7 +106,6 @@ public:
virtual bool visit(QtPropertyDeclarationAST *) { return true; }
virtual bool visit(QtEnumDeclarationAST *) { return true; }
virtual bool visit(QtFlagsDeclarationAST *) { return true; }
virtual bool visit(QtDeclareFlagsDeclarationAST *) { return true; }
virtual bool visit(ArrayAccessAST *) { return true; }
virtual bool visit(ArrayDeclaratorAST *) { return true; }
virtual bool visit(ArrayInitializerAST *) { return true; }
......@@ -241,7 +240,6 @@ public:
virtual void endVisit(QtPropertyDeclarationAST *) { }
virtual void endVisit(QtEnumDeclarationAST *) { }
virtual void endVisit(QtFlagsDeclarationAST *) { }
virtual void endVisit(QtDeclareFlagsDeclarationAST *) { }
virtual void endVisit(ArrayAccessAST *) { }
virtual void endVisit(ArrayDeclaratorAST *) { }
virtual void endVisit(ArrayInitializerAST *) { }
......
......@@ -163,7 +163,6 @@ class PostfixAST;
class PostfixDeclaratorAST;
class PostfixExpressionAST;
class PtrOperatorAST;
class QtDeclareFlagsDeclarationAST;
class QtEnumDeclarationAST;
class QtFlagsDeclarationAST;
class QtMemberDeclarationAST;
......
......@@ -802,15 +802,6 @@ bool CheckDeclaration::visit(ObjCPropertyDeclarationAST *ast)
return false;
}
bool CheckDeclaration::visit(QtDeclareFlagsDeclarationAST *ast)
{
if (ast->flags_name)
semantic()->check(ast->flags_name, _scope);
if (ast->enum_name)
semantic()->check(ast->enum_name, _scope);
return false;
}
bool CheckDeclaration::visit(QtEnumDeclarationAST *ast)
{
for (NameListAST *iter = ast->enumerator_list; iter; iter = iter->next)
......
......@@ -80,7 +80,6 @@ protected:
virtual bool visit(QtPropertyDeclarationAST *ast);
virtual bool visit(QtEnumDeclarationAST *ast);
virtual bool visit(QtFlagsDeclarationAST *ast);
virtual bool visit(QtDeclareFlagsDeclarationAST *ast);
virtual bool visit(AsmDefinitionAST *ast);
virtual bool visit(ExceptionDeclarationAST *ast);
virtual bool visit(FunctionDefinitionAST *ast);
......
......@@ -1283,41 +1283,6 @@ static inline int classify13(const char *s, bool) {
return T_IDENTIFIER;
}
static inline int classify15(const char *s, bool) {
if (s[0] == 'Q') {
if (s[1] == '_') {
if (s[2] == 'D') {
if (s[3] == 'E') {
if (s[4] == 'C') {
if (s[5] == 'L') {
if (s[6] == 'A') {
if (s[7] == 'R') {
if (s[8] == 'E') {
if (s[9] == '_') {
if (s[10] == 'F') {
if (s[11] == 'L') {
if (s[12] == 'A') {
if (s[13] == 'G') {
if (s[14] == 'S') {
return T_Q_DECLARE_FLAGS;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return T_IDENTIFIER;
}
static inline int classify16(const char *s, bool) {
if (s[0] == 'r') {
if (s[1] == 'e') {
......@@ -1369,7 +1334,6 @@ int Lexer::classify(const char *s, int n, bool q) {
case 11: return classify11(s, q);
case 12: return classify12(s, q);
case 13: return classify13(s, q);
case 15: return classify15(s, q);
case 16: return classify16(s, q);
default: return T_IDENTIFIER;
} // switch
......
......@@ -1920,29 +1920,6 @@ bool Parser::parseQtFlags(DeclarationAST *&node)
return true;
}
// q-declare-flags ::= 'Q_DECLARE_FLAGS' '(' q-flags-name ',' q-enum-name ')'
// q-flags-name ::= T_IDENTIFIER
// q-enum-name ::= T_IDENTIFIER
bool Parser::parseQtDeclareFlags(DeclarationAST *&node)
{
/*Q_DECLARE_FLAGS(flag enum)*/
DEBUG_THIS_RULE();
if (LA() != T_Q_DECLARE_FLAGS)
return false;
QtDeclareFlagsDeclarationAST *ast = new (_pool) QtDeclareFlagsDeclarationAST;
ast->declareflags_specifier_token = consumeToken();
match(T_LPAREN, &ast->lparen_token);
ast->flags_name = new (_pool) SimpleNameAST;
match(T_IDENTIFIER, &ast->flags_name->identifier_token);
match(T_COMMA, &ast->comma_token);
ast->enum_name = new (_pool) SimpleNameAST;
match(T_IDENTIFIER, &ast->enum_name->identifier_token);
match(T_RPAREN, &ast->rparen_token);
node = ast;
return true;
}
bool Parser::parseMemberSpecification(DeclarationAST *&node)
{
DEBUG_THIS_RULE();
......@@ -1972,9 +1949,6 @@ bool Parser::parseMemberSpecification(DeclarationAST *&node)
case T_Q_FLAGS:
return parseQtFlags(node);
case T_Q_DECLARE_FLAGS:
return parseQtDeclareFlags(node);
default:
return parseSimpleDeclaration(node, /*acceptStructDeclarator=*/true);
} // switch
......
......@@ -81,7 +81,6 @@ public:
bool parseQtPropertyDeclaration(DeclarationAST *&node);
bool parseQtEnumDeclaration(DeclarationAST *&node);
bool parseQtFlags(DeclarationAST *&node);
bool parseQtDeclareFlags(DeclarationAST *&node);
bool parseAdditiveExpression(ExpressionAST *&node);
bool parseAndExpression(ExpressionAST *&node);
bool parseAsmDefinition(DeclarationAST *&node);
......
......@@ -93,7 +93,7 @@ static const char *token_names[] = {
("SIGNAL"), ("SLOT"), ("Q_SIGNAL"), ("Q_SLOT"), ("signals"), ("slots"),
("Q_FOREACH"), ("Q_D"), ("Q_Q"),
("Q_INVOKABLE"), ("Q_PROPERTY"), ("Q_ENUMS"), ("Q_FLAGS"), ("Q_DECLARE_FLAGS")
("Q_INVOKABLE"), ("Q_PROPERTY"), ("Q_ENUMS"), ("Q_FLAGS")
};
Token::Token() :
......
......@@ -242,8 +242,7 @@ enum Kind {
T_Q_PROPERTY,
T_Q_ENUMS,
T_Q_FLAGS,
T_Q_DECLARE_FLAGS,
T_LAST_KEYWORD = T_Q_DECLARE_FLAGS,
T_LAST_KEYWORD = T_Q_FLAGS,
// aliases
T_OR = T_PIPE_PIPE,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment