diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 6939adb678..d8b547c8e2 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -2839,11 +2839,29 @@ struct is_complete_helper { template struct is_complete : detail::is_complete_helper::type {}; +template +struct qRemovePointerLike +{ + using type = std::remove_pointer_t; +}; + +#define Q_REMOVE_POINTER_LIKE_IMPL(Pointer) \ +template \ +struct qRemovePointerLike> \ +{ \ + using type = T; \ +}; + +QT_FOR_EACH_AUTOMATIC_TEMPLATE_SMART_POINTER(Q_REMOVE_POINTER_LIKE_IMPL) +template +using qRemovePointerLike_t = typename qRemovePointerLike::type; +#undef Q_REMOVE_POINTER_LIKE_IMPL + template constexpr QMetaTypeInterface *qTryMetaTypeInterfaceForType() { using Ty = std::remove_cv_t>; - using Tz = std::remove_pointer_t; + using Tz = qRemovePointerLike_t; if constexpr (!is_complete::value) { return nullptr; } else { diff --git a/tests/auto/tools/moc/allmocs_baseline_in.json b/tests/auto/tools/moc/allmocs_baseline_in.json index 94593b1ef8..f0a6aa088b 100644 --- a/tests/auto/tools/moc/allmocs_baseline_in.json +++ b/tests/auto/tools/moc/allmocs_baseline_in.json @@ -1592,6 +1592,23 @@ "inputFile": "plugin_metadata.h", "outputRevision": 67 }, + { + "classes": [ + { + "className": "TestPointeeCanBeIncomplete", + "object": true, + "qualifiedClassName": "TestPointeeCanBeIncomplete", + "superClasses": [ + { + "access": "public", + "name": "QObject" + } + ] + } + ], + "inputFile": "pointery_to_incomplete.h", + "outputRevision": 67 + }, { "classes": [ { diff --git a/tests/auto/tools/moc/moc.pro b/tests/auto/tools/moc/moc.pro index 693a2ab2f9..5bcde6c883 100644 --- a/tests/auto/tools/moc/moc.pro +++ b/tests/auto/tools/moc/moc.pro @@ -32,6 +32,7 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n namespace.h cxx17-namespaces.h \ cxx-attributes.h \ enum_inc.h enum_with_include.h \ + pointery_to_incomplete.h \ moc_include.h # No platform specifics in the JSON files, so that we can compare them diff --git a/tests/auto/tools/moc/pointery_to_incomplete.h b/tests/auto/tools/moc/pointery_to_incomplete.h new file mode 100644 index 0000000000..1fd0d89fed --- /dev/null +++ b/tests/auto/tools/moc/pointery_to_incomplete.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef POINTERY_TO_INCOMPLETE_H +#define POINTERY_TO_INCOMPLETE_H + +#include +#include +#include +#include + +class FwdClass; + +class TestPointeeCanBeIncomplete : public QObject +{ + Q_OBJECT +public: + void setProp1(QPointer) {}; + void setProp2(QSharedPointer) {}; + void setProp3(const QWeakPointer &) {}; +}; + +#endif // POINTERY_TO_INCOMPLETE_H diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index d4e3a4e297..960164dac4 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -75,6 +75,7 @@ #include "cxx-attributes.h" #include "moc_include.h" +#include "pointery_to_incomplete.h" #include "fwdclass1.h" #include "fwdclass2.h" #include "fwdclass3.h"