aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-types.cc
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2023-12-04 22:44:53 +0100
committerHarald Anlauf <anlauf@gmx.de>2023-12-05 19:16:19 +0100
commit9c3a880feecf81c310b4ade210fbd7004c9aece7 (patch)
tree89b8ee691086d727fad4c35cf767f40880c94df5 /gcc/fortran/trans-types.cc
parent1dad3df1e7f3fd73f157f88561ef424b6853d960 (diff)
downloadgcc-9c3a880feecf81c310b4ade210fbd7004c9aece7.zip
gcc-9c3a880feecf81c310b4ade210fbd7004c9aece7.tar.gz
gcc-9c3a880feecf81c310b4ade210fbd7004c9aece7.tar.bz2
Fortran: allow RESTRICT qualifier also for optional arguments [PR100988]
gcc/fortran/ChangeLog: PR fortran/100988 * gfortran.h (IS_PROC_POINTER): New macro. * trans-types.cc (gfc_sym_type): Use macro in determination if the restrict qualifier can be used for a dummy variable. Fix logic to allow the restrict qualifier also for optional arguments, and to not apply it to pointer or proc_pointer arguments. gcc/testsuite/ChangeLog: PR fortran/100988 * gfortran.dg/coarray_poly_6.f90: Adjust pattern. * gfortran.dg/coarray_poly_7.f90: Likewise. * gfortran.dg/coarray_poly_8.f90: Likewise. * gfortran.dg/missing_optional_dummy_6a.f90: Likewise. * gfortran.dg/pr100988.f90: New test. Co-authored-by: Tobias Burnus <tobias@codesourcery.com>
Diffstat (limited to 'gcc/fortran/trans-types.cc')
-rw-r--r--gcc/fortran/trans-types.cc13
1 files changed, 6 insertions, 7 deletions
diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index 084b8c3..5b11ffc 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -2327,8 +2327,8 @@ gfc_sym_type (gfc_symbol * sym, bool is_bind_c)
else
byref = 0;
- restricted = !sym->attr.target && !sym->attr.pointer
- && !sym->attr.proc_pointer && !sym->attr.cray_pointee;
+ restricted = (!sym->attr.target && !IS_POINTER (sym)
+ && !IS_PROC_POINTER (sym) && !sym->attr.cray_pointee);
if (!restricted)
type = gfc_nonrestricted_type (type);
@@ -2384,11 +2384,10 @@ gfc_sym_type (gfc_symbol * sym, bool is_bind_c)
|| (sym->ns->proc_name && sym->ns->proc_name->attr.entry_master))
type = build_pointer_type (type);
else
- {
- type = build_reference_type (type);
- if (restricted)
- type = build_qualified_type (type, TYPE_QUAL_RESTRICT);
- }
+ type = build_reference_type (type);
+
+ if (restricted)
+ type = build_qualified_type (type, TYPE_QUAL_RESTRICT);
}
return (type);