From: Janus Weil Date: Sat, 2 Jul 2011 11:08:41 +0000 (+0200) Subject: re PR fortran/49562 ([OOP] assigning value to type-bound function) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=49860194e29e3cb2d571e9f9a413b1858967953e;p=gcc.git re PR fortran/49562 ([OOP] assigning value to type-bound function) 2011-07-02 Janus Weil PR fortran/49562 * expr.c (gfc_check_vardef_context): Handle type-bound procedures. 2011-07-02 Janus Weil PR fortran/49562 * gfortran.dg/typebound_proc_23.f90: New. From-SVN: r175779 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 055c15d29e1..e2d5d124dac 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2011-07-02 Janus Weil + + PR fortran/49562 + * expr.c (gfc_check_vardef_context): Handle type-bound procedures. + 2011-06-30 Jakub Jelinek PR fortran/49540 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 4a7a951b6d6..6dcfda1e53a 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -4394,8 +4394,8 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj, sym = e->value.function.esym ? e->value.function.esym : e->symtree->n.sym; } - if (!pointer && e->expr_type == EXPR_FUNCTION - && sym->result->attr.pointer) + attr = gfc_expr_attr (e); + if (!pointer && e->expr_type == EXPR_FUNCTION && attr.pointer) { if (!(gfc_option.allow_std & GFC_STD_F2008)) { @@ -4432,7 +4432,6 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj, /* Find out whether the expr is a pointer; this also means following component references to the last one. */ - attr = gfc_expr_attr (e); is_pointer = (attr.pointer || attr.proc_pointer); if (pointer && !is_pointer) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5d44545dd84..925423540c8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-07-02 Janus Weil + + PR fortran/49562 + * gfortran.dg/typebound_proc_23.f90: New. + 2011-07-01 Jonathan Wakely PR c++/49605 diff --git a/gcc/testsuite/gfortran.dg/typebound_proc_23.f90 b/gcc/testsuite/gfortran.dg/typebound_proc_23.f90 new file mode 100644 index 00000000000..ff682a41b36 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/typebound_proc_23.f90 @@ -0,0 +1,32 @@ +! { dg-do run } +! +! PR 49562: [4.6/4.7 Regression] [OOP] assigning value to type-bound function +! +! Contributed by Hans-Werner Boschmann + +module ice + type::ice_type + contains + procedure::ice_func + end type + integer, target :: it = 0 +contains + function ice_func(this) + integer, pointer :: ice_func + class(ice_type)::this + ice_func => it + end function ice_func + subroutine ice_sub(a) + class(ice_type)::a + a%ice_func() = 1 + end subroutine ice_sub +end module + +use ice +type(ice_type) :: t +if (it/=0) call abort() +call ice_sub(t) +if (it/=1) call abort() +end + +! { dg-final { cleanup-modules "ice" } }