aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-expr.cc
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2024-12-23 17:56:46 +0100
committerHarald Anlauf <anlauf@gmx.de>2024-12-23 18:22:41 +0100
commitf25250e0d5938a81f9f1b37ca873381dcfa26211 (patch)
treeb54625537e209b1a54d1a56e7a52c77acd1a74da /gcc/fortran/trans-expr.cc
parentdae506f73bdc03628e23d5e8c566b2e642086b60 (diff)
downloadgcc-f25250e0d5938a81f9f1b37ca873381dcfa26211.zip
gcc-f25250e0d5938a81f9f1b37ca873381dcfa26211.tar.gz
gcc-f25250e0d5938a81f9f1b37ca873381dcfa26211.tar.bz2
Fortran: fix NULL without MOLD argument to scalar DT pointer dummy [PR118179]
Commit r15-6408 overlooked the case of passing NULL without MOLD argument to a derived type pointer dummy argument without specified intent. Since it is prohibited to modify the dummy argument, we treat it as if intent(in) were specified and suppress copying back of the pointer address. PR fortran/118179 gcc/fortran/ChangeLog: * trans-expr.cc (conv_null_actual): Suppress copying back of pointer address for unspecified intent. gcc/testsuite/ChangeLog: * gfortran.dg/null_actual_7.f90: Extend testcase to also cover scalar variants with pointer or allocatable dummy with or without specified intent.
Diffstat (limited to 'gcc/fortran/trans-expr.cc')
-rw-r--r--gcc/fortran/trans-expr.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 9aedecb..4b02298 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -6488,7 +6488,8 @@ conv_null_actual (gfc_se * parmse, gfc_expr * e, gfc_symbol * fsym)
int dummy_rank;
tree tmp = parmse->expr;
- if (fsym->attr.allocatable && fsym->attr.intent == INTENT_UNKNOWN)
+ if ((fsym->attr.allocatable || fsym->attr.pointer)
+ && fsym->attr.intent == INTENT_UNKNOWN)
fsym->attr.intent = INTENT_IN;
tmp = gfc_conv_scalar_to_descriptor (parmse, tmp, fsym->attr);
dummy_rank = fsym->as ? fsym->as->rank : 0;