diff options
author | Andre Vehreschild <vehre@gcc.gnu.org> | 2025-03-17 08:24:04 +0100 |
---|---|---|
committer | Andre Vehreschild <vehre@gcc.gnu.org> | 2025-03-19 14:55:59 +0100 |
commit | 9a13dc48a3ac3282aaf9a77516b4f02faa60e393 (patch) | |
tree | bbc6667b99f1313987a97b49d3174fb959eca66d | |
parent | d50171bc07006dfb56cae487d72913e5d2567716 (diff) | |
download | gcc-9a13dc48a3ac3282aaf9a77516b4f02faa60e393.zip gcc-9a13dc48a3ac3282aaf9a77516b4f02faa60e393.tar.gz gcc-9a13dc48a3ac3282aaf9a77516b4f02faa60e393.tar.bz2 |
Fortran: Fix comp call in associate [PR119272]
PR fortran/119272
gcc/fortran/ChangeLog:
* resolve.cc (resolve_compcall): Postpone error report when
symbol is not resolved yet for component call resolve.
gcc/testsuite/ChangeLog:
* gfortran.dg/associate_74.f90: New test.
-rw-r--r-- | gcc/fortran/resolve.cc | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/associate_74.f90 | 47 |
2 files changed, 50 insertions, 2 deletions
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index ddd9827..b9c469a 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -7351,8 +7351,9 @@ resolve_compcall (gfc_expr* e, const char **name) /* Check that's really a FUNCTION. */ if (!e->value.compcall.tbp->function) { - gfc_error ("%qs at %L should be a FUNCTION", - e->value.compcall.name, &e->where); + if (e->symtree && e->symtree->n.sym->resolve_symbol_called) + gfc_error ("%qs at %L should be a FUNCTION", e->value.compcall.name, + &e->where); return false; } diff --git a/gcc/testsuite/gfortran.dg/associate_74.f90 b/gcc/testsuite/gfortran.dg/associate_74.f90 new file mode 100644 index 0000000..057d635 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_74.f90 @@ -0,0 +1,47 @@ +!{ dg-do run } + +! Check that PR119272 is fixed +! Contributed by Xing Jing Wei <xingjingwei666@gmail.com> + +module pr119272_module + type, public :: test_type + contains + procedure :: scal_function + procedure :: arr_function + end type test_type + contains + function scal_function(this) result(smth) + class(test_type) :: this + integer :: smth + smth = 2 + end function + function arr_function(this) result(smth) + class(test_type) :: this + integer :: smth(9) + smth = (/(i, i=1, 9)/) + end function +end module + +program pr119272 + use pr119272_module + implicit none + + type(test_type) :: a + + call test_subroutine(a) + contains + subroutine test_subroutine(a) + class(test_type) :: a + integer :: i + integer,parameter :: temp_int(3) = [ 1, 2, 3] + integer,parameter :: identity(9) = (/(i* 5, i= 9, 1, -1)/) + associate(temp => temp_int(a%scal_function())) + if (temp /= 2) stop 1 + end associate + + associate(temparr => identity(a%arr_function())) + if (any(temparr /= (/(i* 5, i= 9, 1, -1)/))) stop 2 + end associate + end subroutine +end program + |