summaryrefslogtreecommitdiffstats
path: root/libcxx
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2015-06-13 06:27:17 +0000
committerEric Fiselier <eric@efcs.ca>2015-06-13 06:27:17 +0000
commitf8177546272a1919798f24d0fa46002175e3af6f (patch)
treeb8b3953bf0f7309cb964f4dbdfab1aec1902011f /libcxx
parent104ad064df78d047008b0079aed419d1bfd8aa8a (diff)
downloadbcm5719-llvm-f8177546272a1919798f24d0fa46002175e3af6f.tar.gz
bcm5719-llvm-f8177546272a1919798f24d0fa46002175e3af6f.zip
[libcxx] Use __decltype instead of __typeof__
Summary: Both clang and GCC provide C++11 decltype semantics as __decltype in c++03 mode. We should use this instead of __typeof__ when availble. GCC added __decltype in 4.6.0, and AFAIK clang provided __decltype ever since 3.3. Unfortunately `__has_builtin(__decltype)` doesn't work for clang so we need to check the compiler version instead. Reviewers: mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D10426 llvm-svn: 239662
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/include/__config17
1 files changed, 16 insertions, 1 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 79f34e444b6..00efda22ee4 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -577,7 +577,22 @@ template <unsigned> struct __static_assert_check {};
#endif // _LIBCPP_HAS_NO_STATIC_ASSERT
#ifdef _LIBCPP_HAS_NO_DECLTYPE
-#define decltype(x) __typeof__(x)
+# if defined(__clang__)
+# define _CLANG_VER (__clang_major__ * 100 + __clang_minor__)
+# else
+# define _CLANG_VER 0
+# endif
+// Clang 3.0 and GCC 4.6 provide __decltype in all standard modes.
+// XCode 5.0 is based off of Clang 3.3 SVN. We require Clang 3.3
+// be sure we have __decltype.
+#if (defined(__apple_build_version__) && _CLANG_VER >= 500) || \
+ (!defined(__apple_build_version__) && _CLANG_VER >= 303) || \
+ _GNUC_VER >= 406
+# define decltype(__x) __decltype(__x)
+#else
+# define decltype(__x) __typeof__(__x)
+#endif
+#undef _CLANG_VER
#endif
#ifdef _LIBCPP_HAS_NO_CONSTEXPR
OpenPOWER on IntegriCloud