mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-05 20:51:45 +08:00
Fortran: flag formal argument before resolving an array spec [PR98016].
2020-12-05 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/98016 * resolve.c (resolve_symbol): Set formal_arg_flag before resolving an array spec and restore value afterwards. gcc/testsuite/ PR fortran/98016 * gfortran.dg/pr98016.f90: New test.
This commit is contained in:
parent
1352bc88a0
commit
7ae210d5db
@ -15394,8 +15394,12 @@ resolve_symbol (gfc_symbol *sym)
|
||||
else if (mp_flag && sym->attr.flavor == FL_PROCEDURE && sym->attr.function)
|
||||
{
|
||||
bool saved_specification_expr = specification_expr;
|
||||
bool saved_formal_arg_flag = formal_arg_flag;
|
||||
|
||||
specification_expr = true;
|
||||
formal_arg_flag = true;
|
||||
gfc_resolve_array_spec (sym->result->as, false);
|
||||
formal_arg_flag = saved_formal_arg_flag;
|
||||
specification_expr = saved_specification_expr;
|
||||
}
|
||||
|
||||
|
19
gcc/testsuite/gfortran.dg/pr98016.f90
Normal file
19
gcc/testsuite/gfortran.dg/pr98016.f90
Normal file
@ -0,0 +1,19 @@
|
||||
! { dg-do compile }
|
||||
!
|
||||
! Fix for PR98016 - Used to fail with Error: Variable ‘n’ cannot appear in the
|
||||
! expression at (1) for line 16. Workaround was to declare y to be real.
|
||||
!
|
||||
! Posted by Juergen Reuter <juergen.reuter@desy.de>
|
||||
!
|
||||
program is_it_valid
|
||||
dimension y(3)
|
||||
n=3
|
||||
y=func(1.0)
|
||||
print *, y
|
||||
stop
|
||||
contains
|
||||
function func(x) result (y)
|
||||
dimension y(n)
|
||||
y=x
|
||||
end function
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user