aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-expr.cc
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2022-10-17 18:15:16 +0200
committerTobias Burnus <tobias@codesourcery.com>2022-10-17 18:15:16 +0200
commit8950288333162caa68b85c71ed2d02f40976ddb9 (patch)
tree20b2d8a10c970cca56a552c01bfc66782031a456 /gcc/fortran/trans-expr.cc
parent3bd5d9a28e1ce4d1615902397b5ad50909839d6d (diff)
downloadgcc-8950288333162caa68b85c71ed2d02f40976ddb9.zip
gcc-8950288333162caa68b85c71ed2d02f40976ddb9.tar.gz
gcc-8950288333162caa68b85c71ed2d02f40976ddb9.tar.bz2
Fortran: Fixes for kind=4 characters strings [PR107266]
PR fortran/107266 gcc/fortran/ * trans-expr.cc (gfc_conv_string_parameter): Use passed type to honor character kind. * trans-types.cc (gfc_sym_type): Honor character kind. * trans-decl.cc (gfc_conv_cfi_to_gfc): Fix handling kind=4 character strings. gcc/testsuite/ * gfortran.dg/char4_decl.f90: New test. * gfortran.dg/char4_decl-2.f90: New test.
Diffstat (limited to 'gcc/fortran/trans-expr.cc')
-rw-r--r--gcc/fortran/trans-expr.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 1551a2e..e7b9211 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -10374,15 +10374,15 @@ gfc_conv_string_parameter (gfc_se * se)
|| TREE_CODE (TREE_TYPE (se->expr)) == INTEGER_TYPE)
&& TYPE_STRING_FLAG (TREE_TYPE (se->expr)))
{
+ type = TREE_TYPE (se->expr);
if (TREE_CODE (se->expr) != INDIRECT_REF)
- {
- type = TREE_TYPE (se->expr);
- se->expr = gfc_build_addr_expr (build_pointer_type (type), se->expr);
- }
+ se->expr = gfc_build_addr_expr (build_pointer_type (type), se->expr);
else
{
- type = gfc_get_character_type_len (gfc_default_character_kind,
- se->string_length);
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ type = TREE_TYPE (type);
+ type = gfc_get_character_type_len_for_eltype (type,
+ se->string_length);
type = build_pointer_type (type);
se->expr = gfc_build_addr_expr (type, se->expr);
}