Skip to content

Commit 0e7f4d0

Browse files
committed
type_traits: fix build with GCC
GCC 5 introduced __is_trivially_copyable for implementing std::is_trivially_copyable. However, gcc does not report it through __has_feature. Perform a version check instead. Repairs the build with GCC.
1 parent 2b091f8 commit 0e7f4d0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/swift/Basic/type_traits.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct IsTriviallyCopyable {
3333
#if _LIBCPP_VERSION || SWIFT_COMPILER_IS_MSVC
3434
// libc++ and MSVC implement is_trivially_copyable.
3535
static const bool value = std::is_trivially_copyable<T>::value;
36-
#elif __has_feature(is_trivially_copyable)
36+
#elif __has_feature(is_trivially_copyable) || __GNUC__ >= 5
3737
static const bool value = __is_trivially_copyable(T);
3838
#else
3939
# error "Not implemented"
@@ -45,7 +45,7 @@ struct IsTriviallyConstructible {
4545
#if _LIBCPP_VERSION || SWIFT_COMPILER_IS_MSVC
4646
// libc++ and MSVC implement is_trivially_constructible.
4747
static const bool value = std::is_trivially_constructible<T>::value;
48-
#elif __has_feature(has_trivial_constructor)
48+
#elif __has_feature(has_trivial_constructor) || __GNUC__ >= 5
4949
static const bool value = __has_trivial_constructor(T);
5050
#else
5151
# error "Not implemented"
@@ -57,7 +57,7 @@ struct IsTriviallyDestructible {
5757
#if _LIBCPP_VERSION || SWIFT_COMPILER_IS_MSVC
5858
// libc++ and MSVC implement is_trivially_destructible.
5959
static const bool value = std::is_trivially_destructible<T>::value;
60-
#elif __has_feature(has_trivial_destructor)
60+
#elif __has_feature(has_trivial_destructor) || __GNUC__ >= 5
6161
static const bool value = __has_trivial_destructor(T);
6262
#else
6363
# error "Not implemented"

0 commit comments

Comments
 (0)