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 <lars.knoll@qt.io>bb10
parent
370324f6e2
commit
d8a2456fbf
|
|
@ -261,11 +261,21 @@ bool Moc::parseEnum(EnumDef *def)
|
|||
}
|
||||
if (!test(LBRACE))
|
||||
return false;
|
||||
auto handleInclude = [this]() {
|
||||
if (test(MOC_INCLUDE_BEGIN))
|
||||
currentFilenames.push(symbol().unquotedLexem());
|
||||
if (test(NOTOKEN)) {
|
||||
next(MOC_INCLUDE_END);
|
||||
currentFilenames.pop();
|
||||
}
|
||||
};
|
||||
do {
|
||||
if (lookup() == RBRACE) // accept trailing comma
|
||||
break;
|
||||
handleInclude();
|
||||
next(IDENTIFIER);
|
||||
def->values += lexem();
|
||||
handleInclude();
|
||||
skipCxxAttributes();
|
||||
} while (test(EQ) ? until(COMMA) : test(COMMA));
|
||||
next(RBRACE);
|
||||
|
|
|
|||
|
|
@ -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": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
parcel
|
||||
|
|
@ -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 <QtCore/QObject>
|
||||
|
||||
class Foo : public QObject {
|
||||
enum en {
|
||||
#include <enum_inc.h>
|
||||
};
|
||||
Q_OBJECT
|
||||
};
|
||||
#endif
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue