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
88fe5a50
Commit
88fe5a50
authored
Dec 16, 2010
by
Roberto Raggi
Browse files
Added semantic checks for stray semicolons and topldevel empty declarations.
parent
476dda1b
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppinsertqtpropertymembers.cpp
View file @
88fe5a50
...
...
@@ -70,7 +70,7 @@ QList<CppQuickFixOperation::Ptr> InsertQtPropertyMembers::match(const CppQuickFi
QString
getterName
;
QString
setterName
;
QString
signalName
;
int
generateFlags
;
int
generateFlags
=
0
;
for
(
QtPropertyDeclarationItemListAST
*
it
=
qtPropertyDeclaration
->
property_declaration_item_list
;
it
;
it
=
it
->
next
)
{
const
QString
tokenString
=
file
.
tokenAt
(
it
->
value
->
item_name_token
).
spell
();
...
...
src/shared/cplusplus/AST.cpp
View file @
88fe5a50
...
...
@@ -1107,6 +1107,8 @@ unsigned EnumSpecifierAST::firstToken() const
if
(
enumerator_list
)
if
(
unsigned
candidate
=
enumerator_list
->
firstToken
())
return
candidate
;
if
(
stray_comma_token
)
return
stray_comma_token
;
if
(
rbrace_token
)
return
rbrace_token
;
return
0
;
...
...
@@ -1117,6 +1119,8 @@ unsigned EnumSpecifierAST::lastToken() const
{
if
(
rbrace_token
)
return
rbrace_token
+
1
;
if
(
stray_comma_token
)
return
stray_comma_token
+
1
;
if
(
enumerator_list
)
if
(
unsigned
candidate
=
enumerator_list
->
lastToken
())
return
candidate
;
...
...
src/shared/cplusplus/AST.h
View file @
88fe5a50
...
...
@@ -1621,6 +1621,7 @@ public:
NameAST
*
name
;
unsigned
lbrace_token
;
EnumeratorListAST
*
enumerator_list
;
unsigned
stray_comma_token
;
unsigned
rbrace_token
;
public:
// annotations
...
...
@@ -1632,6 +1633,7 @@ public:
,
name
(
0
)
,
lbrace_token
(
0
)
,
enumerator_list
(
0
)
,
stray_comma_token
(
0
)
,
rbrace_token
(
0
)
,
symbol
(
0
)
{}
...
...
src/shared/cplusplus/ASTClone.cpp
View file @
88fe5a50
...
...
@@ -557,6 +557,7 @@ EnumSpecifierAST *EnumSpecifierAST::clone(MemoryPool *pool) const
for
(
EnumeratorListAST
*
iter
=
enumerator_list
,
**
ast_iter
=
&
ast
->
enumerator_list
;
iter
;
iter
=
iter
->
next
,
ast_iter
=
&
(
*
ast_iter
)
->
next
)
*
ast_iter
=
new
(
pool
)
EnumeratorListAST
((
iter
->
value
)
?
iter
->
value
->
clone
(
pool
)
:
0
);
ast
->
stray_comma_token
=
stray_comma_token
;
ast
->
rbrace_token
=
rbrace_token
;
return
ast
;
}
...
...
src/shared/cplusplus/ASTMatcher.cpp
View file @
88fe5a50
...
...
@@ -926,6 +926,8 @@ bool ASTMatcher::match(EnumSpecifierAST *node, EnumSpecifierAST *pattern)
else
if
(
!
AST
::
match
(
node
->
enumerator_list
,
pattern
->
enumerator_list
,
this
))
return
false
;
pattern
->
stray_comma_token
=
node
->
stray_comma_token
;
pattern
->
rbrace_token
=
node
->
rbrace_token
;
return
true
;
...
...
src/shared/cplusplus/Bind.cpp
View file @
88fe5a50
...
...
@@ -1796,7 +1796,13 @@ bool Bind::visit(SimpleDeclarationAST *ast)
bool
Bind
::
visit
(
EmptyDeclarationAST
*
ast
)
{
(
void
)
ast
;
// unsigned semicolon_token = ast->semicolon_token;
unsigned
semicolon_token
=
ast
->
semicolon_token
;
if
(
_scope
&&
(
_scope
->
isClass
()
||
_scope
->
isNamespace
()))
{
const
Token
&
tk
=
tokenAt
(
semicolon_token
);
if
(
!
tk
.
generated
())
translationUnit
()
->
warning
(
semicolon_token
,
"extra `;'"
);
}
return
false
;
}
...
...
@@ -2770,6 +2776,14 @@ bool Bind::visit(EnumSpecifierAST *ast)
for
(
EnumeratorListAST
*
it
=
ast
->
enumerator_list
;
it
;
it
=
it
->
next
)
{
this
->
enumerator
(
it
->
value
,
e
);
}
if
(
ast
->
stray_comma_token
/* && ! translationUnit()->cxx0xEnabled()*/
)
{
const
Token
&
tk
=
tokenAt
(
ast
->
stray_comma_token
);
if
(
!
tk
.
generated
())
translationUnit
()
->
warning
(
ast
->
stray_comma_token
,
"commas at the end of enumerator lists are a C++0x-specific feature"
);
}
(
void
)
switchScope
(
previousScope
);
return
false
;
}
...
...
src/shared/cplusplus/Parser.cpp
View file @
88fe5a50
...
...
@@ -1546,6 +1546,9 @@ bool Parser::parseEnumSpecifier(SpecifierListAST *&node)
enumerator_ptr
=
&
(
*
enumerator_ptr
)
->
next
;
}
if
(
LA
()
==
T_COMMA
&&
LA
(
2
)
==
T_RBRACE
)
ast
->
stray_comma_token
=
consumeToken
();
if
(
LA
()
!=
T_RBRACE
)
match
(
T_COMMA
,
&
comma_token
);
}
...
...
tests/tools/cplusplus-dump/dumpers.inc
View file @
88fe5a50
...
...
@@ -543,6 +543,8 @@ virtual bool visit(EnumSpecifierAST *ast)
terminal
(
ast
->
lbrace_token
,
ast
);
for
(
EnumeratorListAST
*
iter
=
ast
->
enumerator_list
;
iter
;
iter
=
iter
->
next
)
nonterminal
(
iter
->
value
);
if
(
ast
->
stray_comma_token
)
terminal
(
ast
->
stray_comma_token
,
ast
);
if
(
ast
->
rbrace_token
)
terminal
(
ast
->
rbrace_token
,
ast
);
return
false
;
...
...
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