summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qcompilerdetection.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-04-18 16:43:41 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-06-07 15:54:31 +0000
commitd254d8c19714af69a9897bdd67c4e9aa3267c3a3 (patch)
tree1b82236c071690ec3a5539e846f68bbd42dbcade /src/corelib/global/qcompilerdetection.h
parent6ae801875ea3c654f808b7ed519b403807653068 (diff)
Use the C++ [[nodiscard]] attribute
Change-Id: I7814054a102a407d876ffffd14b6a285c70b21de Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/global/qcompilerdetection.h')
-rw-r--r--src/corelib/global/qcompilerdetection.h67
1 files changed, 36 insertions, 31 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index c221115e8f..9ffd164b61 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -1061,6 +1061,37 @@
#endif
/*
+ * SG10's SD-6 feature detection and some useful extensions from Clang and GCC
+ * https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations
+ * http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
+ */
+#ifdef __has_builtin
+# define QT_HAS_BUILTIN(x) __has_builtin(x)
+#else
+# define QT_HAS_BUILTIN(x) 0
+#endif
+#ifdef __has_attribute
+# define QT_HAS_ATTRIBUTE(x) __has_attribute(x)
+#else
+# define QT_HAS_ATTRIBUTE(x) 0
+#endif
+#ifdef __has_cpp_attribute
+# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
+#else
+# define QT_HAS_CPP_ATTRIBUTE(x) 0
+#endif
+#ifdef __has_include
+# define QT_HAS_INCLUDE(x) __has_include(x)
+#else
+# define QT_HAS_INCLUDE(x) 0
+#endif
+#ifdef __has_include_next
+# define QT_HAS_INCLUDE_NEXT(x) __has_include_next(x)
+#else
+# define QT_HAS_INCLUDE_NEXT(x) 0
+#endif
+
+/*
* C++11 keywords and expressions
*/
#ifdef Q_COMPILER_NULLPTR
@@ -1141,6 +1172,11 @@
# define Q_DECL_ALIGN(n) alignas(n)
#endif
+#if QT_HAS_CPP_ATTRIBUTE(nodiscard) // P0188R1
+# undef Q_REQUIRED_RESULT
+# define Q_REQUIRED_RESULT [[nodiscard]]
+#endif
+
/*
* Fallback macros to certain compiler features
*/
@@ -1215,37 +1251,6 @@
#ifndef QT_MAKE_CHECKED_ARRAY_ITERATOR
# define QT_MAKE_CHECKED_ARRAY_ITERATOR(x, N) (x)
#endif
-
-/*
- * SG10's SD-6 feature detection and some useful extensions from Clang and GCC
- * https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations
- * http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
- */
-#ifdef __has_builtin
-# define QT_HAS_BUILTIN(x) __has_builtin(x)
-#else
-# define QT_HAS_BUILTIN(x) 0
-#endif
-#ifdef __has_attribute
-# define QT_HAS_ATTRIBUTE(x) __has_attribute(x)
-#else
-# define QT_HAS_ATTRIBUTE(x) 0
-#endif
-#ifdef __has_cpp_attribute
-# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
-#else
-# define QT_HAS_CPP_ATTRIBUTE(x) 0
-#endif
-#ifdef __has_include
-# define QT_HAS_INCLUDE(x) __has_include(x)
-#else
-# define QT_HAS_INCLUDE(x) 0
-#endif
-#ifdef __has_include_next
-# define QT_HAS_INCLUDE_NEXT(x) __has_include_next(x)
-#else
-# define QT_HAS_INCLUDE_NEXT(x) 0
-#endif
#ifdef __has_feature
# define QT_HAS_FEATURE(x) __has_feature(x)
#else