From d8a2456fbf18f60e2d1950585d93aa530df077bf Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Tue, 26 May 2020 13:33:42 +0200 Subject: moc: handle include directives in enums When including files, moc inserts a MOC_INCLUDE_BEGIN and MOC_INCLUDE_END token into the token stream. Those are already handled in the toplevel Moc::parse function, but parseEnum lacked support so far. Pick-to: 5.15 Fixes: QTBUG-80578 Change-Id: I35c8fd959347d94af20090b3a505dd9e6bfaff88 Reviewed-by: Lars Knoll --- tests/auto/tools/moc/allmocs_baseline_in.json | 17 ++++++++++++ tests/auto/tools/moc/enum_inc.h | 1 + tests/auto/tools/moc/enum_with_include.h | 39 +++++++++++++++++++++++++++ tests/auto/tools/moc/moc.pro | 2 ++ 4 files changed, 59 insertions(+) create mode 100644 tests/auto/tools/moc/enum_inc.h create mode 100644 tests/auto/tools/moc/enum_with_include.h (limited to 'tests/auto/tools/moc') diff --git a/tests/auto/tools/moc/allmocs_baseline_in.json b/tests/auto/tools/moc/allmocs_baseline_in.json index 77647329c9..94593b1ef8 100644 --- a/tests/auto/tools/moc/allmocs_baseline_in.json +++ b/tests/auto/tools/moc/allmocs_baseline_in.json @@ -710,6 +710,23 @@ "inputFile": "dir-in-include-path.h", "outputRevision": 67 }, + { + "classes": [ + { + "className": "Foo", + "object": true, + "qualifiedClassName": "Foo", + "superClasses": [ + { + "access": "public", + "name": "QObject" + } + ] + } + ], + "inputFile": "enum_with_include.h", + "outputRevision": 67 + }, { "classes": [ { diff --git a/tests/auto/tools/moc/enum_inc.h b/tests/auto/tools/moc/enum_inc.h new file mode 100644 index 0000000000..32eec283e4 --- /dev/null +++ b/tests/auto/tools/moc/enum_inc.h @@ -0,0 +1 @@ +parcel diff --git a/tests/auto/tools/moc/enum_with_include.h b/tests/auto/tools/moc/enum_with_include.h new file mode 100644 index 0000000000..b8abf77f12 --- /dev/null +++ b/tests/auto/tools/moc/enum_with_include.h @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 ENUM_WITH_INCLUDE_H +#define ENUM_WITH_INCLUDE_H +#include + +class Foo : public QObject { + enum en { + #include + }; + Q_OBJECT +}; +#endif diff --git a/tests/auto/tools/moc/moc.pro b/tests/auto/tools/moc/moc.pro index 094c76227b..693a2ab2f9 100644 --- a/tests/auto/tools/moc/moc.pro +++ b/tests/auto/tools/moc/moc.pro @@ -31,11 +31,13 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n related-metaobjects-name-conflict.h \ namespace.h cxx17-namespaces.h \ cxx-attributes.h \ + enum_inc.h enum_with_include.h \ moc_include.h # No platform specifics in the JSON files, so that we can compare them JSON_HEADERS = $$HEADERS JSON_HEADERS -= cxx-attributes.h +JSON_HEADERS -= enum_inc.h if(*-g++*|*-icc*|*-clang*|*-llvm):!win32-*: HEADERS += os9-newlines.h win-newlines.h if(*-g++*|*-clang*): HEADERS += dollars.h -- cgit v1.2.3