Fix build on gcc < 5 (std::is_trivially_copyable missing)
authorPedro Alves <palves@redhat.com>
Tue, 25 Apr 2017 09:58:57 +0000 (10:58 +0100)
committerPedro Alves <palves@redhat.com>
Tue, 25 Apr 2017 09:58:57 +0000 (10:58 +0100)
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.

gdb/ChangeLog
gdb/common/poison.h
gdb/common/traits.h

index 26e6370a375ef71b750f67a626cbebafdc7bb0c2..d1c1942adbbb98b680896bc6210e608e97749dbf 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2017-04-25  Pedro Alves  <palves@redhat.com>
 
        * common/common-defs.h: Include "common/poison.h".
index a875568d97c83e2dbc9b850ee9cdcf728190876a..37dd35e4b16abe4c7f89e3a52bbe2af4669c6513 100644 (file)
@@ -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 */
index 4f7161bdec424abcb973c47cb47f3df5c182e484..8c41b032f40e50c5877de8539d8449aa75f6638f 100644 (file)
 
 #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
This page took 0.027212 seconds and 4 git commands to generate.