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>bb10
parent
91d3c48d3d
commit
7f9d213765
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue