diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2021-04-09 10:18:24 +0200 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2021-04-09 10:41:39 +0200 |
commit | d31f485dedc86773152d0384bc6ba5583b259a42 (patch) | |
tree | b3e6029593f7a3410761fab418466d5bf92a7f02 | |
parent | 8cc863ca8f48662e9c9339710fa303587479bf71 (diff) | |
download | gcc-d31f485dedc86773152d0384bc6ba5583b259a42.zip gcc-d31f485dedc86773152d0384bc6ba5583b259a42.tar.gz gcc-d31f485dedc86773152d0384bc6ba5583b259a42.tar.bz2 |
Fortran: Fix fndecl with -fcoarray=lib [PR99817]
gcc/fortran/ChangeLog:
PR fortran/99817
* trans-types.c (gfc_get_function_type): Also generate hidden
coarray argument for character arguments.
gcc/testsuite/ChangeLog:
PR fortran/99817
* gfortran.dg/coarray/dummy_2.f90: New test.
-rw-r--r-- | gcc/fortran/trans-types.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/coarray/dummy_2.f90 | 26 |
2 files changed, 34 insertions, 8 deletions
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index bc7aac1..9f21b3e 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -3152,14 +3152,14 @@ gfc_get_function_type (gfc_symbol * sym, gfc_actual_arglist *actual_args, vec_safe_push (typelist, boolean_type_node); /* Coarrays which are descriptorless or assumed-shape pass with -fcoarray=lib the token and the offset as hidden arguments. */ - else if (arg - && flag_coarray == GFC_FCOARRAY_LIB - && ((arg->ts.type != BT_CLASS - && arg->attr.codimension - && !arg->attr.allocatable) - || (arg->ts.type == BT_CLASS - && CLASS_DATA (arg)->attr.codimension - && !CLASS_DATA (arg)->attr.allocatable))) + if (arg + && flag_coarray == GFC_FCOARRAY_LIB + && ((arg->ts.type != BT_CLASS + && arg->attr.codimension + && !arg->attr.allocatable) + || (arg->ts.type == BT_CLASS + && CLASS_DATA (arg)->attr.codimension + && !CLASS_DATA (arg)->attr.allocatable))) { vec_safe_push (typelist, pvoid_type_node); /* caf_token. */ vec_safe_push (typelist, gfc_array_index_type); /* caf_offset. */ diff --git a/gcc/testsuite/gfortran.dg/coarray/dummy_2.f90 b/gcc/testsuite/gfortran.dg/coarray/dummy_2.f90 new file mode 100644 index 0000000..3526374 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray/dummy_2.f90 @@ -0,0 +1,26 @@ +! { dg-do compile } +! +! PR fortran/99817 +! +! Contributed by G. Steinmetz +! +subroutine s1 (x) + character(*) :: x(*)[*] +end + +subroutine s2 (x) + character(*), dimension(*), codimension[*] :: x + integer :: i + i = len(x) +end + +subroutine s3 (x, y) + character(*), dimension(:) :: x[*] + character(*) :: y +end + +subroutine s4 (x, y, z) + character(*), dimension(:) :: x[2, *] + character(*), dimension(*) :: y + character(*) :: z +end |