Skip to content

Commit 014d949

Browse files
committed
Manually force the use of __decltype in C++03 with Clang 3.4.
<string> uses `decltype` in a way incompatible with `__typeof__`. This is problematic when compiling <string> with Clang 3.4 because even though it provides `__decltype` libc++ still used `__typeof__` because clang 3.4 doesn't provide __is_identifier which libc++ uses to detect __decltype. This patch manually detects Clang 3.4 and properly configures for it. llvm-svn: 292833
1 parent 5363be7 commit 014d949

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

libcxx/include/__config

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@
109109

110110
#if defined(__clang__)
111111
#define _LIBCPP_COMPILER_CLANG
112+
# ifndef __apple_build_version__
113+
# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
114+
# endif
112115
#elif defined(__GNUC__)
113116
#define _LIBCPP_COMPILER_GCC
114117
#elif defined(_MSC_VER)
@@ -117,6 +120,10 @@
117120
#define _LIBCPP_COMPILER_IBM
118121
#endif
119122

123+
#ifndef _LIBCPP_CLANG_VER
124+
#define _LIBCPP_CLANG_VER 0
125+
#endif
126+
120127
// FIXME: ABI detection should be done via compiler builtin macros. This
121128
// is just a placeholder until Clang implements such macros. For now assume
122129
// that Windows compilers pretending to be MSVC++ target the microsoft ABI.
@@ -754,7 +761,7 @@ template <unsigned> struct __static_assert_check {};
754761

755762
#ifdef _LIBCPP_HAS_NO_DECLTYPE
756763
// GCC 4.6 provides __decltype in all standard modes.
757-
#if __has_keyword(__decltype) || _GNUC_VER >= 406
764+
#if __has_keyword(__decltype) || _LIBCPP_CLANG_VER >= 304 || _GNUC_VER >= 406
758765
# define decltype(__x) __decltype(__x)
759766
#else
760767
# define decltype(__x) __typeof__(__x)

0 commit comments

Comments
 (0)