public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-11] Bind(C): Correct sizes of some types in CFI_establish
@ 2021-08-20  3:05 Sandra Loosemore
  0 siblings, 0 replies; only message in thread
From: Sandra Loosemore @ 2021-08-20  3:05 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2942b4f3fb8fc574ef0d4ee868c9057d7e9bab47

commit 2942b4f3fb8fc574ef0d4ee868c9057d7e9bab47
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Wed Aug 11 18:41:44 2021 -0700

    Bind(C): Correct sizes of some types in CFI_establish
    
    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.
    
    (cherry picked from commit c4dc9f590181321c36d3f3ef72c50b3c47bbfe7c)

Diff:
---
 libgfortran/ChangeLog.omp                 | 11 +++++++++++
 libgfortran/runtime/ISO_Fortran_binding.c | 19 ++++++++++---------
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/libgfortran/ChangeLog.omp b/libgfortran/ChangeLog.omp
index 6dd605ca6f8..8abf0e52817 100644
--- a/libgfortran/ChangeLog.omp
+++ b/libgfortran/ChangeLog.omp
@@ -1,3 +1,14 @@
+2021-08-11  Sandra Loosemore  <sandra@codesourcery.com>
+
+	Backported from master:
+
+	2021-07-13  Sandra Loosemore  <sandra@codesourcery.com>
+
+	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.
+
 2021-08-11  Sandra Loosemore  <sandra@codesourcery.com>
 
 	Backported from master:
diff --git a/libgfortran/runtime/ISO_Fortran_binding.c b/libgfortran/runtime/ISO_Fortran_binding.c
index 9c871d3e989..b1e51612e2b 100644
--- a/libgfortran/runtime/ISO_Fortran_binding.c
+++ b/libgfortran/runtime/ISO_Fortran_binding.c
@@ -380,9 +380,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. */
@@ -390,16 +394,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;
     }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-20  3:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20  3:05 [gcc/devel/omp/gcc-11] Bind(C): Correct sizes of some types in CFI_establish Sandra Loosemore

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).