From 631c3dbc800bb9b2e3b227c0a09523f0f7eef0b7 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Mon, 30 Dec 2013 03:53:40 -0800 Subject: 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 Reviewed-by: Martin Smith --- src/tools/qdoc/cppcodeparser.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/tools/qdoc/cppcodeparser.cpp') diff --git a/src/tools/qdoc/cppcodeparser.cpp b/src/tools/qdoc/cppcodeparser.cpp index cec042f92bb..bb403bd4d97 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(); -- cgit v1.2.3