From d1329e43cbb243f3b28d172569befc0c28f49b8b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 11 Apr 2012 14:10:12 +0200 Subject: moc: fix compilation of signals returning pointers. That was a regression introduced in 1c5db1aff Example: signals: int *someSignal(); would produce this code: int* _t0 = int*(); which does not compile So have special handling for pointer to change it to '= 0' Change-Id: Ie695e15e309d15c3cfd5c5a69ac8bf6d61ae9915 Reviewed-by: Stephen Kelly --- src/tools/moc/generator.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/tools/moc') diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index ac602fd6e8..608d53c1f2 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1036,8 +1036,14 @@ void Generator::generateSignal(FunctionDef *def,int index) fprintf(out, "%s _t%d%s", a.type.name.constData(), offset++, a.rightType.constData()); } fprintf(out, ")%s\n{\n", constQualifier); - if (def->type.name.size() && def->normalizedType.size()) - fprintf(out, " %s _t0 = %s();\n", noRef(def->normalizedType).constData(), noRef(def->normalizedType).constData()); + if (def->type.name.size() && def->normalizedType.size()) { + QByteArray returnType = noRef(def->normalizedType); + if (returnType.endsWith('*')) { + fprintf(out, " %s _t0 = 0;\n", returnType.constData()); + } else { + fprintf(out, " %s _t0 = %s();\n", returnType.constData(), returnType.constData()); + } + } fprintf(out, " void *_a[] = { "); if (def->normalizedType.isEmpty()) { -- cgit v1.2.3 From d2090e19a93fca9b5015d3a6978d7079e1414e13 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 10 Apr 2012 13:38:41 +0200 Subject: moc: Fix parsing of the empty preprocessor command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When encountering a null preprocessing directive (which is supposed to be ignored), the moc preprocessor will leave a PP_NEWLINE token in the token stream. That will confuse the parser. The PP_NEWLINE token need to be ignored in the preprocessing phase. Task-number: QTBUG-22717 Change-Id: I1e502a7e5bc6fa8ce2f82109ba7199b95747ff0a Reviewed-by: João Abecasis Reviewed-by: Bradley T. Hughes --- src/tools/moc/preprocessor.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/tools/moc') diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index 07986a71e6..091f62b379 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -915,6 +915,8 @@ void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed) case PP_ENDIF: until(PP_NEWLINE); continue; + case PP_NEWLINE: + continue; case SIGNALS: case SLOTS: { Symbol sym = symbol(); -- cgit v1.2.3