[gcc/devel/omp/gcc-9] Define __cpp_lib_endian feature test macro
Tobias Burnus
burnus@gcc.gnu.org
Thu Mar 5 14:12:00 GMT 2020
https://gcc.gnu.org/g:996a7c88b45baf6083ed490be985551c5647cfbf
commit 996a7c88b45baf6083ed490be985551c5647cfbf
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Jul 26 14:37:00 2019 +0100
Define __cpp_lib_endian feature test macro
This macro was added as part of moving std::endian from <type_traits> to
<bit>.
Backport from mainline
2019-07-26 Jonathan Wakely <jwakely@redhat.com>
* include/std/bit (__cpp_lib_endian): Define.
* include/std/version (__cpp_lib_endian): Define.
* testsuite/26_numerics/endian/2.cc: New.
* testsuite/26_numerics/endian/3.cc: New.
* testsuite/26_numerics/endian/4.cc: New.
From-SVN: r273838
Diff:
---
libstdc++-v3/ChangeLog | 11 +++++++++++
libstdc++-v3/include/std/bit | 2 ++
libstdc++-v3/include/std/version | 1 +
libstdc++-v3/testsuite/26_numerics/endian/2.cc | 27 ++++++++++++++++++++++++++
libstdc++-v3/testsuite/26_numerics/endian/3.cc | 27 ++++++++++++++++++++++++++
libstdc++-v3/testsuite/26_numerics/endian/4.cc | 25 ++++++++++++++++++++++++
6 files changed, 93 insertions(+)
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 68490bf..be5d990 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,6 +1,17 @@
2019-07-26 Jonathan Wakely <jwakely@redhat.com>
Backport from mainline
+ 2019-07-26 Jonathan Wakely <jwakely@redhat.com>
+
+ * include/std/bit (__cpp_lib_endian): Define.
+ * include/std/version (__cpp_lib_endian): Define.
+ * testsuite/26_numerics/endian/2.cc: New.
+ * testsuite/26_numerics/endian/3.cc: New.
+ * testsuite/26_numerics/endian/4.cc: New.
+
+2019-07-26 Jonathan Wakely <jwakely@redhat.com>
+
+ Backport from mainline
2019-07-25 Jonathan Wakely <jwakely@redhat.com>
* include/std/bit (endian): Move definition here as per P1612R1.
diff --git a/libstdc++-v3/include/std/bit b/libstdc++-v3/include/std/bit
index 4331255..c753e39 100644
--- a/libstdc++-v3/include/std/bit
+++ b/libstdc++-v3/include/std/bit
@@ -325,6 +325,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
log2p1(_Tp __x) noexcept
{ return std::__log2p1(__x); }
+#define __cpp_lib_endian 201907L
+
/// Byte order
enum class endian
{
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index f42d740..a513e09 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -154,6 +154,7 @@
#if __cpp_impl_destroying_delete
# define __cpp_lib_destroying_delete 201806L
#endif
+#define __cpp_lib_endian 201907L
#define __cpp_lib_erase_if 201900L
#define __cpp_lib_interpolate 201902L
#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
diff --git a/libstdc++-v3/testsuite/26_numerics/endian/2.cc b/libstdc++-v3/testsuite/26_numerics/endian/2.cc
new file mode 100644
index 0000000..474bae4
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/endian/2.cc
@@ -0,0 +1,27 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <bit>
+
+#ifndef __cpp_lib_endian
+# error "Feature-test macro for endian missing in <bit>"
+#elif __cpp_lib_endian != 201907L
+# error "Feature-test macro for endian has wrong value in <bit>"
+#endif
diff --git a/libstdc++-v3/testsuite/26_numerics/endian/3.cc b/libstdc++-v3/testsuite/26_numerics/endian/3.cc
new file mode 100644
index 0000000..a7af53d
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/endian/3.cc
@@ -0,0 +1,27 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <version>
+
+#ifndef __cpp_lib_endian
+# error "Feature-test macro for endian missing in <version>"
+#elif __cpp_lib_endian != 201907L
+# error "Feature-test macro for endian has wrong value in <version>"
+#endif
diff --git a/libstdc++-v3/testsuite/26_numerics/endian/4.cc b/libstdc++-v3/testsuite/26_numerics/endian/4.cc
new file mode 100644
index 0000000..93bed38
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/endian/4.cc
@@ -0,0 +1,25 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile { target c++17_down } }
+
+#include <bit>
+#include <version>
+
+#ifdef __cpp_lib_endian
+# error "Feature-test macro for endian defined before C++20"
+#endif
More information about the Libstdc++-cvs
mailing list