libstdc++: Fix errors from Library Fundamentals TS headers in C++11 [PR 98319]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 16 Dec 2020 13:37:17 +0000 (13:37 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 16 Dec 2020 13:37:17 +0000 (13:37 +0000)
Currently the <experimental/random>, <experimental/source_location> and
<experimental/utility> headers can be included in C++98 and C++11 modes,
but gives errors. With this change they can be included, but define
nothing.

libstdc++-v3/ChangeLog:

PR libstdc++/98319
* include/experimental/random: Only define contents for C++14
and later.
* include/experimental/source_location: Likewise.
* include/experimental/utility: Likewise.
* testsuite/experimental/feat-lib-fund.cc: Include all LFTS
headers that are present. Allow test to run for all modes.

libstdc++-v3/include/experimental/random
libstdc++-v3/include/experimental/source_location
libstdc++-v3/include/experimental/utility
libstdc++-v3/testsuite/experimental/feat-lib-fund.cc

index 2ec1a4b7e42d6fa26540882f028df91c6ca48265..4165a8520c8c5e72f7e92adf366658b473bfb598 100644 (file)
@@ -30,6 +30,7 @@
 #ifndef _GLIBCXX_EXPERIMENTAL_RANDOM
 #define _GLIBCXX_EXPERIMENTAL_RANDOM 1
 
+#if __cplusplus >= 201402L
 #include <random>
 #include <experimental/bits/lfts_config.h>
 
@@ -78,4 +79,5 @@ inline namespace fundamentals_v2 {
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 
-#endif
+#endif // C++14
+#endif // _GLIBCXX_EXPERIMENTAL_RANDOM
index 9d5b5eae5f3c00fe03a73d3c1b454dbd1bfb4bc6..b4f00f1c0392b0763b8aa0ad5543f1df7fb13adc 100644 (file)
@@ -30,6 +30,7 @@
 #ifndef _GLIBCXX_EXPERIMENTAL_SRCLOC
 #define _GLIBCXX_EXPERIMENTAL_SRCLOC 1
 
+#if __cplusplus >= 201402L
 #include <cstdint>
 
 namespace std {
@@ -84,4 +85,5 @@ inline namespace fundamentals_v2 {
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 
-#endif
+#endif // C++14
+#endif // _GLIBCXX_EXPERIMENTAL_SRCLOC
index f0c3b4fcd909c3cf37685f29501024741c4a46bf..8abf55c052672fcf95209966a85aed4c4966920e 100644 (file)
@@ -30,6 +30,7 @@
 #ifndef _GLIBCXX_EXPERIMENTAL_UTILITY
 #define _GLIBCXX_EXPERIMENTAL_UTILITY 1
 
+#if __cplusplus >= 201402L
 #include <utility>
 #include <bits/uses_allocator.h>
 #include <experimental/bits/lfts_config.h>
@@ -47,4 +48,5 @@ inline namespace fundamentals_v2 {
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 
-#endif
+#endif // C++14
+#endif // _GLIBCXX_EXPERIMENTAL_UTILITY
index b0e6e289009cc8d08aedc6fc936acdf14f099380..342edc5352d89527f6a4d49341c3ded4e407c5b5 100644 (file)
@@ -1,57 +1,36 @@
-// { dg-do preprocess { target c++14 } }
-
-#if !__has_include(<experimental/tuple>)
-#  error "<experimental/tuple>"
-#endif
-
-#if !__has_include(<experimental/type_traits>)
-#  error "<experimental/type_traits>"
-#endif
-
-#if !__has_include(<experimental/ratio>)
-#  error "<experimental/ratio>"
-#endif
-
-#if !__has_include(<experimental/chrono>)
-#  error "<experimental/chrono>"
-#endif
-
-#if !__has_include(<experimental/system_error>)
-#  error "<experimental/system_error>"
-#endif
-
-#if !__has_include(<experimental/functional>)
-#  error "<experimental/functional>"
-#endif
-
-#if !__has_include(<experimental/optional>)
-#  error "<experimental/optional>"
-#endif
-
-#if !__has_include(<experimental/any>)
-#  error "<experimental/any>"
-#endif
-
-#if !__has_include(<experimental/string_view>)
-#  error "<experimental/string_view>"
-#endif
-
-//#if !__has_include(<experimental/memory>)
-//#  error "<experimental/memory>"
-//#endif
-
-//#if !__has_include(<experimental/memory_resource>)
-//#  error "<experimental/memory_resource>"
-//#endif
-
-//#if !__has_include(<experimental/future>)
-//#  error "<experimental/future>"
-//#endif
-
-#if !__has_include(<experimental/algorithm>)
-#  error "<experimental/algorithm>"
-#endif
-
-//#if !__has_include(<experimental/net>)
-//#  error "<experimental/net>"
-//#endif
+// { dg-do preprocess }
+
+// Include all the LFTS headers. This should work with any -std flag.
+
+#include <experimental/algorithm>
+#include <experimental/any>
+#include <experimental/array>
+#include <experimental/chrono>
+#include <experimental/deque>
+#include <experimental/forward_list>
+#include <experimental/functional>
+#if __has_include(<experimental/future>) // not supported as of GCC 11
+# include <experimental/future>
+#endif
+#include <experimental/iterator>
+#include <experimental/list>
+#include <experimental/map>
+#include <experimental/memory>
+#include <experimental/memory_resource>
+#include <experimental/numeric>
+#include <experimental/optional>
+#include <experimental/propagate_const>
+#include <experimental/random>
+#include <experimental/ratio>
+#include <experimental/regex>
+#include <experimental/set>
+#include <experimental/source_location>
+#include <experimental/string>
+#include <experimental/string_view>
+#include <experimental/system_error>
+#include <experimental/tuple>
+#include <experimental/type_traits>
+#include <experimental/unordered_map>
+#include <experimental/unordered_set>
+#include <experimental/utility>
+#include <experimental/vector>