From patchwork Fri Oct 21 15:58:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 6804 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp775022wrr; Fri, 21 Oct 2022 09:00:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6L0soQbm5FZAeUifHZ2GG7L8PcKqi9lSjrNC3AKG4RBlt11JXnFLlCWfOCAJN44IDJMYUU X-Received: by 2002:a17:907:2e0b:b0:78e:16cb:327b with SMTP id ig11-20020a1709072e0b00b0078e16cb327bmr15810153ejc.458.1666368010895; Fri, 21 Oct 2022 09:00:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666368010; cv=none; d=google.com; s=arc-20160816; b=rGRUYxIJBykWpeVwGEeAMNp+KoEZMQvWoZHf8iz+qoKeaNX4A6ReB9Fx0VBfTHVRVh mGQiX/Xi3r0P5qmaytQFvB77u07jR4Xpaaey4jcX+MTsIYWxQnNlip7FY2UzExlL+fBo D3JgdG4UilNBBykm+Xw0FOUTT3byk+EOzyaPZ4C4HKQvTpZOgFf8UNu4EXfZHolF2YUc Y1QDYv4oxT+kq2Nwot8vCBD39uP8B6rO204/AVwm5//GWYlOJRCVETrr1d78ngX50R01 JijdgF9vtKpukAXmbKjZ82etULWXoi+pCy/zLGvLvMw2JIKB5YN8TjLn0J/kfpG4CLIN CvHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=tX5mdrHgaCOhQO5ksW8vbIAq8iJhq0iAhrpP4NC27jU=; b=tXpLFQ5Z249DreblCtT/bHiYDUqsm4fUlUf3BYO/Ng3OZ/ZpJ6UIy9SBzAhKVF9h+x B2HijFV6D2gZQpE8/iI2L446lsOzcF03GIJkGjKRu1zlRWHnFFRcWo2jSpJQmFGYkVym BIERFfBtH5CmoY3S4/4pdU3HtR4fnCkPyiVqa/a1z4Ro0awBGhc93YVWQSmcis3Dtmm8 UfBW0/ZNl2jbvwYjzzAt3gFiGUfDpvsk3zNGTa4dZXVFB1b39K7CGIL7FluP6HGAAGO3 KUbClk66olhySmlpHevxyb9Nl+pWhOsDZvmBNwMOzA9qBZqJ5Nk2VFQnjudXxFoD5tg3 WPvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=b1f6lmxf; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id n18-20020a056402061200b0045cc02ce2aasi17795365edv.319.2022.10.21.09.00.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 09:00:10 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=b1f6lmxf; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 73C51384D1B7 for ; Fri, 21 Oct 2022 15:59:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 73C51384D1B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666367960; bh=tX5mdrHgaCOhQO5ksW8vbIAq8iJhq0iAhrpP4NC27jU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=b1f6lmxf6zWksK4fHKa3Le1BH6+6S7+Zp3I1miYV2pGxqBzSZP3Z3HBFQFCkw6GQf cniU8bxi79oeMYPLIlMKWIR43/I9YEP6+tAH2HfEMgNoeQfDxvzDN2ajdXRggExhBD H45ZaZr3syxaT3Yj9u/oJMCznySnqKS59YgsvQU0= 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 A7CB03856974 for ; Fri, 21 Oct 2022 15:58:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A7CB03856974 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-387-dG2T_htlPWaOPU-A26PaMg-1; Fri, 21 Oct 2022 11:58:23 -0400 X-MC-Unique: dG2T_htlPWaOPU-A26PaMg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0854C85A583; Fri, 21 Oct 2022 15:58:23 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2B49310197; Fri, 21 Oct 2022 15:58:22 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 29LFwJc73544037 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 21 Oct 2022 17:58:20 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 29LFwJIn3544036; Fri, 21 Oct 2022 17:58:19 +0200 Date: Fri, 21 Oct 2022 17:58:19 +0200 To: Jonathan Wakely Subject: [PATCH] libstdc++-v3: support for extended floating point types Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747313503589410852?= X-GMAIL-MSGID: =?utf-8?q?1747313503589410852?= Hi! The following patch adds support for extended floating point types. C++23 removes the float/double/long double specializations from the spec and instead adds explicit(bool) specifier on the converting constructor. The patch uses that for converting constructor of the base template as well as the float/double/long double specializations's converting constructors (e.g. so that it handles convertion construction also from complex of extended floating point types). Copy ctor was already defaulted as the spec now requires. The patch also adds partial specialization for the _Float{16,32,64,128} and __gnu_cxx::__bfloat16_t types because the base template doesn't use __complex__ but a pair of floating point values. This patch is on top of https://gcc.gnu.org/pipermail/libstdc++/2022-October/054849.html (and if https://gcc.gnu.org/pipermail/libstdc++/2022-October/054862.html is also applied, then https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603665.html https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604080.html https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604134.html are needed as well). The g++.dg/cpp23/ testcase verifies explicit(bool) works correctly. Tested on x86_64-linux, ok for trunk? 2022-10-21 Jakub Jelinek gcc/testsuite/ * g++.dg/cpp23/ext-floating12.C: New test. libstdc++-v3/ * include/std/complex (complex::complex converting ctor): For C++23 use explicit specifier with constant expression and explicitly cast both parts to _Tp. (__complex_abs, __complex_arg, __complex_cos, __complex_cosh, __complex_exp, __complex_log, __complex_sin, __complex_sinh, __complex_sqrt, __complex_tan, __complex_tanh, __complex_pow): Add __complex__ _Float{16,32,64,128} and __complex__ decltype(0.0bf16) overloads. (complex::complex converting ctor, complex::complex converting ctor, complex::complex converting ctor): For C++23 implement as template with explicit specifier with constant expression and explicit casts. (__complex_type): New template. (complex): New partial specialization for types with extended floating point types. (__complex_acos, __complex_asin, __complex_atan, __complex_acosh, __complex_asinh, __complex_atanh): Add __complex__ _Float{16,32,64,128} and __complex__ decltype(0.0bf16) overloads. (__complex_proj): Likewise. Add template for complex of extended floating point types. * include/bits/cpp_type_traits.h (__is_floating): Specialize for _Float{16,32,64,128} and __gnu_cxx::__bfloat16_t. * testsuite/26_numerics/complex/ext_c++23.cc: New test. Jakub --- libstdc++-v3/include/std/complex.jj 2022-10-21 08:55:43.037675332 +0200 +++ libstdc++-v3/include/std/complex 2022-10-21 17:05:36.802243229 +0200 @@ -142,8 +142,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Converting constructor. template +#if __cplusplus > 202002L + explicit(!requires(_Up __u) { _Tp{__u}; }) + constexpr complex(const complex<_Up>& __z) + : _M_real(_Tp(__z.real())), _M_imag(_Tp(__z.imag())) { } +#else _GLIBCXX_CONSTEXPR complex(const complex<_Up>& __z) : _M_real(__z.real()), _M_imag(__z.imag()) { } +#endif #if __cplusplus >= 201103L // _GLIBCXX_RESOLVE_LIB_DEFECTS @@ -1077,6 +1083,264 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : std::pow(complex<_Tp>(__x), __y); } +#if _GLIBCXX_USE_C99_COMPLEX +#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline _Float16 + __complex_abs(__complex__ _Float16 __z) + { return _Float16(__builtin_cabsf(__z)); } + + inline _Float16 + __complex_arg(__complex__ _Float16 __z) + { return _Float16(__builtin_cargf(__z)); } + + inline __complex__ _Float16 + __complex_cos(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_ccosf(__z)); } + + inline __complex__ _Float16 + __complex_cosh(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_ccoshf(__z)); } + + inline __complex__ _Float16 + __complex_exp(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_cexpf(__z)); } + + inline __complex__ _Float16 + __complex_log(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_clogf(__z)); } + + inline __complex__ _Float16 + __complex_sin(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_csinf(__z)); } + + inline __complex__ _Float16 + __complex_sinh(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_csinhf(__z)); } + + inline __complex__ _Float16 + __complex_sqrt(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_csqrtf(__z)); } + + inline __complex__ _Float16 + __complex_tan(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_ctanf(__z)); } + + inline __complex__ _Float16 + __complex_tanh(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_ctanhf(__z)); } + + inline __complex__ _Float16 + __complex_pow(__complex__ _Float16 __x, __complex__ _Float16 __y) + { return static_cast<__complex__ _Float16>(__builtin_cpowf(__x, __y)); } +#endif + +#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline _Float32 + __complex_abs(__complex__ _Float32 __z) { return __builtin_cabsf(__z); } + + inline _Float32 + __complex_arg(__complex__ _Float32 __z) { return __builtin_cargf(__z); } + + inline __complex__ _Float32 + __complex_cos(__complex__ _Float32 __z) { return __builtin_ccosf(__z); } + + inline __complex__ _Float32 + __complex_cosh(__complex__ _Float32 __z) { return __builtin_ccoshf(__z); } + + inline __complex__ _Float32 + __complex_exp(__complex__ _Float32 __z) { return __builtin_cexpf(__z); } + + inline __complex__ _Float32 + __complex_log(__complex__ _Float32 __z) { return __builtin_clogf(__z); } + + inline __complex__ _Float32 + __complex_sin(__complex__ _Float32 __z) { return __builtin_csinf(__z); } + + inline __complex__ _Float32 + __complex_sinh(__complex__ _Float32 __z) { return __builtin_csinhf(__z); } + + inline __complex__ _Float32 + __complex_sqrt(__complex__ _Float32 __z) { return __builtin_csqrtf(__z); } + + inline __complex__ _Float32 + __complex_tan(__complex__ _Float32 __z) { return __builtin_ctanf(__z); } + + inline __complex__ _Float32 + __complex_tanh(__complex__ _Float32 __z) { return __builtin_ctanhf(__z); } + + inline __complex__ _Float32 + __complex_pow(__complex__ _Float32 __x, __complex__ _Float32 __y) + { return __builtin_cpowf(__x, __y); } +#endif + +#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) + inline _Float64 + __complex_abs(__complex__ _Float64 __z) { return __builtin_cabs(__z); } + + inline _Float64 + __complex_arg(__complex__ _Float64 __z) { return __builtin_carg(__z); } + + inline __complex__ _Float64 + __complex_cos(__complex__ _Float64 __z) { return __builtin_ccos(__z); } + + inline __complex__ _Float64 + __complex_cosh(__complex__ _Float64 __z) { return __builtin_ccosh(__z); } + + inline __complex__ _Float64 + __complex_exp(__complex__ _Float64 __z) { return __builtin_cexp(__z); } + + inline __complex__ _Float64 + __complex_log(__complex__ _Float64 __z) { return __builtin_clog(__z); } + + inline __complex__ _Float64 + __complex_sin(__complex__ _Float64 __z) { return __builtin_csin(__z); } + + inline __complex__ _Float64 + __complex_sinh(__complex__ _Float64 __z) { return __builtin_csinh(__z); } + + inline __complex__ _Float64 + __complex_sqrt(__complex__ _Float64 __z) { return __builtin_csqrt(__z); } + + inline __complex__ _Float64 + __complex_tan(__complex__ _Float64 __z) { return __builtin_ctan(__z); } + + inline __complex__ _Float64 + __complex_tanh(__complex__ _Float64 __z) { return __builtin_ctanh(__z); } + + inline __complex__ _Float64 + __complex_pow(__complex__ _Float64 __x, __complex__ _Float64 __y) + { return __builtin_cpow(__x, __y); } +#endif + +#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) + inline _Float128 + __complex_abs(__complex__ _Float128 __z) { return __builtin_cabsl(__z); } + + inline _Float128 + __complex_arg(__complex__ _Float128 __z) { return __builtin_cargl(__z); } + + inline __complex__ _Float128 + __complex_cos(__complex__ _Float128 __z) { return __builtin_ccosl(__z); } + + inline __complex__ _Float128 + __complex_cosh(__complex__ _Float128 __z) { return __builtin_ccoshl(__z); } + + inline __complex__ _Float128 + __complex_exp(__complex__ _Float128 __z) { return __builtin_cexpl(__z); } + + inline __complex__ _Float128 + __complex_log(__complex__ _Float128 __z) { return __builtin_clogl(__z); } + + inline __complex__ _Float128 + __complex_sin(__complex__ _Float128 __z) { return __builtin_csinl(__z); } + + inline __complex__ _Float128 + __complex_sinh(__complex__ _Float128 __z) { return __builtin_csinhl(__z); } + + inline __complex__ _Float128 + __complex_sqrt(__complex__ _Float128 __z) { return __builtin_csqrtl(__z); } + + inline __complex__ _Float128 + __complex_tan(__complex__ _Float128 __z) { return __builtin_ctanl(__z); } + + inline __complex__ _Float128 + __complex_tanh(__complex__ _Float128 __z) { return __builtin_ctanhl(__z); } + + inline __complex__ _Float128 + __complex_pow(__complex__ _Float128 __x, __complex__ _Float128 __y) + { return __builtin_cpowl(__x, __y); } +#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH) + inline _Float128 + __complex_abs(__complex__ _Float128 __z) { return __builtin_cabsf128(__z); } + + inline _Float128 + __complex_arg(__complex__ _Float128 __z) { return __builtin_cargf128(__z); } + + inline __complex__ _Float128 + __complex_cos(__complex__ _Float128 __z) { return __builtin_ccosf128(__z); } + + inline __complex__ _Float128 + __complex_cosh(__complex__ _Float128 __z) { return __builtin_ccoshf128(__z); } + + inline __complex__ _Float128 + __complex_exp(__complex__ _Float128 __z) { return __builtin_cexpf128(__z); } + + inline __complex__ _Float128 + __complex_log(__complex__ _Float128 __z) { return __builtin_clogf128(__z); } + + inline __complex__ _Float128 + __complex_sin(__complex__ _Float128 __z) { return __builtin_csinf128(__z); } + + inline __complex__ _Float128 + __complex_sinh(__complex__ _Float128 __z) { return __builtin_csinhf128(__z); } + + inline __complex__ _Float128 + __complex_sqrt(__complex__ _Float128 __z) { return __builtin_csqrtf128(__z); } + + inline __complex__ _Float128 + __complex_tan(__complex__ _Float128 __z) { return __builtin_ctanf128(__z); } + + inline __complex__ _Float128 + __complex_tanh(__complex__ _Float128 __z) { return __builtin_ctanhf128(__z); } + + inline __complex__ _Float128 + __complex_pow(__complex__ _Float128 __x, __complex__ _Float128 __y) + { return __builtin_cpowf128(__x, __y); } +#endif + +#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline __gnu_cxx::__bfloat16_t + __complex_abs(__complex__ decltype(0.0bf16) __z) + { return __gnu_cxx::__bfloat16_t(__builtin_cabsf(__z)); } + + inline __gnu_cxx::__bfloat16_t + __complex_arg(__complex__ decltype(0.0bf16) __z) + { return __gnu_cxx::__bfloat16_t(__builtin_cargf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_cos(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_ccosf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_cosh(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_ccoshf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_exp(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_cexpf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_log(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_clogf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_sin(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_csinf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_sinh(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_csinhf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_sqrt(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_csqrtf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_tan(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_ctanf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_tanh(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_ctanhf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_pow(__complex__ decltype(0.0bf16) __x, + __complex__ decltype(0.0bf16) __y) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_cpowf(__x, + __y)); } +#endif +#endif + /// 26.2.3 complex specializations /// complex specialization template<> @@ -1098,8 +1362,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #endif +#if __cplusplus > 202002L + template + explicit(!requires(_Up __u) { value_type{__u}; }) + constexpr complex(const complex<_Up>& __z) + : _M_value{ value_type(__z.real()), value_type(__z.imag()) } { } +#else explicit _GLIBCXX_CONSTEXPR complex(const complex&); explicit _GLIBCXX_CONSTEXPR complex(const complex&); +#endif #if __cplusplus >= 201103L // _GLIBCXX_RESOLVE_LIB_DEFECTS @@ -1244,10 +1515,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #endif +#if __cplusplus > 202002L + template + explicit(!requires(_Up __u) { value_type{__u}; }) + constexpr complex(const complex<_Up>& __z) + : _M_value{ value_type(__z.real()), value_type(__z.imag()) } { } +#else _GLIBCXX_CONSTEXPR complex(const complex& __z) : _M_value(__z.__rep()) { } explicit _GLIBCXX_CONSTEXPR complex(const complex&); +#endif #if __cplusplus >= 201103L // _GLIBCXX_RESOLVE_LIB_DEFECTS @@ -1391,11 +1669,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #endif +#if __cplusplus > 202002L + template + explicit(!requires(_Up __u) { value_type{__u}; }) + constexpr complex(const complex<_Up>& __z) + : _M_value{ value_type(__z.real()), value_type(__z.imag()) } { } +#else _GLIBCXX_CONSTEXPR complex(const complex& __z) : _M_value(__z.__rep()) { } _GLIBCXX_CONSTEXPR complex(const complex& __z) : _M_value(__z.__rep()) { } +#endif #if __cplusplus >= 201103L // _GLIBCXX_RESOLVE_LIB_DEFECTS @@ -1517,6 +1802,161 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _ComplexT _M_value; }; +#if __cplusplus > 202002L + template + struct __complex_type + { }; + +#ifdef __STDCPP_FLOAT16_T__ + template<> + struct __complex_type<_Float16> + { typedef __complex__ _Float16 type; }; +#endif + +#ifdef __STDCPP_FLOAT32_T__ + template<> + struct __complex_type<_Float32> + { typedef __complex__ _Float32 type; }; +#endif + +#ifdef __STDCPP_FLOAT64_T__ + template<> + struct __complex_type<_Float64> + { typedef __complex__ _Float64 type; }; +#endif + +#ifdef __STDCPP_FLOAT128_T__ + template<> + struct __complex_type<_Float128> + { typedef __complex__ _Float128 type; }; +#endif + +#ifdef __STDCPP_BFLOAT16_T__ + template<> + struct __complex_type<__gnu_cxx::__bfloat16_t> + { typedef __complex__ decltype(0.0bf16) type; }; +#endif + + template + requires(__complex_type<_Tp>::type) + class complex<_Tp> + { + public: + typedef _Tp value_type; + typedef std::__complex_type<_Tp>::type _ComplexT; + + constexpr complex(_ComplexT __z) : _M_value(__z) { } + + constexpr complex(_Tp __r = _Tp(), _Tp __i = _Tp()) + : _M_value{ __r, __i } { } + + template + explicit(!requires(_Up __u) { value_type{__u}; }) + constexpr complex(const complex<_Up>& __z) + : _M_value{ value_type(__z.real()), value_type(__z.imag()) } { } + + constexpr _Tp + real() const { return __real__ _M_value; } + + constexpr _Tp + imag() const { return __imag__ _M_value; } + + constexpr void + real(_Tp __val) { __real__ _M_value = __val; } + + constexpr void + imag(_Tp __val) { __imag__ _M_value = __val; } + + constexpr complex& + operator=(_Tp __f) + { + _M_value = __f; + return *this; + } + + constexpr complex& + operator+=(_Tp __f) + { + _M_value += __f; + return *this; + } + + constexpr complex& + operator-=(_Tp __f) + { + _M_value -= __f; + return *this; + } + + constexpr complex& + operator*=(_Tp __f) + { + _M_value *= __f; + return *this; + } + + constexpr complex& + operator/=(_Tp __f) + { + _M_value /= __f; + return *this; + } + + // Let the compiler synthesize the copy and assignment + // operator. It always does a pretty good job. + constexpr complex& operator=(const complex&) = default; + + template + constexpr complex& + operator=(const complex<_Up>& __z) + { + __real__ _M_value = __z.real(); + __imag__ _M_value = __z.imag(); + return *this; + } + + template + constexpr complex& + operator+=(const complex<_Up>& __z) + { + _M_value += __z.__rep(); + return *this; + } + + template + constexpr complex& + operator-=(const complex<_Up>& __z) + { + _M_value -= __z.__rep(); + return *this; + } + + template + constexpr complex& + operator*=(const complex<_Up>& __z) + { + const _ComplexT __t = __z.__rep(); + _M_value *= __t; + return *this; + } + + template + constexpr complex& + operator/=(const complex<_Up>& __z) + { + const _ComplexT __t = __z.__rep(); + _M_value /= __t; + return *this; + } + + constexpr _ComplexT __rep() const { return _M_value; } + + private: + _ComplexT _M_value; + }; +#endif + +#if __cplusplus <= 202002L // These bits have to be at the end of this file, so that the // specializations have all been defined. inline _GLIBCXX_CONSTEXPR @@ -1530,6 +1970,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline _GLIBCXX_CONSTEXPR complex::complex(const complex& __z) : _M_value(__z.__rep()) { } +#endif // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. @@ -1809,6 +2250,162 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __complex_atanh(__z); } #endif +#if _GLIBCXX_USE_C99_COMPLEX_TR1 +#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline __complex__ _Float16 + __complex_acos(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_cacosf(__z)); } + + inline __complex__ _Float16 + __complex_asin(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_casinf(__z)); } + + inline __complex__ _Float16 + __complex_atan(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_catanf(__z)); } + + inline __complex__ _Float16 + __complex_acosh(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_cacoshf(__z)); } + + inline __complex__ _Float16 + __complex_asinh(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_casinhf(__z)); } + + inline __complex__ _Float16 + __complex_atanh(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_catanhf(__z)); } +#endif + +#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline __complex__ _Float32 + __complex_acos(__complex__ _Float32 __z) + { return __builtin_cacosf(__z); } + + inline __complex__ _Float32 + __complex_asin(__complex__ _Float32 __z) + { return __builtin_casinf(__z); } + + inline __complex__ _Float32 + __complex_atan(__complex__ _Float32 __z) + { return __builtin_catanf(__z); } + + inline __complex__ _Float32 + __complex_acosh(__complex__ _Float32 __z) + { return __builtin_cacoshf(__z); } + + inline __complex__ _Float32 + __complex_asinh(__complex__ _Float32 __z) + { return __builtin_casinhf(__z); } + + inline __complex__ _Float32 + __complex_atanh(__complex__ _Float32 __z) + { return __builtin_catanhf(__z); } +#endif + +#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) + inline __complex__ _Float64 + __complex_acos(__complex__ _Float64 __z) + { return __builtin_cacos(__z); } + + inline __complex__ _Float64 + __complex_asin(__complex__ _Float64 __z) + { return __builtin_casin(__z); } + + inline __complex__ _Float64 + __complex_atan(__complex__ _Float64 __z) + { return __builtin_catan(__z); } + + inline __complex__ _Float64 + __complex_acosh(__complex__ _Float64 __z) + { return __builtin_cacosh(__z); } + + inline __complex__ _Float64 + __complex_asinh(__complex__ _Float64 __z) + { return __builtin_casinh(__z); } + + inline __complex__ _Float64 + __complex_atanh(__complex__ _Float64 __z) + { return __builtin_catanh(__z); } +#endif + +#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) + inline __complex__ _Float128 + __complex_acos(__complex__ _Float128 __z) + { return __builtin_cacosl(__z); } + + inline __complex__ _Float128 + __complex_asin(__complex__ _Float128 __z) + { return __builtin_casinl(__z); } + + inline __complex__ _Float128 + __complex_atan(__complex__ _Float128 __z) + { return __builtin_catanl(__z); } + + inline __complex__ _Float128 + __complex_acosh(__complex__ _Float128 __z) + { return __builtin_cacoshl(__z); } + + inline __complex__ _Float128 + __complex_asinh(__complex__ _Float128 __z) + { return __builtin_casinhl(__z); } + + inline __complex__ _Float128 + __complex_atanh(__complex__ _Float128 __z) + { return __builtin_catanhl(__z); } +#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH) + inline __complex__ _Float128 + __complex_acos(__complex__ _Float128 __z) + { return __builtin_cacosf128(__z); } + + inline __complex__ _Float128 + __complex_asin(__complex__ _Float128 __z) + { return __builtin_casinf128(__z); } + + inline __complex__ _Float128 + __complex_atan(__complex__ _Float128 __z) + { return __builtin_catanf128(__z); } + + inline __complex__ _Float128 + __complex_acosh(__complex__ _Float128 __z) + { return __builtin_cacoshf128(__z); } + + inline __complex__ _Float128 + __complex_asinh(__complex__ _Float128 __z) + { return __builtin_casinhf128(__z); } + + inline __complex__ _Float128 + __complex_atanh(__complex__ _Float128 __z) + { return __builtin_catanhf128(__z); } +#endif + +#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline __complex__ decltype(0.0bf16) + __complex_acos(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_cacosf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_asin(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_casinf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_atan(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_catanf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_acosh(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_cacoshf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_asinh(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_casinhf(__z)); } + + inline __complex__ decltype(0.0bf16) + __complex_atanh(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_catanhf(__z)); } +#endif +#endif + template inline _Tp /// fabs(__z) [8.1.8]. @@ -1897,6 +2494,49 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline complex __complex_proj(const complex& __z) { return __builtin_cprojl(__z.__rep()); } + +#if __cplusplus > 202002L +#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline __complex__ _Float16 + __complex_proj(__complex__ _Float16 __z) + { return static_cast<__complex__ _Float16>(__builtin_cprojf(__z)); } +#endif + +#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline __complex__ _Float32 + __complex_proj(__complex__ _Float32 __z) + { return __builtin_cprojf(__z); } +#endif + +#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) + inline __complex__ _Float64 + __complex_proj(__complex__ _Float64 __z) + { return __builtin_cproj(__z); } +#endif + +#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) + inline __complex__ _Float128 + __complex_proj(__complex__ _Float128 __z) + { return __builtin_cprojl(__z); } +#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH) + inline __complex__ _Float128 + __complex_proj(__complex__ _Float128 __z) + { return __builtin_cprojf128(__z); } +#endif + +#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline __complex__ decltype(0.0bf16) + __complex_proj(__complex__ decltype(0.0bf16) __z) + { return static_cast<__complex__ decltype(0.0bf16)>(__builtin_cprojf(__z)); } +#endif + + template + requires(__complex_type<_Tp>::type) + inline complex<_Tp> + __complex_proj(const complex<_Tp>& __z) + { return __complex_proj(__z.__rep()); } +#endif + #elif defined _GLIBCXX_USE_C99_MATH_TR1 inline complex __complex_proj(const complex& __z) --- libstdc++-v3/include/bits/cpp_type_traits.h.jj 2022-01-11 23:11:24.144265506 +0100 +++ libstdc++-v3/include/bits/cpp_type_traits.h 2022-10-21 11:06:07.059777783 +0200 @@ -315,6 +315,51 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) typedef __true_type __type; }; +#ifdef __STDCPP_FLOAT16_T__ + template<> + struct __is_floating<_Float16> + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + +#ifdef __STDCPP_FLOAT32_T__ + template<> + struct __is_floating<_Float32> + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + +#ifdef __STDCPP_FLOAT64_T__ + template<> + struct __is_floating<_Float64> + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + +#ifdef __STDCPP_FLOAT128_T__ + template<> + struct __is_floating<_Float128> + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + +#ifdef __STDCPP_BFLOAT16_T__ + template<> + struct __is_floating<__gnu_cxx::__bfloat16_t> + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + // // Pointer types // --- libstdc++-v3/testsuite/26_numerics/complex/ext_c++23.cc.jj 2022-10-21 16:24:24.337657605 +0200 +++ libstdc++-v3/testsuite/26_numerics/complex/ext_c++23.cc 2022-10-21 17:20:47.300853616 +0200 @@ -0,0 +1,89 @@ +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++2b" } +// { dg-do link { target c++23 } } + +#include +#include + +template +__attribute__((__noipa__)) void +test_functions(T *p, std::complex *q) +{ + p[0] = std::abs(q[0]); + p[1] = std::arg(q[1]); + q[2] = std::cos(q[2]); + q[3] = std::cosh(q[3]); + q[4] = std::exp(q[4]); + q[5] = std::log(q[5]); + q[6] = std::sin(q[6]); + q[7] = std::sinh(q[7]); + q[8] = std::sqrt(q[8]); + q[9] = std::tan(q[9]); + q[10] = std::tanh(q[10]); + q[11] = std::pow(q[11], q[19]); + q[12] = std::acos(q[12]); + q[13] = std::asin(q[13]); + q[14] = std::atan(q[14]); + q[15] = std::acosh(q[15]); + q[16] = std::asinh(q[16]); + q[17] = std::atanh(q[17]); + q[18] = std::proj(q[18]); +} + +int +main() +{ +#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + { + std::float16_t p[2] = {}; + std::complex q[20] = {}; + test_functions(p, q); + } +#endif +#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + { + std::float32_t p[2] = {}; + std::complex q[20] = {}; + test_functions(p, q); + } +#endif +#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) + { + std::float64_t p[2] = {}; + std::complex q[20] = {}; + test_functions(p, q); + } +#endif +#if defined(__STDCPP_FLOAT128_T__) \ + && (defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY128) \ + || defined(_GLIBCXX_HAVE_FLOAT128_MATH)) + { + std::float128_t p[2] = {}; + std::complex q[20] = {}; + test_functions(p, q); + } +#endif +#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + { + std::bfloat16_t p[2] = {}; + std::complex q[20] = {}; + test_functions(p, q); + } +#endif +} --- gcc/testsuite/g++.dg/cpp23/ext-floating12.C.jj 2022-10-21 15:12:38.119671632 +0200 +++ gcc/testsuite/g++.dg/cpp23/ext-floating12.C 2022-10-21 16:13:27.021501628 +0200 @@ -0,0 +1,182 @@ +// P1467R9 - Extended floating-point types and standard names. +// { dg-do compile { target { c++23 && { i?86-*-linux* x86_64-*-linux* } } } } +// { dg-options "" } + +#include +#include + +#if !defined(__STDCPP_FLOAT32_T__) \ + || !defined(__STDCPP_FLOAT64_T__) || !defined(__STDCPP_FLOAT128_T__) \ + || __FLT_MAX_EXP__ != __FLT32_MAX_EXP__ || __FLT_MANT_DIG__ != __FLT32_MANT_DIG__ \ + || __DBL_MAX_EXP__ != __FLT64_MAX_EXP__ || __DBL_MANT_DIG__ != __FLT64_MANT_DIG__ \ + || __LDBL_MAX_EXP__ != __FLT128_MAX_EXP__ || __LDBL_MANT_DIG__ >= __FLT128_MANT_DIG__ \ + || !defined(__SIZEOF_FLOAT128__) +#error Unexpected set of floating point types +#endif + +using namespace std; + +int +main() +{ + complex a01(complex(1.0f, 2.0f)); + complex a02 = complex(1.0f, 2.0f); + complex a03(complex(1.0, 2.0)); + complex a04 = complex(1.0, 2.0); // { dg-error "conversion from 'complex' to non-scalar type 'complex' requested" } + complex a05(complex(1.0L, 2.0L)); + complex a06 = complex(1.0L, 2.0L); // { dg-error "conversion from 'complex' to non-scalar type 'complex' requested" } + complex a07(complex(1.0f32, 2.0f32)); + complex a08 = complex(1.0f32, 2.0f32); + complex a09(complex(1.0f64, 2.0f64)); + complex a10 = complex(1.0f64, 2.0f64); // { dg-error "conversion from 'complex<_Float64>' to non-scalar type 'complex' requested" } + complex a11(complex(1.0f128, 2.0f128)); + complex a12 = complex(1.0f128, 2.0f128); // { dg-error "conversion from 'complex<_Float128>' to non-scalar type 'complex' requested" } +#ifdef __STDCPP_FLOAT16_T__ + complex a13(complex(1.0f16, 2.0f16)); + complex a14 = complex(1.0f16, 2.0f16); +#endif +#ifdef __STDCPP_BFLOAT16_T__ + complex a15(complex(1.0bf16, 2.0bf16)); + complex a16 = complex(1.0bf16, 2.0bf16); +#endif + complex b01(complex(1.0f, 2.0f)); + complex b02 = complex(1.0f, 2.0f); + complex b03(complex(1.0, 2.0)); + complex b04 = complex(1.0, 2.0); + complex b05(complex(1.0L, 2.0L)); + complex b06 = complex(1.0L, 2.0L); // { dg-error "conversion from 'complex' to non-scalar type 'complex' requested" } + complex b07(complex(1.0f32, 2.0f32)); + complex b08 = complex(1.0f32, 2.0f32); + complex b09(complex(1.0f64, 2.0f64)); + complex b10 = complex(1.0f64, 2.0f64); + complex b11(complex(1.0f128, 2.0f128)); + complex b12 = complex(1.0f128, 2.0f128); // { dg-error "conversion from 'complex<_Float128>' to non-scalar type 'complex' requested" } +#ifdef __STDCPP_FLOAT16_T__ + complex b13(complex(1.0f16, 2.0f16)); + complex b14 = complex(1.0f16, 2.0f16); +#endif +#ifdef __STDCPP_BFLOAT16_T__ + complex b15(complex(1.0bf16, 2.0bf16)); + complex b16 = complex(1.0bf16, 2.0bf16); +#endif + complex c01(complex(1.0f, 2.0f)); + complex c02 = complex(1.0f, 2.0f); + complex c03(complex(1.0, 2.0)); + complex c04 = complex(1.0, 2.0); + complex c05(complex(1.0L, 2.0L)); + complex c06 = complex(1.0L, 2.0L); + complex c07(complex(1.0f32, 2.0f32)); + complex c08 = complex(1.0f32, 2.0f32); + complex c09(complex(1.0f64, 2.0f64)); + complex c10 = complex(1.0f64, 2.0f64); + complex c11(complex(1.0f128, 2.0f128)); + complex c12 = complex(1.0f128, 2.0f128); // { dg-error "conversion from 'complex<_Float128>' to non-scalar type 'complex' requested" } +#ifdef __STDCPP_FLOAT16_T__ + complex c13(complex(1.0f16, 2.0f16)); + complex c14 = complex(1.0f16, 2.0f16); +#endif +#ifdef __STDCPP_BFLOAT16_T__ + complex c15(complex(1.0bf16, 2.0bf16)); + complex c16 = complex(1.0bf16, 2.0bf16); +#endif + complex d01(complex(1.0f, 2.0f)); + complex d02 = complex(1.0f, 2.0f); + complex d03(complex(1.0, 2.0)); + complex d04 = complex(1.0, 2.0); // { dg-error "conversion from 'complex' to non-scalar type 'complex<_Float32>' requested" } + complex d05(complex(1.0L, 2.0L)); + complex d06 = complex(1.0L, 2.0L); // { dg-error "conversion from 'complex' to non-scalar type 'complex<_Float32>' requested" } + complex d07(complex(1.0f32, 2.0f32)); + complex d08 = complex(1.0f32, 2.0f32); + complex d09(complex(1.0f64, 2.0f64)); + complex d10 = complex(1.0f64, 2.0f64); // { dg-error "conversion from 'complex<_Float64>' to non-scalar type 'complex<_Float32>' requested" } + complex d11(complex(1.0f128, 2.0f128)); + complex d12 = complex(1.0f128, 2.0f128); // { dg-error "conversion from 'complex<_Float128>' to non-scalar type 'complex<_Float32>' requested" } +#ifdef __STDCPP_FLOAT16_T__ + complex d13(complex(1.0f16, 2.0f16)); + complex d14 = complex(1.0f16, 2.0f16); +#endif +#ifdef __STDCPP_BFLOAT16_T__ + complex d15(complex(1.0bf16, 2.0bf16)); + complex d16 = complex(1.0bf16, 2.0bf16); +#endif + complex e01(complex(1.0f, 2.0f)); + complex e02 = complex(1.0f, 2.0f); + complex e03(complex(1.0, 2.0)); + complex e04 = complex(1.0, 2.0); + complex e05(complex(1.0L, 2.0L)); + complex e06 = complex(1.0L, 2.0L); // { dg-error "conversion from 'complex' to non-scalar type 'complex<_Float64>' requested" } + complex e07(complex(1.0f32, 2.0f32)); + complex e08 = complex(1.0f32, 2.0f32); + complex e09(complex(1.0f64, 2.0f64)); + complex e10 = complex(1.0f64, 2.0f64); + complex e11(complex(1.0f128, 2.0f128)); + complex e12 = complex(1.0f128, 2.0f128); // { dg-error "conversion from 'complex<_Float128>' to non-scalar type 'complex<_Float64>' requested" } +#ifdef __STDCPP_FLOAT16_T__ + complex e13(complex(1.0f16, 2.0f16)); + complex e14 = complex(1.0f16, 2.0f16); +#endif +#ifdef __STDCPP_BFLOAT16_T__ + complex e15(complex(1.0bf16, 2.0bf16)); + complex e16 = complex(1.0bf16, 2.0bf16); +#endif + complex f01(complex(1.0f, 2.0f)); + complex f02 = complex(1.0f, 2.0f); + complex f03(complex(1.0, 2.0)); + complex f04 = complex(1.0, 2.0); + complex f05(complex(1.0L, 2.0L)); + complex f06 = complex(1.0L, 2.0L); + complex f07(complex(1.0f32, 2.0f32)); + complex f08 = complex(1.0f32, 2.0f32); + complex f09(complex(1.0f64, 2.0f64)); + complex f10 = complex(1.0f64, 2.0f64); + complex f11(complex(1.0f128, 2.0f128)); + complex f12 = complex(1.0f128, 2.0f128); +#ifdef __STDCPP_FLOAT16_T__ + complex f13(complex(1.0f16, 2.0f16)); + complex f14 = complex(1.0f16, 2.0f16); +#endif +#ifdef __STDCPP_BFLOAT16_T__ + complex f15(complex(1.0bf16, 2.0bf16)); + complex f16 = complex(1.0bf16, 2.0bf16); +#endif +#ifdef __STDCPP_FLOAT16_T__ + complex g01(complex(1.0f, 2.0f)); + complex g02 = complex(1.0f, 2.0f); // { dg-error "conversion from 'complex' to non-scalar type 'complex<_Float16>' requested" "" { target float16 } } + complex g03(complex(1.0, 2.0)); + complex g04 = complex(1.0, 2.0); // { dg-error "conversion from 'complex' to non-scalar type 'complex<_Float16>' requested" "" { target float16 } } + complex g05(complex(1.0L, 2.0L)); + complex g06 = complex(1.0L, 2.0L); // { dg-error "conversion from 'complex' to non-scalar type 'complex<_Float16>' requested" "" { target float16 } } + complex g07(complex(1.0f32, 2.0f32)); + complex g08 = complex(1.0f32, 2.0f32); // { dg-error "conversion from 'complex<_Float32>' to non-scalar type 'complex<_Float16>' requested" "" { target float16 } } + complex g09(complex(1.0f64, 2.0f64)); + complex g10 = complex(1.0f64, 2.0f64); // { dg-error "conversion from 'complex<_Float64>' to non-scalar type 'complex<_Float16>' requested" "" { target float16 } } + complex g11(complex(1.0f128, 2.0f128)); + complex g12 = complex(1.0f128, 2.0f128); // { dg-error "conversion from 'complex<_Float128>' to non-scalar type 'complex<_Float16>' requested" "" { target float16 } } + complex g13(complex(1.0f16, 2.0f16)); + complex g14 = complex(1.0f16, 2.0f16); +#ifdef __STDCPP_BFLOAT16_T__ + complex g15(complex(1.0bf16, 2.0bf16)); + complex g16 = complex(1.0bf16, 2.0bf16); // { dg-error "conversion from 'complex<\[^\n\r]*>' to non-scalar type 'complex<_Float16>' requested" "" { target { float16 && bfloat16 } } } +#endif +#endif +#ifdef __STDCPP_BFLOAT16_T__ + complex h01(complex(1.0f, 2.0f)); + complex h02 = complex(1.0f, 2.0f); // { dg-error "conversion from 'complex' to non-scalar type 'complex<\[^\n\r]*>' requested" "" { target bfloat16 } } + complex h03(complex(1.0, 2.0)); + complex h04 = complex(1.0, 2.0); // { dg-error "conversion from 'complex' to non-scalar type 'complex<\[^\n\r]*>' requested" "" { target bfloat16 } } + complex h05(complex(1.0L, 2.0L)); + complex h06 = complex(1.0L, 2.0L); // { dg-error "conversion from 'complex' to non-scalar type 'complex<\[^\n\r]*>' requested" "" { target bfloat16 } } + complex h07(complex(1.0f32, 2.0f32)); + complex h08 = complex(1.0f32, 2.0f32); // { dg-error "conversion from 'complex<_Float32>' to non-scalar type 'complex<\[^\n\r]*>' requested" "" { target bfloat16 } } + complex h09(complex(1.0f64, 2.0f64)); + complex h10 = complex(1.0f64, 2.0f64); // { dg-error "conversion from 'complex<_Float64>' to non-scalar type 'complex<\[^\n\r]*>' requested" "" { target bfloat16 } } + complex h11(complex(1.0f128, 2.0f128)); + complex h12 = complex(1.0f128, 2.0f128); // { dg-error "conversion from 'complex<_Float128>' to non-scalar type 'complex<\[^\n\r]*>' requested" "" { target bfloat16 } } +#ifdef __STDCPP_FLOAT16_T__ + complex h13(complex(1.0f16, 2.0f16)); + complex h14 = complex(1.0f16, 2.0f16); // { dg-error "conversion from 'complex<_Float16>' to non-scalar type 'complex<\[^\n\r]*>' requested" "" { target { float16 && bfloat16 } } } +#endif + complex h15(complex(1.0bf16, 2.0bf16)); + complex h16 = complex(1.0bf16, 2.0bf16); +#endif +}