summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qscopeguard.h
diff options
context:
space:
mode:
authorJędrzej Nowacki <jedrzej.nowacki@qt.io>2019-05-21 15:43:41 +0200
committerJędrzej Nowacki <jedrzej.nowacki@qt.io>2019-05-21 15:47:55 +0200
commitf946c9fb78e9a267647e9fd1b397d9b7ca2b6664 (patch)
tree67c9d1459d800f7fc495dda2fdbfbf8ae48bc960 /src/corelib/tools/qscopeguard.h
parent8afecdcccb58f53147ae5a8edcc4c510cabc54d2 (diff)
Fix compilation error on compilers not supporting [[nodiscard]]
__warn_unused_result__ and [[nodiscard]] both are masked by Q_REQUIRED_RESULT but there are some minor differences between them. In general [[nodiscard]] is more flexible while __warn_unused_result__ can cause warnings in some contexts, for example: error #2621: attribute "__warn_unused_result__" does not apply here error #3058: GNU attributes on a template redeclaration have no effect That is a fix for regression caused by b91e6f6f40864d54903d707d7f19a9732188b670. Change-Id: Icf11b832f31e714a88536828051f4b7f348cdb36 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/tools/qscopeguard.h')
-rw-r--r--src/corelib/tools/qscopeguard.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/tools/qscopeguard.h b/src/corelib/tools/qscopeguard.h
index d20620e933..45c3f93da4 100644
--- a/src/corelib/tools/qscopeguard.h
+++ b/src/corelib/tools/qscopeguard.h
@@ -51,8 +51,9 @@ template <typename F> QScopeGuard<F> qScopeGuard(F f);
template <typename F>
class
-#ifndef __INTEL_COMPILER
-// error #2621: attribute "__warn_unused_result__" does not apply here
+#if QT_HAS_CPP_ATTRIBUTE(nodiscard)
+// Q_REQUIRED_RESULT can be defined as __warn_unused_result__ or as [[nodiscard]]
+// but the 1st one has some limitations for example can be placed only on functions.
Q_REQUIRED_RESULT
#endif
QScopeGuard
@@ -90,8 +91,7 @@ private:
template <typename F>
-#ifndef __INTEL_COMPILER
-// Causes "error #3058: GNU attributes on a template redeclaration have no effect"
+#if QT_HAS_CPP_ATTRIBUTE(nodiscard)
Q_REQUIRED_RESULT
#endif
QScopeGuard<F> qScopeGuard(F f)