aboutsummaryrefslogtreecommitdiff
path: root/gdb/common
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-04-25 10:58:57 +0100
committerPedro Alves <palves@redhat.com>2017-04-25 10:58:57 +0100
commitdebed3db4887483552103da36d180967ef0dca5f (patch)
treedab7562353f25938ba0a48f6cb82aa8195fd5279 /gdb/common
parentd28b6364b1fba1c0270c001f0d82a69e351e1922 (diff)
downloadgdb-debed3db4887483552103da36d180967ef0dca5f.zip
gdb-debed3db4887483552103da36d180967ef0dca5f.tar.gz
gdb-debed3db4887483552103da36d180967ef0dca5f.tar.bz2
Fix build on gcc < 5 (std::is_trivially_copyable missing)
Ref: https://sourceware.org/ml/gdb-patches/2017-04/msg00660.html Simply skip the poisoning on older compilers. gdb/ChangeLog: 2017-04-25 Pedro Alves <palves@redhat.com> * common/poison.h [!HAVE_IS_TRIVIALLY_COPYABLE] (IsRelocatable) (BothAreRelocatable, memcopy, memmove): Don't define. * common/traits.h (__has_feature, HAVE_IS_TRIVIALLY_COPYABLE): New macros.
Diffstat (limited to 'gdb/common')
-rw-r--r--gdb/common/poison.h4
-rw-r--r--gdb/common/traits.h13
2 files changed, 17 insertions, 0 deletions
diff --git a/gdb/common/poison.h b/gdb/common/poison.h
index a875568..37dd35e 100644
--- a/gdb/common/poison.h
+++ b/gdb/common/poison.h
@@ -55,6 +55,8 @@ template <typename T,
typename = gdb::Requires<gdb::Not<IsMemsettable<T>>>>
void *memset (T *s, int c, size_t n) = delete;
+#if HAVE_IS_TRIVIALLY_COPYABLE
+
/* Similarly, poison memcpy and memmove of non trivially-copyable
types, which is undefined. */
@@ -80,4 +82,6 @@ template <typename D, typename S,
typename = gdb::Requires<gdb::Not<BothAreRelocatable<D, S>>>>
void *memmove (D *dest, const S *src, size_t n) = delete;
+#endif /* HAVE_IS_TRIVIALLY_COPYABLE */
+
#endif /* COMMON_POISON_H */
diff --git a/gdb/common/traits.h b/gdb/common/traits.h
index 4f7161b..8c41b03 100644
--- a/gdb/common/traits.h
+++ b/gdb/common/traits.h
@@ -20,6 +20,19 @@
#include <type_traits>
+/* GCC does not understand __has_feature. */
+#if !defined(__has_feature)
+# define __has_feature(x) 0
+#endif
+
+/* HAVE_IS_TRIVIALLY_COPYABLE is defined as 1 iff
+ std::is_trivially_copyable is available. GCC only implemented it
+ in GCC 5. */
+#if (__has_feature(is_trivially_copyable) \
+ || (defined __GNUC__ && __GNUC__ >= 5))
+# define HAVE_IS_TRIVIALLY_COPYABLE 1
+#endif
+
namespace gdb {
/* Pre C++14-safe (CWG 1558) version of C++17's std::void_t. See