Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
e3baca2e
Commit
e3baca2e
authored
Mar 17, 2009
by
Roberto Raggi
Browse files
Prefer C++ Initializer when parsing init-declarators.
parent
f9a3df18
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/shared/cplusplus/Parser.cpp
View file @
e3baca2e
...
...
@@ -977,7 +977,7 @@ bool Parser::parseCoreDeclarator(DeclaratorAST *&node)
return
false
;
}
bool
Parser
::
parseDeclarator
(
DeclaratorAST
*&
node
)
bool
Parser
::
parseDeclarator
(
DeclaratorAST
*&
node
,
bool
stopAtCppInitializer
)
{
if
(
!
parseCoreDeclarator
(
node
))
return
false
;
...
...
@@ -988,6 +988,25 @@ bool Parser::parseDeclarator(DeclaratorAST *&node)
unsigned
startOfPostDeclarator
=
cursor
();
if
(
LA
()
==
T_LPAREN
)
{
if
(
stopAtCppInitializer
)
{
unsigned
lparen_token
=
cursor
();
ExpressionAST
*
initializer
=
0
;
bool
blocked
=
blockErrors
(
true
);
if
(
parseInitializer
(
initializer
))
{
if
(
NestedExpressionAST
*
expr
=
initializer
->
asNestedExpression
())
{
if
(
expr
->
expression
&&
expr
->
rparen_token
&&
(
LA
()
==
T_COMMA
||
LA
()
==
T_SEMICOLON
))
{
rewind
(
lparen_token
);
blockErrors
(
blocked
);
return
true
;
}
}
}
blockErrors
(
blocked
);
rewind
(
lparen_token
);
}
FunctionDeclaratorAST
*
ast
=
new
(
_pool
)
FunctionDeclaratorAST
;
ast
->
lparen_token
=
consumeToken
();
parseParameterDeclarationClause
(
ast
->
parameters
);
...
...
@@ -1494,7 +1513,7 @@ bool Parser::parseInitDeclarator(DeclaratorAST *&node,
if
(
acceptStructDeclarator
&&
LA
()
==
T_COLON
)
{
// anonymous bit-field declaration.
// ### TODO create the AST
}
else
if
(
!
parseDeclarator
(
node
))
{
}
else
if
(
!
parseDeclarator
(
node
,
/*stopAtCppInitializer = */
!
acceptStructDeclarator
))
{
return
false
;
}
...
...
src/shared/cplusplus/Parser.h
View file @
e3baca2e
...
...
@@ -107,7 +107,7 @@ public:
bool
parseSimpleDeclaration
(
DeclarationAST
*&
node
,
bool
acceptStructDeclarator
=
false
);
bool
parseDeclarationStatement
(
StatementAST
*&
node
);
bool
parseCoreDeclarator
(
DeclaratorAST
*&
node
);
bool
parseDeclarator
(
DeclaratorAST
*&
node
);
bool
parseDeclarator
(
DeclaratorAST
*&
node
,
bool
stopAtCppInitializer
=
false
);
bool
parseDeleteExpression
(
ExpressionAST
*&
node
);
bool
parseDoStatement
(
StatementAST
*&
node
);
bool
parseElaboratedTypeSpecifier
(
SpecifierAST
*&
node
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment