From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 4C58F395ACCE for ; Tue, 3 Aug 2021 15:34:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4C58F395ACCE 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-77-DzCtBs-mOgmcYHTeL6qH1Q-1; Tue, 03 Aug 2021 11:34:42 -0400 X-MC-Unique: DzCtBs-mOgmcYHTeL6qH1Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E1671C73A0; Tue, 3 Aug 2021 15:34:40 +0000 (UTC) Received: from localhost (unknown [10.33.36.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E7425FC22; Tue, 3 Aug 2021 15:34:40 +0000 (UTC) Date: Tue, 3 Aug 2021 16:34:39 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Suppress redundant definitions of inline variables Message-ID: MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="4Tq+MC629iDinhRW" Content-Disposition: inline X-Spam-Status: No, score=-15.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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Aug 2021 15:34:45 -0000 --4Tq+MC629iDinhRW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In C++17 the out-of-class definitions for static constexpr variables are redundant, because they are implicitly inline. This change avoids "redundant redeclaration" warnings from -Wsystem-headers -Wdeprecated. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * include/bits/random.tcc (linear_congruential_engine): Do not define static constexpr members when they are implicitly inline. * include/std/ratio (ratio, __ratio_multiply, __ratio_divide) (__ratio_add, __ratio_subtract): Likewise. * include/std/type_traits (integral_constant): Likewise. * testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error line number. Tested powerpc64le-linux. Committed to trunk. --4Tq+MC629iDinhRW Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit a77a46d9aeb0166b4b1ee4b52e1cbb4b52c6736f Author: Jonathan Wakely Date: Tue Aug 3 15:03:44 2021 libstdc++: Suppress redundant definitions of inline variables In C++17 the out-of-class definitions for static constexpr variables are redundant, because they are implicitly inline. This change avoids "redundant redeclaration" warnings from -Wsystem-headers -Wdeprecated. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * include/bits/random.tcc (linear_congruential_engine): Do not define static constexpr members when they are implicitly inline. * include/std/ratio (ratio, __ratio_multiply, __ratio_divide) (__ratio_add, __ratio_subtract): Likewise. * include/std/type_traits (integral_constant): Likewise. * testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error line number. diff --git a/libstdc++-v3/include/bits/random.tcc b/libstdc++-v3/include/bits/random.tcc index 6ba263072b0..0be50d90e8a 100644 --- a/libstdc++-v3/include/bits/random.tcc +++ b/libstdc++-v3/include/bits/random.tcc @@ -91,6 +91,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } // namespace __detail /// @endcond +#if ! __cpp_inline_variables template constexpr _UIntType linear_congruential_engine<_UIntType, __a, __c, __m>::multiplier; @@ -106,6 +107,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template constexpr _UIntType linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed; +#endif /** * Seeds the LCR with integral value @p __s, adjusted so that the diff --git a/libstdc++-v3/include/std/ratio b/libstdc++-v3/include/std/ratio index ceee7d00c12..92f6d4b9ea1 100644 --- a/libstdc++-v3/include/std/ratio +++ b/libstdc++-v3/include/std/ratio @@ -279,11 +279,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef ratio type; }; +#if ! __cpp_inline_variables template constexpr intmax_t ratio<_Num, _Den>::num; template constexpr intmax_t ratio<_Num, _Den>::den; +#endif /// @cond undocumented @@ -307,11 +309,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static constexpr intmax_t den = type::den; }; +#if ! __cpp_inline_variables template constexpr intmax_t __ratio_multiply<_R1, _R2>::num; template constexpr intmax_t __ratio_multiply<_R1, _R2>::den; +#endif /// @endcond @@ -334,11 +338,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static constexpr intmax_t den = type::den; }; +#if ! __cpp_inline_variables template constexpr intmax_t __ratio_divide<_R1, _R2>::num; template constexpr intmax_t __ratio_divide<_R1, _R2>::den; +#endif /// @endcond @@ -512,11 +518,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static constexpr intmax_t den = type::den; }; +#if ! __cpp_inline_variables template constexpr intmax_t __ratio_add<_R1, _R2>::num; template constexpr intmax_t __ratio_add<_R1, _R2>::den; +#endif /// @endcond @@ -537,11 +545,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static constexpr intmax_t den = type::den; }; +#if ! __cpp_inline_variables template constexpr intmax_t __ratio_subtract<_R1, _R2>::num; template constexpr intmax_t __ratio_subtract<_R1, _R2>::den; +#endif /// @endcond diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 0d821f9c074..46edde905f8 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -73,8 +73,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif }; +#if ! __cpp_inline_variables template constexpr _Tp integral_constant<_Tp, __v>::value; +#endif /// The type used as a compile-time boolean with true value. using true_type = integral_constant; diff --git a/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc b/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc index d6e6399bd79..8fba7144d8a 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc @@ -12,4 +12,4 @@ auto x = std::generate_canonical