From patchwork Tue Nov 29 15:39:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 61229 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 CEAFA385514E for ; Tue, 29 Nov 2022 15:40:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CEAFA385514E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669736419; bh=n6QZeQe/iHPuAaTXjlP0eThX/NYQK1TnvdnlvP7tonw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=bBBY6RnuZ/KHCiguobxy4GtuzVsGevwhifyAGRxLsM7uAiBwahw2+R2zAm+1pz4RM c9x1Hql57LgNRcutkLgdqkVDqbGE99mqsDqip214ICVkrDdKoTFlUoL47Z4IGGPh0U t5MmTZLPSWY2JiYKCn5y6rwyRSR1q1xCRlZKotcQ= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 7F95F3858D35 for ; Tue, 29 Nov 2022 15:39:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7F95F3858D35 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-450-jFjP5F9KOECjzK4oiepXIg-1; Tue, 29 Nov 2022 10:39:48 -0500 X-MC-Unique: jFjP5F9KOECjzK4oiepXIg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6C16F85A5A6; Tue, 29 Nov 2022 15:39:48 +0000 (UTC) Received: from localhost (unknown [10.33.36.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3119F40C6EC4; Tue, 29 Nov 2022 15:39:48 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Do not use __used or __packed as identifiers Date: Tue, 29 Nov 2022 15:39:45 +0000 Message-Id: <20221129153945.144056-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham 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 x86_64-linux. Pushed to trunk. -- >8 -- These names (and __unused) are defined as macros by newlib. libstdc++-v3/ChangeLog: * include/std/format: Rename all variables called __used or __packed. * testsuite/17_intro/badnames.cc: Add no_pch options. * testsuite/17_intro/names.cc: Check __packed, __unused and __used. --- libstdc++-v3/include/std/format | 30 ++++++++++----------- libstdc++-v3/testsuite/17_intro/badnames.cc | 1 + libstdc++-v3/testsuite/17_intro/names.cc | 10 +++++-- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format index 23ffbdabed8..cb5ce40dece 100644 --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -2472,21 +2472,21 @@ namespace __format void _M_overflow() override { - auto __used = this->_M_used(); + auto __s = this->_M_used(); if (_M_max < 0) // No maximum. - _M_out = ranges::copy(__used, std::move(_M_out)).out; + _M_out = ranges::copy(__s, std::move(_M_out)).out; else if (_M_count < size_t(_M_max)) { auto __max = _M_max - _M_count; span<_CharT> __first; - if (__max < __used.size()) - __first = __used.first(__max); + if (__max < __s.size()) + __first = __s.first(__max); else - __first = __used; + __first = __s; _M_out = ranges::copy(__first, std::move(_M_out)).out; } this->_M_rewind(); - _M_count += __used.size(); + _M_count += __s.size(); } public: @@ -2529,8 +2529,8 @@ namespace __format void _M_overflow() { - auto __used = this->_M_used(); - _M_count += __used.size(); + auto __s = this->_M_used(); + _M_count += __s.size(); if (_M_max >= 0) { @@ -2544,7 +2544,7 @@ namespace __format { // No maximum character count. Just extend the span to allow // writing more characters to it. - this->_M_reset({__used.data(), __used.size() + 1024}, __used.end()); + this->_M_reset({__s.data(), __s.size() + 1024}, __s.end()); } } @@ -2594,12 +2594,12 @@ namespace __format { _Iter_sink::_M_overflow(); iter_difference_t<_OutIter> __count(_M_count); - auto __used = this->_M_used(); + auto __s = this->_M_used(); auto __last = _M_first; - if (__used.data() == _M_buf) // Wrote at least _M_max characters. + if (__s.data() == _M_buf) // Wrote at least _M_max characters. __last += _M_max; else - __last += iter_difference_t<_OutIter>(__used.size()); + __last += iter_difference_t<_OutIter>(__s.size()); return { __last, __count }; } }; @@ -3119,10 +3119,10 @@ namespace __format constexpr auto __pack_arg_types(const array<_Arg_t, _Nm>& __types) { - __UINT64_TYPE__ __packed = 0; + __UINT64_TYPE__ __packed_types = 0; for (auto __i = __types.rbegin(); __i != __types.rend(); ++__i) - __packed = (__packed << _Bits) | *__i; - return __packed; + __packed_types = (__packed_types << _Bits) | *__i; + return __packed_types; } } // namespace __format /// @endcond diff --git a/libstdc++-v3/testsuite/17_intro/badnames.cc b/libstdc++-v3/testsuite/17_intro/badnames.cc index 63c955e8277..5f1be094515 100644 --- a/libstdc++-v3/testsuite/17_intro/badnames.cc +++ b/libstdc++-v3/testsuite/17_intro/badnames.cc @@ -16,6 +16,7 @@ // . // { dg-do compile { target x86_64-*-linux* } } +// { dg-add-options no_pch } // Names taken from coding_style.bad_identifiers in the libstdc++ manual. // We can't test this on all targets, because these names are used in diff --git a/libstdc++-v3/testsuite/17_intro/names.cc b/libstdc++-v3/testsuite/17_intro/names.cc index 6490cd63307..ffbb199797b 100644 --- a/libstdc++-v3/testsuite/17_intro/names.cc +++ b/libstdc++-v3/testsuite/17_intro/names.cc @@ -129,8 +129,11 @@ #define ptr ( #endif -// This clashes with newlib so don't use it. +// These clash with newlib so don't use them. # define __lockable cannot be used as an identifier +# define __packed cannot be used as an identifier +# define __unused cannot be used as an identifier +# define __used cannot be used as an identifier #ifndef __APPLE__ #define __weak predefined qualifier on darwin @@ -239,8 +242,11 @@ #endif #if __has_include() -// newlib's defines __lockable as a macro. +// newlib's defines these as macros. #undef __lockable +#undef __packed +#undef __unused +#undef __used // newlib's defines __tzrule_type with these members. #undef d #undef m