public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r8-10849] libstdc++: Fix errors from Library Fundamentals TS headers in C++11 [PR 98319]
Date: Mon, 19 Apr 2021 09:38:49 +0000 (GMT)	[thread overview]
Message-ID: <20210419093849.CE9B83958C21@sourceware.org> (raw)

https://gcc.gnu.org/g:c79725c7b21838e89105381ceff5af05b3609d21

commit r8-10849-gc79725c7b21838e89105381ceff5af05b3609d21
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Dec 16 13:37:17 2020 +0000

    libstdc++: Fix errors from Library Fundamentals TS headers in C++11 [PR 98319]
    
    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/memory_resource: Add system_header pragma
            and only define contents for C++14 and later.
            * 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.
    
    (cherry picked from commit ab9bd93271061f436c10e35e261ecb73e2108ccc)

Diff:
---
 libstdc++-v3/include/experimental/memory_resource  |  8 +-
 libstdc++-v3/include/experimental/random           |  4 +-
 libstdc++-v3/include/experimental/source_location  |  4 +-
 libstdc++-v3/include/experimental/utility          |  4 +-
 .../testsuite/experimental/feat-lib-fund.cc        | 93 +++++++++-------------
 5 files changed, 51 insertions(+), 62 deletions(-)

diff --git a/libstdc++-v3/include/experimental/memory_resource b/libstdc++-v3/include/experimental/memory_resource
index 23653ee2fe8..29e53930a39 100644
--- a/libstdc++-v3/include/experimental/memory_resource
+++ b/libstdc++-v3/include/experimental/memory_resource
@@ -29,6 +29,10 @@
 #ifndef _GLIBCXX_EXPERIMENTAL_MEMORY_RESOURCE
 #define _GLIBCXX_EXPERIMENTAL_MEMORY_RESOURCE 1
 
+#pragma GCC system_header
+
+#if __cplusplus >= 201402L
+
 #include <memory>
 #include <new>
 #include <atomic>
@@ -403,5 +407,5 @@ namespace pmr {
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
-
-#endif
+#endif // C++14
+#endif // _GLIBCXX_EXPERIMENTAL_MEMORY_RESOURCE
diff --git a/libstdc++-v3/include/experimental/random b/libstdc++-v3/include/experimental/random
index deb7bd6b75c..a26b5f6cdce 100644
--- a/libstdc++-v3/include/experimental/random
+++ b/libstdc++-v3/include/experimental/random
@@ -29,6 +29,7 @@
 #ifndef _GLIBCXX_EXPERIMENTAL_RANDOM
 #define _GLIBCXX_EXPERIMENTAL_RANDOM 1
 
+#if __cplusplus >= 201402L
 #include <random>
 #include <experimental/bits/lfts_config.h>
 
@@ -77,4 +78,5 @@ inline namespace fundamentals_v2 {
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 
-#endif
+#endif // C++14
+#endif // _GLIBCXX_EXPERIMENTAL_RANDOM
diff --git a/libstdc++-v3/include/experimental/source_location b/libstdc++-v3/include/experimental/source_location
index 389eb816be1..988d23e12db 100644
--- a/libstdc++-v3/include/experimental/source_location
+++ b/libstdc++-v3/include/experimental/source_location
@@ -29,6 +29,7 @@
 #ifndef _GLIBCXX_EXPERIMENTAL_SRCLOC
 #define _GLIBCXX_EXPERIMENTAL_SRCLOC 1
 
+#if __cplusplus >= 201402L
 #include <cstdint>
 
 namespace std {
@@ -83,4 +84,5 @@ inline namespace fundamentals_v2 {
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 
-#endif
+#endif // C++14
+#endif // _GLIBCXX_EXPERIMENTAL_SRCLOC
diff --git a/libstdc++-v3/include/experimental/utility b/libstdc++-v3/include/experimental/utility
index 7e367196744..de3fe84a41b 100644
--- a/libstdc++-v3/include/experimental/utility
+++ b/libstdc++-v3/include/experimental/utility
@@ -29,6 +29,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>
@@ -46,4 +47,5 @@ inline namespace fundamentals_v2 {
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 
-#endif
+#endif // C++14
+#endif // _GLIBCXX_EXPERIMENTAL_UTILITY
diff --git a/libstdc++-v3/testsuite/experimental/feat-lib-fund.cc b/libstdc++-v3/testsuite/experimental/feat-lib-fund.cc
index b0e6e289009..342edc5352d 100644
--- a/libstdc++-v3/testsuite/experimental/feat-lib-fund.cc
+++ b/libstdc++-v3/testsuite/experimental/feat-lib-fund.cc
@@ -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>


                 reply	other threads:[~2021-04-19  9:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210419093849.CE9B83958C21@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).