aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2018-07-31 23:31:14 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2018-07-31 23:31:14 +0100
commitff273400466f44c64a19b917151641706318c268 (patch)
tree7aca7e266e60c46d792cca9f1a6d266a14f9a630
parentb348c78aa4ab72ea533a01ad24311f45b0b4f4cb (diff)
downloadgcc-ff273400466f44c64a19b917151641706318c268.zip
gcc-ff273400466f44c64a19b917151641706318c268.tar.gz
gcc-ff273400466f44c64a19b917151641706318c268.tar.bz2
Don't unconditionally define feature test macros in <version>
The macro definitions in <version> should depend on the same preprocessor conditions as the original macros in other headers. Otherwise <version> can define macros that imply the availability of features that are not actually defined. This fix is incomplete, as __cpp_lib_filesystem should depend on whether libstdc++fs.a is supported, and several macros should only be defined when _GLIBCXX_HOSTED is defined. Also, the feature test macros should define their value as type long, but most are type int. * include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP) (_GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE): Move definitions here. (_GLIBCXX_HAVE_BUILTIN_LAUNDER): Likewise. Use !__is_identifier instead of __has_builtin. * include/std/type_traits (_GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP) (_GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE): Remove definitions from here. * include/std/version [!_GLIBCXX_HAS_GTHREADS] (__cpp_lib_shared_timed_mutex, __cpp_lib_scoped_lock) (__cpp_lib_shared_mutex): Don't define when Gthreads not in use. [!_GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP] (__cpp_lib_has_unique_object_representations): Don't define when builtin not available. [!_GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE] (__cpp_lib_is_aggregate): Likewise. [!_GLIBCXX_HAVE_BUILTIN_LAUNDER] (__cpp_lib_launder): Likewise. * libsupc++/new (_GLIBCXX_HAVE_BUILTIN_LAUNDER): Remove definition from here. From-SVN: r263184
-rw-r--r--libstdc++-v3/ChangeLog18
-rw-r--r--libstdc++-v3/include/bits/c++config18
-rw-r--r--libstdc++-v3/include/std/type_traits23
-rw-r--r--libstdc++-v3/include/std/version22
-rw-r--r--libstdc++-v3/libsupc++/new10
5 files changed, 53 insertions, 38 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index f2f7676..b29778a 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,23 @@
2018-07-31 Jonathan Wakely <jwakely@redhat.com>
+ * include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP)
+ (_GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE): Move definitions here.
+ (_GLIBCXX_HAVE_BUILTIN_LAUNDER): Likewise. Use !__is_identifier
+ instead of __has_builtin.
+ * include/std/type_traits (_GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP)
+ (_GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE): Remove definitions from here.
+ * include/std/version [!_GLIBCXX_HAS_GTHREADS]
+ (__cpp_lib_shared_timed_mutex, __cpp_lib_scoped_lock)
+ (__cpp_lib_shared_mutex): Don't define when Gthreads not in use.
+ [!_GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP]
+ (__cpp_lib_has_unique_object_representations): Don't define when
+ builtin not available.
+ [!_GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE] (__cpp_lib_is_aggregate):
+ Likewise.
+ [!_GLIBCXX_HAVE_BUILTIN_LAUNDER] (__cpp_lib_launder): Likewise.
+ * libsupc++/new (_GLIBCXX_HAVE_BUILTIN_LAUNDER): Remove definition
+ from here.
+
* doc/xml/manual/test.xml: Improve documentation on writing tests for
newer standards.
* doc/xml/manual/using.xml: Document all headers for C++11 and later.
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index c0b89f4..d499d32 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -622,4 +622,22 @@ namespace std
#define _GLIBCXX_USE_FLOAT128
#endif
+#if __GNUC__ >= 7
+// Assume these are available if the compiler claims to be a recent GCC:
+# define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
+# define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
+# define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
+#elif defined(__is_identifier)
+// For non-GNU compilers:
+# if ! __is_identifier(__has_unique_object_representations)
+# define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
+# endif
+# if ! __is_identifier(__is_aggregate)
+# define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
+# endif
+# if ! __is_identifier(__builtin_launder)
+# define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
+# endif
+#endif // GCC
+
// End of prewritten config; the settings discovered at configure time follow.
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index aaa554c..4f89723 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -2956,15 +2956,6 @@ template <typename _Base, typename _Derived>
template <typename _From, typename _To>
inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
-#if __GNUC__ >= 7
-# define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
-#elif defined(__is_identifier)
-// For non-GNU compilers:
-# if ! __is_identifier(__has_unique_object_representations)
-# define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
-# endif
-#endif
-
#ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
# define __cpp_lib_has_unique_object_representations 201606
/// has_unique_object_representations
@@ -2979,19 +2970,9 @@ template <typename _From, typename _To>
inline constexpr bool has_unique_object_representations_v
= has_unique_object_representations<_Tp>::value;
#endif
-#undef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
-
-#if __GNUC__ >= 7
-# define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
-#elif defined(__is_identifier)
-// For non-GNU compilers:
-# if ! __is_identifier(__is_aggregate)
-# define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
-# endif
-#endif
#ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE
-#define __cpp_lib_is_aggregate 201703
+# define __cpp_lib_is_aggregate 201703
/// is_aggregate
template<typename _Tp>
struct is_aggregate
@@ -3001,8 +2982,6 @@ template <typename _From, typename _To>
template<typename _Tp>
inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value;
#endif
-#undef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE
-
#endif // C++17
#if __cplusplus > 201703L
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index 0c26d9b6..0e054c4 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -73,7 +73,9 @@
#define __cpp_lib_make_unique 201304
#define __cpp_lib_quoted_string_io 201304
#define __cpp_lib_robust_nonmodifying_seq_ops 201304
-#define __cpp_lib_shared_timed_mutex 201402
+#ifdef _GLIBCXX_HAS_GTHREADS
+# define __cpp_lib_shared_timed_mutex 201402
+#endif
#define __cpp_lib_string_udls 201304
#define __cpp_lib_transformation_trait_aliases 201304
#define __cpp_lib_transparent_operators 201510
@@ -97,13 +99,19 @@
#define __cpp_lib_filesystem 201703
#define __cpp_lib_gcd 201606
#define __cpp_lib_gcd_lcm 201606
-#define __cpp_lib_has_unique_object_representations 201606
+#ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
+# define __cpp_lib_has_unique_object_representations 201606
+#endif
#define __cpp_lib_hypot 201603
#define __cpp_lib_invoke 201411
-#define __cpp_lib_is_aggregate 201703
+#ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE
+# define __cpp_lib_is_aggregate 201703
+#endif
#define __cpp_lib_is_invocable 201703
#define __cpp_lib_is_swappable 201603
-#define __cpp_lib_launder 201606
+#ifdef _GLIBCXX_HAVE_BUILTIN_LAUNDER
+# define __cpp_lib_launder 201606
+#endif
#define __cpp_lib_lcm 201606
#define __cpp_lib_logical_traits 201510
#define __cpp_lib_make_from_tuple 201606
@@ -115,8 +123,10 @@
#define __cpp_lib_not_fn 201603
#define __cpp_lib_optional 201603
#define __cpp_lib_sample 201603
-#define __cpp_lib_scoped_lock 201703
-#define __cpp_lib_shared_mutex 201505
+#ifdef _GLIBCXX_HAS_GTHREADS
+# define __cpp_lib_scoped_lock 201703
+# define __cpp_lib_shared_mutex 201505
+#endif
#define __cpp_lib_shared_ptr_weak_type 201606
#define __cpp_lib_string_view 201603
#define __cpp_lib_type_trait_variable_templates 201510L
diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new
index 73483c8..82d884d 100644
--- a/libstdc++-v3/libsupc++/new
+++ b/libstdc++-v3/libsupc++/new
@@ -182,15 +182,6 @@ inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { }
} // extern "C++"
#if __cplusplus >= 201703L
-#if __GNUC__ >= 7
-# define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
-#elif defined __has_builtin
-// For non-GNU compilers:
-# if __has_builtin(__builtin_launder)
-# define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
-# endif
-#endif
-
#ifdef _GLIBCXX_HAVE_BUILTIN_LAUNDER
namespace std
{
@@ -215,7 +206,6 @@ namespace std
void launder(const volatile void*) = delete;
}
#endif // _GLIBCXX_HAVE_BUILTIN_LAUNDER
-#undef _GLIBCXX_HAVE_BUILTIN_LAUNDER
#endif // C++17
#pragma GCC visibility pop