From b9b5734559774d7fe571b94fda7896e4806707f4 Mon Sep 17 00:00:00 2001 From: Mate Barany Date: Mon, 20 Jun 2022 14:26:38 +0200 Subject: [PATCH] Disable useless-cast warning for moc generated code The useless-cast gcc warning is disabled in the files generated by the moc. A typical warning is like using_t = void(Counter::*)(int ); if (*reinterpret_cast<_t*>(_a[1]) == static_cast<_t>(&Counter::valueChanged)) { *result = 0; return; } Removing the static cast results in a compilation error "address of overloaded function with no contextual type-of information" in moc_myobject.cpp files. Checking whether we have an overload set or a single function might be too much effort for too little benefit and may not worth it. Fixes: QTBUG-71938 Change-Id: I6f67e163a3493b51fb95f54218ce6bf9a302f824 Reviewed-by: Fabian Kosmale --- src/tools/moc/moc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 550c1ac422..dc8fcbf8db 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -1107,6 +1107,7 @@ void Moc::generate(FILE *out, FILE *jsonOutput) fprintf(out, "QT_BEGIN_MOC_NAMESPACE\n"); fprintf(out, "QT_WARNING_PUSH\n"); fprintf(out, "QT_WARNING_DISABLE_DEPRECATED\n"); + fprintf(out, "QT_WARNING_DISABLE_GCC(\"-Wuseless-cast\")\n"); fputs("", out); for (i = 0; i < classList.size(); ++i) {