From patchwork Thu May 19 22:43:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 54250 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 83673396E844 for ; Thu, 19 May 2022 22:47:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83673396E844 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1653000439; bh=bquOi83e6UcBEupSz7IYXCiQfvpqj1mlU+dAPKnwL3w=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ZGDGCynL/GSm1CmNp7CUsFALXqPeA9CTckHNfd8NQD+J/TgRbeqJS6c3UxgRQ6W6r oZ6+K32+iWoubvMSEhCypWXNFIOG8xICe5LlY40v7BKGXAT9UjfXsiCxEoRXTPphOx IysUmlLUhIlqpT77CuoW8AuLPo74kxwq6Mt3nTuE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id AF531396E84A for ; Thu, 19 May 2022 22:43:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AF531396E84A Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-205-gbfoFxM2OHKCGtxXYcY4_Q-1; Thu, 19 May 2022 18:43:22 -0400 X-MC-Unique: gbfoFxM2OHKCGtxXYcY4_Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B95C529AA2F6; Thu, 19 May 2022 22:43:21 +0000 (UTC) Received: from localhost (unknown [10.33.36.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80EB02026D6A; Thu, 19 May 2022 22:43:21 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Avoid including for std::char_traits Date: Thu, 19 May 2022 23:43:20 +0100 Message-Id: <20220519224320.703019-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Tested powerpc64le-linux, pushed to trunk. -- >8 -- We should prefer the __UINT_LEAST16_TYPE__ and __UINT_LEAST32_TYPE__ macros, if available, so that we don't need all of in every header that uses std::char_traits. libstdc++-v3/ChangeLog: * include/bits/char_traits.h: Only include when necessary. * include/std/stacktrace: Use __UINTPTR_TYPE__ instead of uintptr_t. * src/c++11/cow-stdexcept.cc: Include . * src/c++17/floating_to_chars.cc: Likewise. * testsuite/20_util/assume_aligned/1.cc: Include . * testsuite/20_util/assume_aligned/3.cc: Likewise. * testsuite/20_util/shared_ptr/creation/array.cc: Likewise. --- libstdc++-v3/include/bits/char_traits.h | 17 +++++++++-------- libstdc++-v3/include/std/stacktrace | 13 +++++++------ libstdc++-v3/src/c++11/cow-stdexcept.cc | 4 ++++ libstdc++-v3/src/c++17/floating_to_chars.cc | 2 ++ .../testsuite/20_util/assume_aligned/1.cc | 1 + .../testsuite/20_util/assume_aligned/3.cc | 1 + .../20_util/shared_ptr/creation/array.cc | 1 + 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h index cac1326d4b5..b856b1da320 100644 --- a/libstdc++-v3/include/bits/char_traits.h +++ b/libstdc++-v3/include/bits/char_traits.h @@ -40,6 +40,9 @@ #include // For WEOF, wmemmove, wmemset, etc. #if __cplusplus >= 201103L # include +#if !defined __UINT_LEAST16_TYPE__ || !defined __UINT_LEAST32_TYPE__ +# include +#endif #endif #if __cplusplus >= 202002L # include @@ -728,8 +731,6 @@ _GLIBCXX_END_NAMESPACE_VERSION #if __cplusplus >= 201103L -#include - namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -738,10 +739,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct char_traits { typedef char16_t char_type; -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 - typedef uint_least16_t int_type; -#elif defined __UINT_LEAST16_TYPE__ +#ifdef __UINT_LEAST16_TYPE__ typedef __UINT_LEAST16_TYPE__ int_type; +#elif defined _GLIBCXX_USE_C99_STDINT_TR1 + typedef uint_least16_t int_type; #else typedef make_unsigned::type int_type; #endif @@ -859,10 +860,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct char_traits { typedef char32_t char_type; -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 - typedef uint_least32_t int_type; -#elif defined __UINT_LEAST32_TYPE__ +#ifdef __UINT_LEAST32_TYPE__ typedef __UINT_LEAST32_TYPE__ int_type; +#elif defined _GLIBCXX_USE_C99_STDINT_TR1 + typedef uint_least32_t int_type; #else typedef make_unsigned::type int_type; #endif diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace index 1efaf253abb..39472d7236a 100644 --- a/libstdc++-v3/include/std/stacktrace +++ b/libstdc++-v3/include/std/stacktrace @@ -52,20 +52,20 @@ __glibcxx_backtrace_create_state(const char*, int, int __glibcxx_backtrace_simple(__glibcxx_backtrace_state*, int, - int (*) (void*, uintptr_t), + int (*) (void*, __UINTPTR_TYPE__), void(*)(void*, const char*, int), void*); int -__glibcxx_backtrace_pcinfo(__glibcxx_backtrace_state*, uintptr_t, - int (*)(void*, uintptr_t, +__glibcxx_backtrace_pcinfo(__glibcxx_backtrace_state*, __UINTPTR_TYPE__, + int (*)(void*, __UINTPTR_TYPE__, const char*, int, const char*), void(*)(void*, const char*, int), void*); int -__glibcxx_backtrace_syminfo(__glibcxx_backtrace_state*, uintptr_t addr, - void (*) (void*, uintptr_t, const char*, - uintptr_t, uintptr_t), +__glibcxx_backtrace_syminfo(__glibcxx_backtrace_state*, __UINTPTR_TYPE__ addr, + void (*) (void*, __UINTPTR_TYPE__, const char*, + __UINTPTR_TYPE__, __UINTPTR_TYPE__), void(*)(void*, const char*, int), void*); } @@ -225,6 +225,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION class basic_stacktrace { using _AllocTraits = allocator_traits<_Allocator>; + using uintptr_t = __UINTPTR_TYPE__; public: using value_type = stacktrace_entry; diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc b/libstdc++-v3/src/c++11/cow-stdexcept.cc index 5ccf2ca2d74..9e8787485eb 100644 --- a/libstdc++-v3/src/c++11/cow-stdexcept.cc +++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc @@ -200,6 +200,10 @@ _GLIBCXX_END_NAMESPACE_VERSION #if _GLIBCXX_USE_WEAK_REF #ifdef _GLIBCXX_USE_C99_STDINT_TR1 +#include + +using std::size_t; + extern "C" { #ifndef _GLIBCXX_MANGLE_SIZE_T diff --git a/libstdc++-v3/src/c++17/floating_to_chars.cc b/libstdc++-v3/src/c++17/floating_to_chars.cc index 4599d68a39c..b1c915e8a68 100644 --- a/libstdc++-v3/src/c++17/floating_to_chars.cc +++ b/libstdc++-v3/src/c++17/floating_to_chars.cc @@ -85,6 +85,8 @@ using F128_type = __float128; using F128_type = void; #endif +#include + namespace { #if defined __SIZEOF_INT128__ diff --git a/libstdc++-v3/testsuite/20_util/assume_aligned/1.cc b/libstdc++-v3/testsuite/20_util/assume_aligned/1.cc index 59379582cf9..0a1390d18e4 100644 --- a/libstdc++-v3/testsuite/20_util/assume_aligned/1.cc +++ b/libstdc++-v3/testsuite/20_util/assume_aligned/1.cc @@ -19,6 +19,7 @@ // { dg-do run { target c++2a } } #include +#include #include void diff --git a/libstdc++-v3/testsuite/20_util/assume_aligned/3.cc b/libstdc++-v3/testsuite/20_util/assume_aligned/3.cc index e1abf17e90a..93ee86c666e 100644 --- a/libstdc++-v3/testsuite/20_util/assume_aligned/3.cc +++ b/libstdc++-v3/testsuite/20_util/assume_aligned/3.cc @@ -20,6 +20,7 @@ // { dg-final { scan-assembler-not "undefined" } } #include +#include int* ptr(); extern "C" void undefined(); diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/array.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/array.cc index cd614c0ce0a..5c11a8b6285 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/array.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/array.cc @@ -65,6 +65,7 @@ test02() } #include +#include std::vector addresses;