public inbox for libstdc++-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 r11-9277] libstdc++: Fix test for libstdc++ not including <unistd.h> [PR100117]
Date: Wed, 24 Nov 2021 11:50:16 +0000 (GMT)	[thread overview]
Message-ID: <20211124115016.85E5D3857C75@sourceware.org> (raw)

https://gcc.gnu.org/g:176e55cc28a61b7b246bd9e16ffeaa31367a8985

commit r11-9277-g176e55cc28a61b7b246bd9e16ffeaa31367a8985
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Nov 10 11:43:46 2021 +0000

    libstdc++: Fix test for libstdc++ not including <unistd.h> [PR100117]
    
    The <cxxx> headers for the C library are not under our control, so we
    can't prevent them from including <unistd.h>. Change the PR 49745 test
    to only include the C++ library headers, not the <cxxx> ones.
    
    To ensure <bits/stdc++.h> isn't included automatically we need to use
    no_pch to disable PCH.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/100117
            * testsuite/17_intro/headers/c++1998/49745.cc: Explicitly list
            all C++ headers instead of including <bits/stdc++.h>
    
    (cherry picked from commit 77963796aef8aa07993c0bc757c15848fab7432a)

Diff:
---
 .../testsuite/17_intro/headers/c++1998/49745.cc    | 113 ++++++++++++++++++++-
 1 file changed, 112 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++1998/49745.cc b/libstdc++-v3/testsuite/17_intro/headers/c++1998/49745.cc
index 204975e0316..f98fa3b4fb9 100644
--- a/libstdc++-v3/testsuite/17_intro/headers/c++1998/49745.cc
+++ b/libstdc++-v3/testsuite/17_intro/headers/c++1998/49745.cc
@@ -1,4 +1,5 @@
 // { dg-do compile { target *-*-linux* *-*-gnu* } }
+// { dg-add-options no_pch }
 
 // Copyright (C) 2011-2021 Free Software Foundation, Inc.
 //
@@ -18,7 +19,117 @@
 // <http://www.gnu.org/licenses/>.
 
 // libstdc++/49745
-#include <bits/stdc++.h>
+// error: 'int truncate' redeclared as different kind of symbol
+
+// This tests that no libstdc++ headers include <unistd.h>.
+// However, as discussed in PR libstdc++/100117 we cannot guarantee that
+// no libc headers include it indirectly, so only include the C++ headers.
+// That means we can't use <bits/stdc++.h> because that includes <cstdio> etc.
+// so we list the C++ headers explicitly here. This list is unfortunately
+// doomed to get out of date as new headers are added to the library.
+
+#include <algorithm>
+#include <bitset>
+#include <complex>
+#include <deque>
+#include <exception>
+#include <fstream>
+#include <functional>
+#include <iomanip>
+#include <ios>
+#include <iosfwd>
+#include <iostream>
+#include <istream>
+#include <iterator>
+#include <limits>
+#include <list>
+#include <locale>
+#include <map>
+#include <memory>
+#include <new>
+#include <numeric>
+#include <ostream>
+#include <queue>
+#include <set>
+#include <sstream>
+#include <stack>
+#include <stdexcept>
+#include <streambuf>
+#include <string>
+#include <typeinfo>
+#include <utility>
+#include <valarray>
+#include <vector>
+
+#if __cplusplus >= 201103L
+#include <array>
+#include <atomic>
+#include <chrono>
+#include <codecvt>
+#include <condition_variable>
+#include <forward_list>
+#include <future>
+#include <initializer_list>
+#include <mutex>
+#include <random>
+#include <ratio>
+#include <regex>
+#include <scoped_allocator>
+#include <system_error>
+#include <thread>
+#include <tuple>
+#include <typeindex>
+#include <type_traits>
+#include <unordered_map>
+#include <unordered_set>
+#endif
+
+#if __cplusplus >= 201402L
+#include <shared_mutex>
+#endif
+
+#if __cplusplus >= 201703L
+#include <any>
+#include <charconv>
+// #include <execution>
+#include <filesystem>
+#include <optional>
+#include <memory_resource>
+#include <string_view>
+#include <variant>
+#endif
+
+#if __cplusplus >= 202002L
+#include <barrier>
+#include <bit>
+#include <compare>
+#include <concepts>
+#if __cpp_impl_coroutine
+# include <coroutine>
+#endif
+#if __has_include (<format>)
+# include <format>
+#endif
+#include <latch>
+#include <numbers>
+#include <ranges>
+#include <span>
+#include <stop_token>
+#include <semaphore>
+#include <source_location>
+#include <syncstream>
+#include <version>
+#endif
+
+#if __cplusplus > 202002L
+#if __has_include(<spanstream>)
+# include <spanstream>
+#endif
+#if __has_include(<stacktrace>)
+# include <stacktrace>
+#endif
+#endif
+
 int truncate = 0;
 
 // { dg-xfail-if "PR libstdc++/99995" { c++20 } }


                 reply	other threads:[~2021-11-24 11:50 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=20211124115016.85E5D3857C75@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).