From 36d6eb721e7d5997ade75e289d4088dc48678d0d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 5 May 2015 08:43:42 -0700 Subject: Require -fPIC instead of just -fPIE for -reduce-relocations GCC 5 combined with a recent binutils have a new optimization that allows them to generate copy relocations even in -fPIE code. Clang has the same functionality when compiling an executable with -flto. We need to let the compilers know that they cannot use copy relocations, so they need to use really position-independent code. Position independent code throughout is not really required. We just need the compilers to use position-independent access to symbols coming from the Qt libraries, but there's currently no other way of doing that. Task-number: QTBUG-45755 Change-Id: I0d4913955e3745b69672ffff13db5df7377398c5 Reviewed-by: Simon Hausmann Reviewed-by: Oswald Buddenhagen --- tests/auto/tools/moc/tst_moc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/auto/tools/moc/tst_moc.cpp') diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index edb6488eaa..748cb82989 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -662,7 +662,7 @@ void tst_Moc::oldStyleCasts() QStringList args; args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "." - << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIE" << "-"; + << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-"; proc.start("gcc", args); QVERIFY(proc.waitForStarted()); proc.write(mocOut); @@ -732,7 +732,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension() QStringList args; args << "-c" << "-x" << "c++" << "-I" << ".." - << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIE" << "-"; + << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-"; proc.start("gcc", args); QVERIFY(proc.waitForStarted()); proc.write(mocOut); @@ -1011,7 +1011,7 @@ void tst_Moc::ignoreOptionClashes() // If -pthread wasn't ignored, it was parsed as a prefix of "thread/", which breaks compilation. QStringList gccArgs; gccArgs << "-c" << "-x" << "c++" << "-I" << ".." - << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null" << "-fPIE" << "-"; + << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null" << "-fPIC" << "-"; proc.start("gcc", gccArgs); QVERIFY(proc.waitForStarted()); proc.write(mocOut); -- cgit v1.2.3 From d6efc6b543d1a8fe2e1232750a98e396db07be0f Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 11 May 2015 12:52:34 +0200 Subject: moc: Fix type for gadget's CreateInstance metacall An error similar to the one below would be emitted by the compiler on the moc generated file: error: assigning to 'QObject *' from incompatible type 'Gadget *' if (_a[0]) *reinterpret_cast(_a[0]) = _r; } break; Change-Id: I75ae7bd6c46d20db2d47a80eaa08aae302d7d6c8 Reviewed-by: Simon Hausmann Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/tools/moc/tst_moc.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/auto/tools/moc/tst_moc.cpp') diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 405d273f4b..7fa5de3377 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -87,6 +87,16 @@ struct QTBUG_31218_Derived : QTBUG_31218<-1<0> {}; class QTBUG_45790 : Bug() { }; #endif +class CreatableGadget +{ + Q_GADGET + Q_PROPERTY(int a MEMBER a) +public: + Q_INVOKABLE CreatableGadget() : a(0xdeadbeef) { } + + int a; +}; + struct MyStruct {}; struct MyStruct2 {}; -- cgit v1.2.3 From 629f5a46d531886cebe654a4ddb9269b62874e6a Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 11 May 2015 13:11:59 +0200 Subject: moc: Generate qt_static_metacall for creatable-only gadgets Prior to this, moc would not generate the function unless the gadget class had a property or a non-constructor invokable. Change-Id: Ic020ea5f8f59702f5e9e194a46e26850e53e5cfe Reviewed-by: Simon Hausmann Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/tools/moc/tst_moc.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests/auto/tools/moc/tst_moc.cpp') diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 7fa5de3377..8bef678af9 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -90,13 +90,15 @@ struct QTBUG_31218_Derived : QTBUG_31218<-1<0> {}; class CreatableGadget { Q_GADGET - Q_PROPERTY(int a MEMBER a) public: - Q_INVOKABLE CreatableGadget() : a(0xdeadbeef) { } - - int a; + Q_INVOKABLE CreatableGadget() + { + CreatableGadget::qt_static_metacall((QObject*)this, QMetaObject::ReadProperty, -1, Q_NULLPTR); + } }; +CreatableGadget creatableGadget; // Force the compiler to use the constructor + struct MyStruct {}; struct MyStruct2 {}; -- cgit v1.2.3 From 71c85c554a49ed3a17167e436630ddaff2b9fcb1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 29 May 2015 12:39:24 +0200 Subject: moc: Fix crash parsing invalid macro invocation When invoking a macro with less argument than it expect, we would crash trying to access the vector of arguments from the invocation as we are trying to substitute an argument. (Note that we do not show an error in case of argument mismatch because ithat might happen parsing valid code as moc's c++ parser is not 100% accurate (that was QTBUG-29331)) Task-number: QTBUG-46210 Change-Id: I3f08d7f5049e593a5bdc02a594ea63cadf66e7a4 Reviewed-by: Gabriel de Dietrich --- tests/auto/tools/moc/tst_moc.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/auto/tools/moc/tst_moc.cpp') diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 8bef678af9..350c6142d2 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -1882,6 +1882,13 @@ void tst_Moc::warnings_data() << 1 << QString() << QString("standard input:5: Error: Class declaration lacks Q_OBJECT macro."); + + QTest::newRow("QTBUG-46210: crash on invalid macro") + << QByteArray("#define Foo(a, b, c) a b c #a #b #c a##b##c #d\n Foo(45);") + << QStringList() + << 1 + << QString("IGNORE_ALL_STDOUT") + << QString(":2: Error: '#' is not followed by a macro parameter"); } void tst_Moc::warnings() -- cgit v1.2.3