summaryrefslogtreecommitdiffstats
path: root/src/tools/moc/moc.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2013-05-18 11:24:12 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-20 10:06:04 +0200
commit208e9a2757ae9146e538fffe399c18ee4259a84a (patch)
tree7c2f09b7517efbc8829f97ab2fae61564cbb8fa5 /src/tools/moc/moc.cpp
parentf1d1b8219cbb94ec327047d71ebdc6510317ce3b (diff)
moc: recover bad template parsing.
When encountering code such as: X<a<b> moc does not have the mean to know if 'a' is a type or a variable, so the type parser currently assume that '<' always open a template parameter. (instead of being the operator<) The type parser do not care about the actual type, it just need to strip the string out. The problem is that then the whole rest of the file will be considered as the type. With this patch, we also stop the parsing at semicolon. The type will be wrong, but this allow the parser to recover and it will continue to look for more classes after this. (In other words, moc will no longer break if it encounter such construct in a header. But it will still not parse such types correctly if used within a Q_OBJECT class) Task-number: QTBUG-31218 Change-Id: I1fef6bc58493d7c00df72401c9ad55463b24eaa7 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/tools/moc/moc.cpp')
-rw-r--r--src/tools/moc/moc.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 1ebb82ffad..f3bfcc3144 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -1449,6 +1449,11 @@ bool Moc::until(Token target) {
--index;
break;
}
+
+ if (braceCount <= 0 && t == SEMIC) {
+ // Abort on semicolon. Allow recovering bad template parsing (QTBUG-31218)
+ break;
+ }
}
if(target == COMMA && angleCount != 0 && possible != -1) {