moc: Don't stumble over MSVC __declspec.

Commit 310031188c (Fix moc stumbling over gcc __attribute__
extensions, 2012-10-01) applied similar logic for GNU style
attributes.

Change-Id: I550eaefd703b4e974e6ffae7716f02074c8a8823
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
Stephen Kelly 2013-09-23 21:28:54 +02:00 committed by The Qt Project
parent 2ff3cbbb56
commit 72d6717b26
2 changed files with 11 additions and 3 deletions

View File

@ -199,6 +199,7 @@ int runMoc(int argc, char **argv)
dummyVariadicFunctionMacro.isVariadic = true;
dummyVariadicFunctionMacro.arguments += Symbol(0, PP_IDENTIFIER, "__VA_ARGS__");
pp.macros["__attribute__"] = dummyVariadicFunctionMacro;
pp.macros["__declspec"] = dummyVariadicFunctionMacro;
QString filename;
QString output;

View File

@ -43,15 +43,22 @@
// test support for gcc attributes with functions
#if defined(Q_CC_GNU) || defined(Q_MOC_RUN)
#define DEPRECATED __attribute__ ((__deprecated__))
#define DEPRECATED1 __attribute__ ((__deprecated__))
#else
#define DEPRECATED
#define DEPRECATED1
#endif
#if defined(Q_CC_MSVC) || defined(Q_MOC_RUN)
#define DEPRECATED2 __declspec(deprecated)
#else
#define DEPRECATED2
#endif
class FunctionWithAttributes : public QObject
{
Q_OBJECT
public slots:
DEPRECATED void test() {}
DEPRECATED1 void test1() {}
DEPRECATED2 void test2() {}
};