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
b91e6f6f40.
Change-Id: Icf11b832f31e714a88536828051f4b7f348cdb36
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
parent
8afecdcccb
commit
f946c9fb78
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue