From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 25750383F42E; Tue, 13 Jul 2021 21:29:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 25750383F42E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: KWoptJigDG9LXKMyrz0I0mZngXlNyONrhVpheIyi6cRxi8vFKdvkB2U6hfVhhx6T7TIdTQKJaw RexOPG7pcqmA2ONOs9I6c8RhJYdPxuZqOVeZ6oiQjC4vz1Y8vGPntYU41gvDiIlJYD8cI7qe0K bQGtbYpu0mjs+uJajDEh+nDEX6H5DCrJJNLu+p2TwmDupJQ8oN2/FzXuvL3Xjj7Z3LiBQkf4ny iseJZ4gIddVlc9B5R8VbvLDSsfxvOppwKV09XI8fHHBKSPJ2WTMx2Gqpg7SYZb8qzLDviVF26M vkE= X-IronPort-AV: E=Sophos;i="5.84,237,1620720000"; d="scan'208";a="63657441" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 13 Jul 2021 13:29:25 -0800 IronPort-SDR: L/6EDKLVQMyr7KVAGGIAPG64pG8DhKT7LdMiFmFeashswshR8b7bumnjaRBV/eBuQA0G0YiXDP yHs85XdqgUEmEzqFdUz2j6/CzMR1Pwdx0xqJqdv2T79DBXbuqa3Lk174ls6L5PhGLi4DQCe45Y vOZd71FTSAXfW6T8jPIOeanyM3jbmnc8TuI6fjFjBXe8tjnr6mX9ahi73hbKz33kuW91nPxLT+ QiqUzv+f1p5tvQDv+bKiU9z3lspQrHMjMH2vNG/HKPhTKZTIlKPvv8Gcjb6Ovmk26VCNPlJxY6 F5s= From: Sandra Loosemore To: , Subject: [PATCH 2/3] [PR libfortran/101305] Bind(C): Correct sizes of some types in CFI_establish Date: Tue, 13 Jul 2021 15:28:57 -0600 Message-ID: <20210713212859.1532449-3-sandra@codesourcery.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210713212859.1532449-1-sandra@codesourcery.com> References: <20210713212859.1532449-1-sandra@codesourcery.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: svr-orw-mbx-04.mgc.mentorg.com (147.34.90.204) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, 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: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jul 2021 21:29:27 -0000 CFI_establish was failing to set the default elem_len correctly for CFI_type_cptr, CFI_type_cfunptr, CFI_type_long_double, and CFI_type_long_double_Complex. 2021-07-13 Sandra Loosemore libgfortran/ PR libfortran/101305 * runtime/ISO_Fortran_binding.c (CFI_establish): Special-case CFI_type_cptr and CFI_type_cfunptr. Correct size of long double on targets where it has kind 10. --- libgfortran/runtime/ISO_Fortran_binding.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libgfortran/runtime/ISO_Fortran_binding.c b/libgfortran/runtime/ISO_Fortran_binding.c index 28fa9f5..6b5f26c 100644 --- a/libgfortran/runtime/ISO_Fortran_binding.c +++ b/libgfortran/runtime/ISO_Fortran_binding.c @@ -341,9 +341,13 @@ int CFI_establish (CFI_cdesc_t *dv, void *base_addr, CFI_attribute_t attribute, dv->base_addr = base_addr; - if (type == CFI_type_char || type == CFI_type_ucs4_char || - type == CFI_type_struct || type == CFI_type_other) + if (type == CFI_type_char || type == CFI_type_ucs4_char + || type == CFI_type_struct || type == CFI_type_other) dv->elem_len = elem_len; + else if (type == CFI_type_cptr) + dv->elem_len = sizeof (void *); + else if (type == CFI_type_cfunptr) + dv->elem_len = sizeof (void (*)(void)); else { /* base_type describes the intrinsic type with kind parameter. */ @@ -351,16 +355,13 @@ int CFI_establish (CFI_cdesc_t *dv, void *base_addr, CFI_attribute_t attribute, /* base_type_size is the size in bytes of the variable as given by its * kind parameter. */ size_t base_type_size = (type - base_type) >> CFI_type_kind_shift; - /* Kind types 10 have a size of 64 bytes. */ + /* Kind type 10 maps onto the 80-bit long double encoding on x86. + Note that this has different storage size for -m32 than -m64. */ if (base_type_size == 10) - { - base_type_size = 64; - } + base_type_size = sizeof (long double); /* Complex numbers are twice the size of their real counterparts. */ if (base_type == CFI_type_Complex) - { - base_type_size *= 2; - } + base_type_size *= 2; dv->elem_len = base_type_size; } -- 2.8.1