From patchwork Fri Jul 16 14:36:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1506190 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=p2+TdDB3; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GRDPB5Pmsz9sRf for ; Sat, 17 Jul 2021 00:38:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 99B1A39AF4FE for ; Fri, 16 Jul 2021 14:38:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 99B1A39AF4FE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1626446281; bh=H5wav8JSEPHa5ZYyHiwQXz/BjOlD8cNveJXptdPhUzk=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=p2+TdDB3DiRIkADknEoBIYd3CLlMEfMa6N0qR+P+KqoB72kymIdTlY7vxwURkrWiI I+vLTiC2GOj7VtzPsjakJ+TjaAbautrEsGtWE+JhTfpu8Esnwi8x9GK62LQPUnft1m D9mqF7YQKf5ERvO+ymjp5+Glv+wEG0TWUqm7+MnU= 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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 757223AA9400 for ; Fri, 16 Jul 2021 14:37:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 757223AA9400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-189-Dtx4krEIOWGZShb-Zy4yYg-1; Fri, 16 Jul 2021 10:36:59 -0400 X-MC-Unique: Dtx4krEIOWGZShb-Zy4yYg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8E4C0802B9F; Fri, 16 Jul 2021 14:36:42 +0000 (UTC) Received: from localhost (unknown [10.33.37.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26C005D9DE; Fri, 16 Jul 2021 14:36:41 +0000 (UTC) Date: Fri, 16 Jul 2021 15:36:41 +0100 To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Modernize helpers Message-ID: MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-14.1 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, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * include/bits/random.h (_Shift::__value): Use constexpr. (_Select_uint_least_t::type): Use using-declaration. (_Mod): Likewise. * testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error line number. Tested powerpc64le-linux. Committed to trunk. commit 95891ca020591196cde50c4cde4cab14783a3c00 Author: Jonathan Wakely Date: Fri Jul 16 13:39:25 2021 libstdc++: Modernize helpers Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * include/bits/random.h (_Shift::__value): Use constexpr. (_Select_uint_least_t::type): Use using-declaration. (_Mod): Likewise. * testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error line number. diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h index 6d0e1544c90..c5cae87b636 100644 --- a/libstdc++-v3/include/bits/random.h +++ b/libstdc++-v3/include/bits/random.h @@ -68,11 +68,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION bool = __w < static_cast (std::numeric_limits<_UIntType>::digits)> struct _Shift - { static const _UIntType __value = 0; }; + { static constexpr _UIntType __value = 0; }; template struct _Shift<_UIntType, __w, true> - { static const _UIntType __value = _UIntType(1) << __w; }; + { static constexpr _UIntType __value = _UIntType(1) << __w; }; template struct _Select_uint_least_t<__s, 4> - { typedef unsigned int type; }; + { using type = unsigned int; }; template struct _Select_uint_least_t<__s, 3> - { typedef unsigned long type; }; + { using type = unsigned long; }; template struct _Select_uint_least_t<__s, 2> - { typedef unsigned long long type; }; + { using type = unsigned long long; }; #if __SIZEOF_INT128__ > __SIZEOF_LONG_LONG__ template struct _Select_uint_least_t<__s, 1> - { __extension__ typedef unsigned __int128 type; }; + { __extension__ using type = unsigned __int128; }; #endif // Assume a != 0, a < m, c < m, x < m. @@ -111,11 +111,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION bool __schrage_ok = __m % __a < __m / __a> struct _Mod { - typedef typename _Select_uint_least_t::type _Tp2; static _Tp __calc(_Tp __x) - { return static_cast<_Tp>((_Tp2(__a) * __x + __c) % __m); } + { + using _Tp2 + = typename _Select_uint_least_t::type; + return static_cast<_Tp>((_Tp2(__a) * __x + __c) % __m); + } }; // Schrage. diff --git a/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc b/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc index 3ded306bd5f..d6e6399bd79 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc @@ -10,6 +10,6 @@ std::__detail::_Adaptor aurng(urng); auto x = std::generate_canonical::digits>(urng); -// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 166 } +// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 169 } // { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 3350 }