From 37bfd49f329f3c2107068040c1421cfb6ef71fcb Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Sun, 16 Sep 2012 22:12:21 +0200 Subject: re PR fortran/54387 ([F03] Wrongly accepts non-proc result variable on the RHS of a proc-pointer assignment) 2012-09-16 Janus Weil PR fortran/54387 * expr.c (gfc_check_pointer_assign): Check for result of embracing function. 2012-09-16 Janus Weil PR fortran/54387 * gfortran.dg/proc_ptr_38.f90: New. From-SVN: r191364 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/expr.c | 9 +++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/proc_ptr_38.f90 | 16 ++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/proc_ptr_38.f90 (limited to 'gcc') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 24ff91f..bf9f0b93 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2012-09-16 Janus Weil + + PR fortran/54387 + * expr.c (gfc_check_pointer_assign): Check for result of embracing + function. + 2012-09-16 Tobias Burnus * trans-decl.c (gfc_generate_function_code): Fix diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index bc1f5e3..dced05d 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -3430,6 +3430,15 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue) gfc_resolve_intrinsic (sym, &rvalue->where); attr = gfc_expr_attr (rvalue); } + /* Check for result of embracing function. */ + if (sym == gfc_current_ns->proc_name + && sym->attr.function && sym->result == sym) + { + gfc_error ("Function result '%s' is invalid as proc-target " + "in procedure pointer assignment at %L", + sym->name, &rvalue->where); + return FAILURE; + } } if (attr.abstract) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e38e779..978e3df 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-09-16 Janus Weil + + PR fortran/54387 + * gfortran.dg/proc_ptr_38.f90: New. + 2012-09-16 John David Anglin PR debug/54460 diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_38.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_38.f90 new file mode 100644 index 0000000..9387b6b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/proc_ptr_38.f90 @@ -0,0 +1,16 @@ +! { dg-do compile } +! +! PR 54387: [F03] Wrongly accepts non-proc result variable on the RHS of a proc-pointer assignment +! +! Contributed by James Van Buskirk + +integer function foo() + procedure(), pointer :: i + i => foo ! { dg-error "is invalid as proc-target in procedure pointer assignment" } +end + +recursive function bar() result (res) + integer :: res + procedure(), pointer :: j + j => bar +end -- cgit v1.1