C++: Parse emit/Q_EMIT properly

The parser now understands emit/Q_EMIT as an expression statement.

Also, the recent fixes in the preprocessor introduced a side-effect
in the hanlding of code such as: emit signal(); Member signal started
being treated as a local use (parsed as a declaration) and possibily
being highlighted as unused variable.

Previously that worked by accident since there was an inconsistency
in the preprocessor on which only object-like macros were being
expanded even when the "no expand" flag was set. Then, the code
mentioned above was being parsed as an expression, what kind of worked.

Change-Id: I47a68ed4c1c1702872620b8ed7c7264fb0997034
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
Leandro Melo
2012-06-28 10:55:51 +02:00
parent d1971174d4
commit 621e5c3dbe
5 changed files with 46 additions and 3 deletions

View File

@@ -136,6 +136,13 @@ static inline int classify4(const char *s, bool q, bool) {
}
}
}
else if (q && s[1] == 'm') {
if (s[2] == 'i') {
if (s[3] == 't') {
return T_EMIT;
}
}
}
}
else if (s[0] == 'g') {
if (s[1] == 'o') {
@@ -417,6 +424,19 @@ static inline int classify6(const char *s, bool q, bool) {
}
}
}
else if (q && s[0] == 'Q') {
if (s[1] == '_') {
if (s[2] == 'E') {
if (s[3] == 'M') {
if (s[4] == 'I') {
if (s[5] == 'T') {
return T_Q_EMIT;
}
}
}
}
}
}
else if (s[0] == 'r') {
if (s[1] == 'e') {
if (s[2] == 't') {