diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-05-16 18:16:04 +0300 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-05-16 18:16:04 +0300 |
commit | 231d3670981a33ec42b91ad1cb33c1fc50551066 (patch) | |
tree | b1ef1096f4e279baaa2ea0d2daf14b5c4185a82f /src/tools/moc | |
parent | tst_QSslCertificate::verify - remove QSKIP (diff) | |
parent | Android: Fix Application becomes unresponsive issue (diff) | |
download | qtbase-5.15.5-lts-lgpl.tar.xz qtbase-5.15.5-lts-lgpl.zip |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.5' into tqtc/lts-5.15-opensourcev5.15.5-lts-lgpl
Change-Id: I0cdb390124e783dc9cd832a9954baa76a0e9eb6b
Diffstat (limited to 'src/tools/moc')
-rw-r--r-- | src/tools/moc/moc.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 7389919911..2c0c21ff42 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -219,6 +219,7 @@ Type Moc::parseType() case DOUBLE: case VOID: case BOOL: + case AUTO: type.name += lexem(); isVoid |= (lookup(0) == VOID); break; @@ -458,15 +459,6 @@ bool Moc::parseFunction(FunctionDef *def, bool inMacro) scopedFunctionName = tempType.isScoped; } - // we don't support references as return types, it's too dangerous - if (def->type.referenceType == Type::Reference) { - QByteArray rawName = def->type.rawName; - def->type = Type("void"); - def->type.rawName = rawName; - } - - def->normalizedType = normalizeType(def->type.name); - if (!test(RPAREN)) { parseFunctionArguments(def); next(RPAREN); @@ -489,6 +481,10 @@ bool Moc::parseFunction(FunctionDef *def, bool inMacro) next(LPAREN); until(RPAREN); } + + if (def->type.name == "auto" && test(ARROW)) + def->type = parseType(); // Parse trailing return-type + if (test(SEMIC)) ; else if ((def->inlineCode = test(LBRACE))) @@ -506,6 +502,22 @@ bool Moc::parseFunction(FunctionDef *def, bool inMacro) warning(msg.constData()); return false; } + + QList<QByteArray> typeNameParts = normalizeType(def->type.name).split(' '); + if (typeNameParts.contains("auto")) { + // We expected a trailing return type but we haven't seen one + error("Function declared with auto as return type but missing trailing return type. " + "Return type deduction is not supported."); + } + + // we don't support references as return types, it's too dangerous + if (def->type.referenceType == Type::Reference) { + QByteArray rawName = def->type.rawName; + def->type = Type("void"); + def->type.rawName = rawName; + } + + def->normalizedType = normalizeType(def->type.name); return true; } |