summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2023-06-16 13:25:42 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2023-08-26 12:13:08 +0200
commit7f9d2137654de0ee041c74cbccb958a3a803996c (patch)
tree0b3ec5120edcaa404638f1195fb36c9a9569c56b /src/tools
parent91d3c48d3da5f75e126bbce79096a84c078e23e2 (diff)
moc: Drop support for function declaration without type specifier
Neither C++ nor modern C allow omitting the type (which used to be equivalent to an "int" return type). moc should not try to parse functions in C code, as they cannot be meta-methods. So there is no point in supporting it. Change-Id: I2b3a492988f29e8139311db64be110581cc1a4de Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/moc/moc.cpp51
1 files changed, 23 insertions, 28 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index ee15427e1c..cc5cc929b9 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -423,35 +423,29 @@ bool Moc::parseFunction(FunctionDef *def, bool inMacro)
error();
}
bool scopedFunctionName = false;
- if (test(LPAREN)) {
- def->name = def->type.name;
- scopedFunctionName = def->type.isScoped;
- def->type = Type("int");
- } else {
- // we might have modifiers and attributes after a tag
- // note that testFunctionAttribute is handled further below,
- // and revisions and attributes must come first
- while (testForFunctionModifiers(def)) {}
- Type tempType = parseType();;
- while (!tempType.name.isEmpty() && lookup() != LPAREN) {
- if (testFunctionAttribute(def->type.firstToken, def))
- ; // fine
- else if (def->type.firstToken == Q_SIGNALS_TOKEN)
- error();
- else if (def->type.firstToken == Q_SLOTS_TOKEN)
- error();
- else {
- if (!def->tag.isEmpty())
- def->tag += ' ';
- def->tag += def->type.name;
- }
- def->type = tempType;
- tempType = parseType();
+ // we might have modifiers and attributes after a tag
+ // note that testFunctionAttribute is handled further below,
+ // and revisions and attributes must come first
+ while (testForFunctionModifiers(def)) {}
+ Type tempType = parseType();;
+ while (!tempType.name.isEmpty() && lookup() != LPAREN) {
+ if (testFunctionAttribute(def->type.firstToken, def))
+ ; // fine
+ else if (def->type.firstToken == Q_SIGNALS_TOKEN)
+ error();
+ else if (def->type.firstToken == Q_SLOTS_TOKEN)
+ error();
+ else {
+ if (!def->tag.isEmpty())
+ def->tag += ' ';
+ def->tag += def->type.name;
}
- next(LPAREN, "Not a signal or slot declaration");
- def->name = tempType.name;
- scopedFunctionName = tempType.isScoped;
+ def->type = tempType;
+ tempType = parseType();
}
+ next(LPAREN, "Not a signal or slot declaration");
+ def->name = tempType.name;
+ scopedFunctionName = tempType.isScoped;
if (!test(RPAREN)) {
parseFunctionArguments(def);
@@ -543,7 +537,8 @@ bool Moc::parseMaybeFunction(const ClassDef *cdef, FunctionDef *def)
def->isConstructor = !tilde;
def->type = Type();
} else {
- def->type = Type("int");
+ // missing type name? => Skip
+ return false;
}
} else {
// ### TODO: The condition before testForFunctionModifiers shoulnd't be necessary,