Don't unconditionally define feature test macros in <version>
authorJonathan Wakely <jwakely@redhat.com>
Tue, 31 Jul 2018 22:31:14 +0000 (23:31 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 31 Jul 2018 22:31:14 +0000 (23:31 +0100)
commitff273400466f44c64a19b917151641706318c268
tree7aca7e266e60c46d792cca9f1a6d266a14f9a630
parentb348c78aa4ab72ea533a01ad24311f45b0b4f4cb
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
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/c++config
libstdc++-v3/include/std/type_traits
libstdc++-v3/include/std/version
libstdc++-v3/libsupc++/new