aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/expr.c
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2021-12-09 22:57:13 +0100
committerHarald Anlauf <anlauf@gmx.de>2021-12-10 18:53:09 +0100
commitbb6a1ebb8585b85879735d0d6df9535885fad165 (patch)
treef9c186dabaacf7ae6f1f7693c2e1c5e06ab42971 /gcc/fortran/expr.c
parent982a2c9b7866558039df61b0596caad57c94c8c4 (diff)
downloadgcc-bb6a1ebb8585b85879735d0d6df9535885fad165.zip
gcc-bb6a1ebb8585b85879735d0d6df9535885fad165.tar.gz
gcc-bb6a1ebb8585b85879735d0d6df9535885fad165.tar.bz2
Fortran: fix check for pointer dummy arguments with INTENT(IN)
gcc/fortran/ChangeLog: PR fortran/103418 * check.c (variable_check): Replace previous check of procedure dummy arguments with INTENT(IN) attribute when passed to intrinsic procedures by gfc_check_vardef_context. * expr.c (gfc_check_vardef_context): Correct check of INTENT(IN) dummy arguments for the case of sub-components of a CLASS pointer. gcc/testsuite/ChangeLog: PR fortran/103418 * gfortran.dg/move_alloc_8.f90: Adjust error messages. * gfortran.dg/pointer_intent_9.f90: New test.
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r--gcc/fortran/expr.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 8708932..b874607 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -6254,10 +6254,13 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj,
{
if (ptr_component && ref->type == REF_COMPONENT)
check_intentin = false;
- if (ref->type == REF_COMPONENT && ref->u.c.component->attr.pointer)
+ if (ref->type == REF_COMPONENT)
{
- ptr_component = true;
- if (!pointer)
+ gfc_component *comp = ref->u.c.component;
+ ptr_component = (comp->ts.type == BT_CLASS && comp->attr.class_ok)
+ ? CLASS_DATA (comp)->attr.class_pointer
+ : comp->attr.pointer;
+ if (ptr_component && !pointer)
check_intentin = false;
}
if (ref->type == REF_INQUIRY