Split Q_COMPILER_DEFAULT_DELETE_MEMBERS
authorBradley T. Hughes <bradley.hughes@nokia.com>
Mon, 14 May 2012 07:22:40 +0000 (09:22 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 15 May 2012 02:57:05 +0000 (04:57 +0200)
Based on reviewer comments on
https://codereview.qt-project.org/#change,25992, split
Q_COMPILER_DEFAULT_DELETE_MEMBERS into
Q_COMPILER_DEFAULT_MEMBERS and Q_COMPILER_DELETE_MEMBERS. Clang provides
2 separate feature checks for these, all other compilers always define
both.

Keep the Q_COMPILER_DEFAULT_DELETE_MEMBERS define, though, for any
existing code that may be using it.

Change-Id: I8969e10989c776a822da153152cfecb99dda8cb9
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/global/qcompilerdetection.h
src/corelib/thread/qbasicatomic.h

index c55da5c..b4ea022 100644 (file)
  *  N2437           Q_COMPILER_CLASS_ENUM
  *  N2235           Q_COMPILER_CONSTEXPR
  *  N2343 N3276     Q_COMPILER_DECLTYPE
- *  N2346           Q_COMPILER_DEFAULT_DELETE_MEMBERS
+ *  N2346           Q_COMPILER_DEFAULT_MEMBERS
+ *  N2346           Q_COMPILER_DELETE_MEMBERS
  *  N1986           Q_COMPILER_DELEGATING_CONSTRUCTORS
  *  N3206 N3272     Q_COMPILER_EXPLICIT_OVERRIDES   (v0.9 and above only)
  *  N1987           Q_COMPILER_EXTERN_TEMPLATES
 #      define Q_COMPILER_AUTO_TYPE
 #      define Q_COMPILER_CLASS_ENUM
 #      define Q_COMPILER_DECLTYPE
-#      define Q_COMPILER_DEFAULT_DELETE_MEMBERS
+#      define Q_COMPILER_DEFAULT_MEMBERS
+#      define Q_COMPILER_DELETE_MEMBERS
 #      define Q_COMPILER_EXTERN_TEMPLATES
 #      define Q_COMPILER_LAMBDA
 #      define Q_COMPILER_RVALUE_REFS
 #    if __has_feature(cxx_decltype) /* && __has_feature(cxx_decltype_incomplete_return_types) */
 #      define Q_COMPILER_DECLTYPE
 #    endif
-#    if __has_feature(cxx_defaulted_functions) && __has_feature(cxx_deleted_functions) /* defaulted members in 3.0, deleted members in 2.9 */
-#      define Q_COMPILER_DEFAULT_DELETE_MEMBERS
+#    if __has_feature(cxx_defaulted_functions)
+#      define Q_COMPILER_DEFAULT_MEMBERS
+#    endif
+#    if __has_feature(cxx_deleted_functions)
+#      define Q_COMPILER_DELETE_MEMBERS
 #    endif
 #    if __has_feature(cxx_delegating_constructors)
 #      define Q_COMPILER_DELEGATING_CONSTRUCTORS
 #      define Q_COMPILER_AUTO_FUNCTION
 #      define Q_COMPILER_AUTO_TYPE
 #      define Q_COMPILER_CLASS_ENUM
-#      define Q_COMPILER_DEFAULT_DELETE_MEMBERS
+#      define Q_COMPILER_DEFAULT_MEMBERS
+#      define Q_COMPILER_DELETE_MEMBERS
 #      define Q_COMPILER_EXTERN_TEMPLATES
 #      define Q_COMPILER_INITIALIZER_LISTS
 #      define Q_COMPILER_UNICODE_STRINGS
 # define Q_NULLPTR         0
 #endif
 
-#ifdef Q_COMPILER_DEFAULT_DELETE_MEMBERS
+#ifdef Q_COMPILER_DEFAULT_MEMBERS
+#  define Q_DECL_EQ_DEFAULT = default
+#else
+#  define Q_DECL_EQ_DEFAULT
+#endif
+
+#ifdef Q_COMPILER_DELETE_MEMBERS
 # define Q_DECL_EQ_DELETE = delete
 #else
 # define Q_DECL_EQ_DELETE
 #endif
 
+// Don't break code that is already using Q_COMPILER_DEFAULT_DELETE_MEMBERS
+#if defined(Q_COMPILER_DEFAULT_MEMBERS) && defined(Q_COMPILER_DELETE_MEMBERS)
+#  define Q_COMPILER_DEFAULT_DELETE_MEMBERS
+#endif
+
 #ifdef Q_COMPILER_CONSTEXPR
 # define Q_DECL_CONSTEXPR constexpr
 #else
index dd11ca8..5aebb03 100644 (file)
@@ -179,7 +179,7 @@ public:
     T fetchAndAddOrdered(T valueToAdd)
     { return Ops::fetchAndAddOrdered(_q_value, valueToAdd); }
 
-#if defined(Q_COMPILER_CONSTEXPR) && defined(Q_COMPILER_DEFAULT_DELETE_MEMBERS)
+#if defined(Q_COMPILER_CONSTEXPR) && defined(Q_COMPILER_DEFAULT_MEMBERS) && defined(Q_COMPILER_DELETE_MEMBERS)
     QBasicAtomicInteger() = default;
     constexpr QBasicAtomicInteger(T value) : _q_value(value) {}
     QBasicAtomicInteger(const QBasicAtomicInteger &) = delete;
@@ -243,7 +243,7 @@ public:
     Type fetchAndAddOrdered(qptrdiff valueToAdd)
     { return Ops::fetchAndAddOrdered(_q_value, valueToAdd); }
 
-#if defined(Q_COMPILER_CONSTEXPR) && defined(Q_COMPILER_DEFAULT_DELETE_MEMBERS)
+#if defined(Q_COMPILER_CONSTEXPR) && defined(Q_COMPILER_DEFAULT_MEMBERS) && defined(Q_COMPILER_DELETE_MEMBERS)
     QBasicAtomicPointer() = default;
     constexpr QBasicAtomicPointer(Type value) : _q_value(value) {}
     QBasicAtomicPointer(const QBasicAtomicPointer &) = delete;