From 27d79ce91b88e550331af78a47dac16d1b11d1b0 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 28 Oct 2014 14:33:39 +0100 Subject: moc: do not error if the last token of a define is # MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We do not need to emit a diagnostic at definition time. The diagnostic will be emit at expansion time. Fix error when parsing boost header: /usr/include/boost/fusion/container/vector/vector.hpp:25: Error: '#' is not followed by a macro parameter Task-number: QTBUG-42233 Change-Id: I27deab362341f17ca3b0160615bb1b0934c3d5c3 Reviewed-by: Jędrzej Nowacki --- src/tools/moc/preprocessor.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/tools/moc') diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index 087b064c0f..c5d6b58412 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Copyright (C) 2013 Olivier Goffart +** Copyright (C) 2014 Olivier Goffart ** Contact: http://www.qt-project.org/legal ** ** This file is part of the tools applications of the Qt Toolkit. @@ -1094,10 +1094,6 @@ void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed) macro.symbols.last().token == PP_HASHHASH) { error("'##' cannot appear at either end of a macro expansion"); } - if (macro.symbols.last().token == HASH || - macro.symbols.last().token == PP_HASH) { - error("'#' is not followed by a macro parameter"); - } } macros.insert(name, macro); continue; -- cgit v1.2.3 From 0b54de41bc6beeddc0453a3f31527eaaf53ffee5 Mon Sep 17 00:00:00 2001 From: Axel Rasmussen Date: Sun, 2 Nov 2014 15:02:07 -0700 Subject: moc: use Q_NULLPTR instead of 0 in generated code. This commit changes several instances where moc was generating code that used 0 as a null pointer constant. The Q_NULLPTR define is the more idiomatic way to do this, and additionally this silences warnings generated by e.g. GCC's -Wzero-as-null-pointer-constant. [ChangeLog][Tools][moc] Fixed "zero as null pointer constant" warnings in moc's generated code. Change-Id: Ibe382b7bdbdddaf20cb4bdfd075fcdd1f363f9d3 Reviewed-by: Thiago Macieira Reviewed-by: Olivier Goffart --- src/tools/moc/generator.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/tools/moc') diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index dd032e46f6..6c5e772e8c 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -493,7 +493,7 @@ void Generator::generateCode() for (int i = 0; i < extraList.count(); ++i) { fprintf(out, " &%s::staticMetaObject,\n", extraList.at(i).constData()); } - fprintf(out, " 0\n};\n\n"); + fprintf(out, " Q_NULLPTR\n};\n\n"); } // @@ -505,24 +505,24 @@ void Generator::generateCode() fprintf(out, "const QMetaObject %s::staticMetaObject = {\n", cdef->qualified.constData()); if (isQObject) - fprintf(out, " { 0, "); + fprintf(out, " { Q_NULLPTR, "); else if (cdef->superclassList.size()) fprintf(out, " { &%s::staticMetaObject, ", purestSuperClass.constData()); else - fprintf(out, " { 0, "); + fprintf(out, " { Q_NULLPTR, "); fprintf(out, "qt_meta_stringdata_%s.data,\n" " qt_meta_data_%s, ", qualifiedClassNameIdentifier.constData(), qualifiedClassNameIdentifier.constData()); if (cdef->hasQObject && !isQt) fprintf(out, " qt_static_metacall, "); else - fprintf(out, " 0, "); + fprintf(out, " Q_NULLPTR, "); if (extraList.isEmpty()) - fprintf(out, "0, "); + fprintf(out, "Q_NULLPTR, "); else fprintf(out, "qt_meta_extradata_%s, ", qualifiedClassNameIdentifier.constData()); - fprintf(out, "0}\n};\n\n"); + fprintf(out, "Q_NULLPTR}\n};\n\n"); if(isQt) return; @@ -537,7 +537,7 @@ void Generator::generateCode() // Generate smart cast function // fprintf(out, "\nvoid *%s::qt_metacast(const char *_clname)\n{\n", cdef->qualified.constData()); - fprintf(out, " if (!_clname) return 0;\n"); + fprintf(out, " if (!_clname) return Q_NULLPTR;\n"); fprintf(out, " if (!strcmp(_clname, qt_meta_stringdata_%s.stringdata))\n" " return static_cast(const_cast< %s*>(this));\n", qualifiedClassNameIdentifier.constData(), cdef->classname.constData()); @@ -562,7 +562,7 @@ void Generator::generateCode() QByteArray superClass = purestSuperClass; fprintf(out, " return %s::qt_metacast(_clname);\n", superClass.constData()); } else { - fprintf(out, " return 0;\n"); + fprintf(out, " return Q_NULLPTR;\n"); } fprintf(out, "}\n"); @@ -1416,7 +1416,7 @@ void Generator::generateSignal(FunctionDef *def,int index) fprintf(out, "QPrivateSignal"); fprintf(out, ")%s\n{\n" - " QMetaObject::activate(%s, &staticMetaObject, %d, 0);\n" + " QMetaObject::activate(%s, &staticMetaObject, %d, Q_NULLPTR);\n" "}\n", constQualifier, thisPtr.constData(), index); return; } @@ -1446,7 +1446,7 @@ void Generator::generateSignal(FunctionDef *def,int index) fprintf(out, " void *_a[] = { "); if (def->normalizedType == "void") { - fprintf(out, "0"); + fprintf(out, "Q_NULLPTR"); } else { if (def->returnTypeIsVolatile) fprintf(out, "const_cast(reinterpret_cast(&_t0))"); -- cgit v1.2.3