diff options
Diffstat (limited to 'gcc')
-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 + |