public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-11] Bind(c): signed char is not a Fortran character type
@ 2021-07-27  9:50 Tobias Burnus
  0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2021-07-27  9:50 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:56a797429f1da90e95046b2f8185d462b2720632

commit 56a797429f1da90e95046b2f8185d462b2720632
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Tue Jul 27 11:40:44 2021 +0200

    Bind(c): signed char is not a Fortran character type
    
    CFI_allocate and CFI_select_part were incorrectly treating
    CFI_type_signed_char as a Fortran character type for the purpose of
    deciding whether or not to use the elem_len argument.  It is a Fortran
    integer type per table 18.2 in the 2018 Fortran standard.
    
    Other functions in ISO_Fortran_binding.c appeared to handle this case
    correctly already.
    
    2021-07-15  Sandra Loosemore  <sandra@codesourcery.com>
    
    libgfortran/
            * runtime/ISO_Fortran_binding.c (CFI_allocate): Don't use elem_len
            for CFI_type_signed_char.
            (CFI_select_part): Likewise.
    
    (cherry picked from commit e4966e1d1de54441bdaed54eb00084db4193bbbf)

Diff:
---
 gcc/fortran/ChangeLog.omp                 |  9 +++++++++
 libgfortran/runtime/ISO_Fortran_binding.c | 13 ++++++-------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index 6f1ced4bf1f..9b79c9439f9 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,12 @@
+2021-07-27  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2021-07-15  Sandra Loosemore  <sandra@codesourcery.com>
+
+	* runtime/ISO_Fortran_binding.c (CFI_allocate): Don't use elem_len
+	for CFI_type_signed_char.
+	(CFI_select_part): Likewise.
+
 2021-07-27  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/libgfortran/runtime/ISO_Fortran_binding.c b/libgfortran/runtime/ISO_Fortran_binding.c
index 73fb4c4e729..773d24e9b71 100644
--- a/libgfortran/runtime/ISO_Fortran_binding.c
+++ b/libgfortran/runtime/ISO_Fortran_binding.c
@@ -229,10 +229,9 @@ CFI_allocate (CFI_cdesc_t *dv, const CFI_index_t lower_bounds[],
 	}
     }
 
-  /* If the type is a character, the descriptor's element length is replaced
-     by the elem_len argument. */
-  if (dv->type == CFI_type_char || dv->type == CFI_type_ucs4_char ||
-      dv->type == CFI_type_signed_char)
+  /* If the type is a Fortran character type, the descriptor's element
+     length is replaced by the elem_len argument. */
+  if (dv->type == CFI_type_char || dv->type == CFI_type_ucs4_char)
     dv->elem_len = elem_len;
 
   /* Dimension information and calculating the array length. */
@@ -731,9 +730,9 @@ int CFI_select_part (CFI_cdesc_t *result, const CFI_cdesc_t *source,
 	}
     }
 
-  /* Element length. */
-  if (result->type == CFI_type_char || result->type == CFI_type_ucs4_char ||
-      result->type == CFI_type_signed_char)
+  /* Element length is ignored unless result->type specifies a Fortran
+     character type.  */
+  if (result->type == CFI_type_char || result->type == CFI_type_ucs4_char)
     result->elem_len = elem_len;
 
   if (unlikely (compile_options.bounds_check))


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

only message in thread, other threads:[~2021-07-27  9:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27  9:50 [gcc/devel/omp/gcc-11] Bind(c): signed char is not a Fortran character type Tobias Burnus

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