From 3d0fa4d4fb870450f6e77d7248db91984ddf8b50 Mon Sep 17 00:00:00 2001 From: Eric Lemanissier Date: Tue, 26 Sep 2017 11:45:56 +0200 Subject: moc: remove useless cast in qt_static_metacall generated code _a[1] was reinterpret_casted twice in a row, which triggers clang's warning undefined-reinterpret-cast: "dereference of type '_t *' (aka ...) that was reinterpret_cast from type 'void **' has undefined behavior " only the last reinterpret_cast is kept Change-Id: I71d52c5ff08c674003aec29f8a907c90905c0d4c Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/generator.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 6795e3b2cf..7e1ec3522f 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1237,7 +1237,6 @@ void Generator::generateStaticMetacall() Q_ASSERT(needElse); // if there is signal, there was method. fprintf(out, " else if (_c == QMetaObject::IndexOfMethod) {\n"); fprintf(out, " int *result = reinterpret_cast(_a[0]);\n"); - fprintf(out, " void **func = reinterpret_cast(_a[1]);\n"); bool anythingUsed = false; for (int methodindex = 0; methodindex < cdef->signalList.size(); ++methodindex) { const FunctionDef &f = cdef->signalList.at(methodindex); @@ -1263,14 +1262,14 @@ void Generator::generateStaticMetacall() fprintf(out, ") const;\n"); else fprintf(out, ");\n"); - fprintf(out, " if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&%s::%s)) {\n", + fprintf(out, " if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&%s::%s)) {\n", cdef->classname.constData(), f.name.constData()); fprintf(out, " *result = %d;\n", methodindex); fprintf(out, " return;\n"); fprintf(out, " }\n }\n"); } if (!anythingUsed) - fprintf(out, " Q_UNUSED(result);\n Q_UNUSED(func);\n"); + fprintf(out, " Q_UNUSED(result);\n"); fprintf(out, " }"); needElse = true; } -- cgit v1.2.3