Use [[nodiscard]] with clang in C++17 mode

It is only broken in C++11/c++14 mode.

We do need to fix the order of visibility-attributes and this
C++ attribute.

Change-Id: I41e4367f1aaa9241fec4e336c39e58b798336b2c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Allan Sandfeld Jensen 2020-08-12 14:53:21 +02:00
parent 579a11590d
commit 041f655c01
4 changed files with 8 additions and 8 deletions

View File

@ -1129,8 +1129,8 @@
# define Q_DECL_ALIGN(n) alignas(n)
#endif
#if __has_cpp_attribute(nodiscard) && !defined(Q_CC_CLANG) // P0188R1
// Can't use [[nodiscard]] with Clang, see https://bugs.llvm.org/show_bug.cgi?id=33518
#if __has_cpp_attribute(nodiscard) && (!defined(Q_CC_CLANG) || __cplusplus > 201402L) // P0188R1
// Can't use [[nodiscard]] with Clang and C++11/14, see https://bugs.llvm.org/show_bug.cgi?id=33518
# undef Q_REQUIRED_RESULT
# define Q_REQUIRED_RESULT [[nodiscard]]
#endif

View File

@ -47,8 +47,8 @@ QT_BEGIN_NAMESPACE
class QWindow;
namespace QTest {
Q_GUI_EXPORT Q_REQUIRED_RESULT bool qWaitForWindowActive(QWindow *window, int timeout = 5000);
Q_GUI_EXPORT Q_REQUIRED_RESULT bool qWaitForWindowExposed(QWindow *window, int timeout = 5000);
Q_REQUIRED_RESULT Q_GUI_EXPORT bool qWaitForWindowActive(QWindow *window, int timeout = 5000);
Q_REQUIRED_RESULT Q_GUI_EXPORT bool qWaitForWindowExposed(QWindow *window, int timeout = 5000);
}
QT_END_NAMESPACE

View File

@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
\sa qWaitForWindowExposed(), QWidget::isActiveWindow()
*/
Q_WIDGETS_EXPORT Q_REQUIRED_RESULT bool QTest::qWaitForWindowActive(QWidget *widget, int timeout)
Q_WIDGETS_EXPORT bool QTest::qWaitForWindowActive(QWidget *widget, int timeout)
{
if (QWindow *window = widget->window()->windowHandle())
return QTest::qWaitForWindowActive(window, timeout);
@ -80,7 +80,7 @@ Q_WIDGETS_EXPORT Q_REQUIRED_RESULT bool QTest::qWaitForWindowActive(QWidget *wid
\sa qWaitForWindowActive()
*/
Q_WIDGETS_EXPORT Q_REQUIRED_RESULT bool QTest::qWaitForWindowExposed(QWidget *widget, int timeout)
Q_WIDGETS_EXPORT bool QTest::qWaitForWindowExposed(QWidget *widget, int timeout)
{
if (QWindow *window = widget->window()->windowHandle())
return QTest::qWaitForWindowExposed(window, timeout);

View File

@ -47,8 +47,8 @@ QT_BEGIN_NAMESPACE
class QWidget;
namespace QTest {
Q_WIDGETS_EXPORT Q_REQUIRED_RESULT bool qWaitForWindowActive(QWidget *widget, int timeout = 5000);
Q_WIDGETS_EXPORT Q_REQUIRED_RESULT bool qWaitForWindowExposed(QWidget *widget, int timeout = 5000);
Q_REQUIRED_RESULT Q_WIDGETS_EXPORT bool qWaitForWindowActive(QWidget *widget, int timeout = 5000);
Q_REQUIRED_RESULT Q_WIDGETS_EXPORT bool qWaitForWindowExposed(QWidget *widget, int timeout = 5000);
}
QT_END_NAMESPACE