From: Sandra Loosemore <sandra@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>, <fortran@gcc.gnu.org>
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 [thread overview]
Message-ID: <20210713212859.1532449-3-sandra@codesourcery.com> (raw)
In-Reply-To: <20210713212859.1532449-1-sandra@codesourcery.com>
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 <sandra@codesourcery.com>
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
next prev parent reply other threads:[~2021-07-13 21:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-13 21:28 [PATCH 0/3] [PR libfortran/101305] Bind(C): Fix kind/size mappings Sandra Loosemore
2021-07-13 21:28 ` [PATCH 1/3] [PR libfortran/101305] Bind(C): Fix type encodings in ISO_Fortran_binding.h Sandra Loosemore
2021-07-21 10:03 ` Tobias Burnus
2021-07-13 21:28 ` Sandra Loosemore [this message]
2021-07-21 9:48 ` [PATCH 2/3] [PR libfortran/101305] Bind(C): Correct sizes of some types in CFI_establish Tobias Burnus
2021-07-13 21:28 ` [PATCH 3/3] [PR libfortran/101305] Fix ISO_Fortran_binding.h paths in gfortran testsuite Sandra Loosemore
2021-07-21 10:17 ` Tobias Burnus
2021-07-23 14:15 ` Tobias Burnus
2021-07-23 20:43 ` Sandra Loosemore
2021-07-26 9:45 ` Tobias Burnus
2021-07-26 20:13 ` Sandra Loosemore
2021-07-28 4:36 ` Sandra Loosemore
2021-07-28 11:22 ` [Patch] gfortran.dg/dg.exp: Add libgfortran as -I flag for ISO*.h [PR101305] (was: [PATCH 3/3] [PR libfortran/101305] Fix ISO_Fortran_binding.h paths in gfortran testsuite) Tobias Burnus
2021-07-28 22:56 ` Jakub Jelinek
2021-07-29 7:09 ` Jakub Jelinek
2021-07-29 9:51 ` [Patch] testsuite/lib/gfortran.exp: Add -I for ISO*.h [PR101305, PR101660] (was: Re: [Patch] gfortran.dg/dg.exp: Add libgfortran as -I flag for ISO*.h [PR101305] (was: [PATCH 3/3] [PR libfortran/101305] Fix ISO_Fortran_binding.h paths in gfortran testsuite)) Tobias Burnus
2021-08-09 10:50 ` committed – " Tobias Burnus
2021-08-04 9:00 ` [PATCH 3/3] [PR libfortran/101305] Fix ISO_Fortran_binding.h paths in gfortran testsuite Andreas Schwab
2021-08-09 10:52 ` Tobias Burnus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210713212859.1532449-3-sandra@codesourcery.com \
--to=sandra@codesourcery.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).