Hello world, here is my first patch made from the git world. It certainly took enough time to work out how to to this, but I think I have it figured out now...
Anyway, the fix is rather straightforward. We cannot have a reference on a function. If this slipped through on parsing, let's issue the error during resolution. Regression-tested. OK for trunk? Regards Thomas 2020-01-16 Thomas König <tkoe...@gcc.gnu.org> PR fortran/44960 * resolve.c (resolve_function): Issue error when a function call contains a reference. 2020-01-16 Thomas König <tkoe...@gcc.gnu.org> PR fortran/44960 * gfortran.dg/function_reference_1.f90: New test.
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 6f2a4c4d65a..1525c00ea4c 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -3129,6 +3129,13 @@ resolve_function (gfc_expr *expr) || sym->intmod_sym_id == GFC_ISYM_CAF_SEND)) return true; + if (expr->ref) + { + gfc_error ("Function call can not contain a reference at %L", + &expr->where); + return false; + } + if (sym && sym->attr.intrinsic && !gfc_resolve_intrinsic (sym, &expr->where)) return false; diff --git a/gcc/testsuite/gfortran.dg/function_reference_1.f90 b/gcc/testsuite/gfortran.dg/function_reference_1.f90 new file mode 100644 index 00000000000..78c92a6f20d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/function_reference_1.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! PR 44960 - this was erroneusly accepted. +! Original test case by Daniel Franke. + +type t + integer :: a +end type t +type(t) :: foo +print *, foo(1)%a ! { dg-error "Function call can not contain a reference" } +end +
! { dg-do compile } ! PR 44960 - this was erroneusly accepted. ! Original test case by Daniel Franke. type t integer :: a end type t type(t) :: foo print *, foo(1)%a ! { dg-error "Function call can not contain a reference" } end