summaryrefslogtreecommitdiffstats
path: root/src/tools/qdoc/cppcodeparser.cpp
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2013-12-30 03:53:40 -0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-31 20:37:46 +0100
commit631c3dbc800bb9b2e3b227c0a09523f0f7eef0b7 (patch)
tree283b012e3c8babe0fdb86a40d83b001e6a3ef4c6 /src/tools/qdoc/cppcodeparser.cpp
parent080096590b9bc30fcbaba1bb140f6aee20418e7a (diff)
qdoc: Fix Q_PROPERTY parsing
When parsing Q_PROPERTY declarations, qdoc tries to always read an associated value for each matched keyword. This fails for property declarations including a CONSTANT or FINAL, as they have no associated values. This change fixes the above problem and makes the parsing more robust by checking the return value of matchProperty() and skipping to closing parenthesis in case of failure. Task-number: QTBUG-35722 Change-Id: Ia483b8e74aeef19b2e761b21473cd4f765cdca19 Reviewed-by: J-P Nurmi <jpnurmi@digia.com> Reviewed-by: Martin Smith <martin.smith@digia.com>
Diffstat (limited to 'src/tools/qdoc/cppcodeparser.cpp')
-rw-r--r--src/tools/qdoc/cppcodeparser.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/tools/qdoc/cppcodeparser.cpp b/src/tools/qdoc/cppcodeparser.cpp
index cec042f92b..bb403bd4d9 100644
--- a/src/tools/qdoc/cppcodeparser.cpp
+++ b/src/tools/qdoc/cppcodeparser.cpp
@@ -1916,6 +1916,16 @@ bool CppCodeParser::matchProperty(InnerNode *parent)
QString key = previousLexeme();
QString value;
+ // Keywords with no associated values
+ if (key == "CONSTANT") {
+ property->setConstant();
+ continue;
+ }
+ else if (key == "FINAL") {
+ property->setFinal();
+ continue;
+ }
+
if (match(Tok_Ident) || match(Tok_Number)) {
value = previousLexeme();
}
@@ -1966,7 +1976,7 @@ bool CppCodeParser::matchProperty(InnerNode *parent)
if (ok)
property->setRevision(revision);
else
- parent->doc().location().warning(tr("Invalid revision number: %1").arg(value));
+ location().warning(tr("Invalid revision number: %1").arg(value));
} else if (key == "SCRIPTABLE") {
QString v = value.toLower();
if (v == "true")
@@ -1978,10 +1988,6 @@ bool CppCodeParser::matchProperty(InnerNode *parent)
property->setRuntimeScrFunc(value);
}
}
- else if (key == "CONSTANT")
- property->setConstant();
- else if (key == "FINAL")
- property->setFinal();
}
match(Tok_RightParen);
return true;
@@ -2061,7 +2067,11 @@ bool CppCodeParser::matchDeclList(InnerNode *parent)
case Tok_Q_PROPERTY:
case Tok_Q_PRIVATE_PROPERTY:
case Tok_QDOC_PROPERTY:
- matchProperty(parent);
+ if (!matchProperty(parent)) {
+ location().warning(tr("Failed to parse token %1 in property declaration").arg(lexeme()));
+ skipTo(Tok_RightParen);
+ match(Tok_RightParen);
+ }
break;
case Tok_Q_DECLARE_SEQUENTIAL_ITERATOR:
readToken();