Commit 6409a3c0 by Tobias Burnus Committed by Tobias Burnus

Fortran] PR92277 - Fix assumed-rank array with bind(C)

        gcc/fortran/
        PR fortran/92277
        * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Fix DECL_ARTIFICIAL
        checking.

        gcc/testsuite/
        PR fortran/92277
        * fortran.dg/pr92277.f90: New.

From-SVN: r277661
parent 6773658a
2019-10-31 Tobias Burnus <tobias@codesourcery.com>
PR fortran/92277
* trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Fix DECL_ARTIFICIAL
checking.
2019-10-30 Tobias Burnus <tobias@codesourcery.com> 2019-10-30 Tobias Burnus <tobias@codesourcery.com>
PR fortran/92208 PR fortran/92208
......
...@@ -5239,6 +5239,9 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym) ...@@ -5239,6 +5239,9 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym)
if (POINTER_TYPE_P (TREE_TYPE (parmse->expr))) if (POINTER_TYPE_P (TREE_TYPE (parmse->expr)))
parmse->expr = build_fold_indirect_ref_loc (input_location, parmse->expr = build_fold_indirect_ref_loc (input_location,
parmse->expr); parmse->expr);
bool is_artificial = (INDIRECT_REF_P (parmse->expr)
? DECL_ARTIFICIAL (TREE_OPERAND (parmse->expr, 0))
: DECL_ARTIFICIAL (parmse->expr));
/* Unallocated allocatable arrays and unassociated pointer arrays /* Unallocated allocatable arrays and unassociated pointer arrays
need their dtype setting if they are argument associated with need their dtype setting if they are argument associated with
...@@ -5258,7 +5261,7 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym) ...@@ -5258,7 +5261,7 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym)
type = e->ts.type != BT_ASSUMED ? gfc_typenode_for_spec (&e->ts) : type = e->ts.type != BT_ASSUMED ? gfc_typenode_for_spec (&e->ts) :
NULL_TREE; NULL_TREE;
if (type && DECL_ARTIFICIAL (parmse->expr) if (type && is_artificial
&& type != gfc_get_element_type (TREE_TYPE (parmse->expr))) && type != gfc_get_element_type (TREE_TYPE (parmse->expr)))
{ {
/* Obtain the offset to the data. */ /* Obtain the offset to the data. */
...@@ -5271,7 +5274,7 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym) ...@@ -5271,7 +5274,7 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym)
gfc_get_dtype_rank_type (e->rank, type)); gfc_get_dtype_rank_type (e->rank, type));
} }
else if (type == NULL_TREE else if (type == NULL_TREE
|| (!is_subref_array (e) && !DECL_ARTIFICIAL (parmse->expr))) || (!is_subref_array (e) && !is_artificial))
{ {
/* Make sure that the span is set for expressions where it /* Make sure that the span is set for expressions where it
might not have been done already. */ might not have been done already. */
......
2019-10-31 Tobias Burnus <tobias@codesourcery.com>
PR fortran/92277
* fortran.dg/pr92277.f90: New.
2019-10-31 Jakub Jelinek <jakub@redhat.com> 2019-10-31 Jakub Jelinek <jakub@redhat.com>
PR middle-end/92231 PR middle-end/92231
......
! { dg-do compile }
!
! PR fortran/92277
!
! Contributed by José Rui Faustino de Sousa
!
module arr_m
implicit none
contains
subroutine arr_set(this, that)
integer, intent(out) :: this(..)
integer, optional, intent(out) :: that(..)
interface
subroutine arr_set_c(this) bind(c)
use, intrinsic :: iso_c_binding, only: c_int
implicit none
integer(kind=c_int), intent(out) :: this(..)
end subroutine arr_set_c
subroutine arr_set_c_opt(this) bind(c)
use, intrinsic :: iso_c_binding, only: c_int
implicit none
integer(kind=c_int), optional, intent(out) :: this(..)
end subroutine arr_set_c_opt
end interface
call arr_set_c(this)
call arr_set_c(that)
call arr_set_c_opt(this)
call arr_set_c_opt(that)
end subroutine arr_set
end module arr_m
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment