From efcdf39bcebcc48c27c340e562fcb01af12fa0a7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 5 Mar 2013 12:35:05 +0100 Subject: [PATCH] permit returning from files this allows skipping an entire feature file if a condition is not fulfilled, without putting the whole body inside a conditional. Change-Id: I84fe9c94dda58c794fb52c3f163b40563b0db30a Reviewed-by: Joerg Bornemann Reviewed-by: Oswald Buddenhagen (cherry picked from qtbase/525eb337670f61078383c20ad9be274dcf2d0928) --- src/linguist/shared/qmakeparser.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/linguist/shared/qmakeparser.cpp b/src/linguist/shared/qmakeparser.cpp index 0dbc3ce..93c7a54 100644 --- a/src/linguist/shared/qmakeparser.cpp +++ b/src/linguist/shared/qmakeparser.cpp @@ -1024,7 +1024,6 @@ void QMakeParser::finalizeCall(ushort *&tokPtr, ushort *uc, ushort *ptr, int arg m_tmp.setRawData((QChar *)uc + 4, nlen); const QString *defName; ushort defType; - uchar nest; if (m_tmp == statics.strfor) { if (m_invert || m_operator == OrOperator) { // '|' could actually work reasonably, but qmake does nonsense here. @@ -1101,13 +1100,20 @@ void QMakeParser::finalizeCall(ushort *&tokPtr, ushort *uc, ushort *ptr, int arg parseError(fL1S("%1(function) requires one literal argument.").arg(*defName)); return; } else if (m_tmp == statics.strreturn) { - if (argc > 1) { - parseError(fL1S("return() requires zero or one argument.")); - bogusTest(tokPtr); - return; + if (m_blockstack.top().nest & NestFunction) { + if (argc > 1) { + parseError(fL1S("return() requires zero or one argument.")); + bogusTest(tokPtr); + return; + } + } else { + if (*uce != TokFuncTerminator) { + parseError(fL1S("Top-level return() requires zero arguments.")); + bogusTest(tokPtr); + return; + } } defType = TokReturn; - nest = NestFunction; goto ctrlstm2; } else if (m_tmp == statics.strnext) { defType = TokNext; @@ -1120,15 +1126,14 @@ void QMakeParser::finalizeCall(ushort *&tokPtr, ushort *uc, ushort *ptr, int arg bogusTest(tokPtr); return; } - nest = NestLoop; - ctrlstm2: - if (m_invert) { - parseError(fL1S("Unexpected NOT operator in front of %1().").arg(m_tmp)); + if (!(m_blockstack.top().nest & NestLoop)) { + parseError(fL1S("Unexpected %1().").arg(m_tmp)); bogusTest(tokPtr); return; } - if (!(m_blockstack.top().nest & nest)) { - parseError(fL1S("Unexpected %1().").arg(m_tmp)); + ctrlstm2: + if (m_invert) { + parseError(fL1S("Unexpected NOT operator in front of %1().").arg(m_tmp)); bogusTest(tokPtr); return; } -- 2.7.4