Fix moc stumbling over gcc __attribute__ extensions
Reported by David Faure. In KDE a DEPRECATED macro gets defined in a header file created by cmake. The define is not guarded with #if Q_CC_GNU or similar because at cmake time the compiler is determined. Therefore moc suddenly sees this gcc specific token and stumbles over it. This patch simply defines an empty __attribute__ macro that will expand to nothing and thus become invisible to moc's "C++ parser" after the pre-processing. Change-Id: I4448b9ac3f72b6334e32b27484401fb0fca23a0c Reviewed-by: David Faure <faure@kde.org> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
291e1a9e67
commit
310031188c
@ -170,6 +170,14 @@ int runMoc(int _argc, char **_argv)
|
||||
Moc moc;
|
||||
pp.macros["Q_MOC_RUN"];
|
||||
pp.macros["__cplusplus"];
|
||||
|
||||
// Don't stumble over GCC extensions
|
||||
Macro dummyVariadicFunctionMacro;
|
||||
dummyVariadicFunctionMacro.isFunction = true;
|
||||
dummyVariadicFunctionMacro.isVariadic = true;
|
||||
dummyVariadicFunctionMacro.arguments += Symbol(0, PP_IDENTIFIER, "__VA_ARGS__");
|
||||
pp.macros["__attribute__"] = dummyVariadicFunctionMacro;
|
||||
|
||||
QByteArray filename;
|
||||
QByteArray output;
|
||||
FILE *in = 0;
|
||||
|
57
tests/auto/tools/moc/function-with-attributes.h
Normal file
57
tests/auto/tools/moc/function-with-attributes.h
Normal file
@ -0,0 +1,57 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#include <qobject.h>
|
||||
|
||||
// test support for gcc attributes with functions
|
||||
|
||||
#if defined(Q_CC_GNU) || defined(Q_MOC_RUN)
|
||||
#define DEPRECATED __attribute__ ((__deprecated__))
|
||||
#else
|
||||
#define DEPRECATED
|
||||
#endif
|
||||
|
||||
class FunctionWithAttributes : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public slots:
|
||||
DEPRECATED void test() {}
|
||||
|
||||
};
|
@ -22,7 +22,8 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n
|
||||
cxx11-final-classes.h \
|
||||
cxx11-explicit-override-control.h \
|
||||
forward-declared-param.h \
|
||||
parse-defines.h
|
||||
parse-defines.h \
|
||||
function-with-attributes.h
|
||||
|
||||
|
||||
if(*-g++*|*-icc*|*-clang*|*-llvm):!irix-*:!win32-*: HEADERS += os9-newlines.h win-newlines.h
|
||||
|
Loading…
Reference in New Issue
Block a user