Commit aa9aed00 by Janus Weil

re PR fortran/41706 ([OOP] Calling one TBP as an actual argument of another TBP)

2009-10-21  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/41706
	PR fortran/41766
	* match.c (select_type_set_tmp): Set flavor for temporary.
	* resolve.c (resolve_class_typebound_call): Correctly resolve actual
	arguments.


2009-10-21  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/41706
	PR fortran/41766
	* gfortran.dg/class_9.f03: Extended test case.
	* gfortran.dg/select_type_7.f03: New test case.

From-SVN: r153049
parent ea524613
2009-10-21 Janus Weil <janus@gcc.gnu.org>
PR fortran/41706
PR fortran/41766
* match.c (select_type_set_tmp): Set flavor for temporary.
* resolve.c (resolve_class_typebound_call): Correctly resolve actual
arguments.
2009-10-20 Paul Thomas <pault@gcc.gnu.org> 2009-10-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/41706 PR fortran/41706
......
...@@ -4047,9 +4047,10 @@ select_type_set_tmp (gfc_typespec *ts) ...@@ -4047,9 +4047,10 @@ select_type_set_tmp (gfc_typespec *ts)
sprintf (name, "tmp$%s", ts->u.derived->name); sprintf (name, "tmp$%s", ts->u.derived->name);
gfc_get_sym_tree (name, gfc_current_ns, &tmp, false); gfc_get_sym_tree (name, gfc_current_ns, &tmp, false);
tmp->n.sym->ts = *ts; gfc_add_type (tmp->n.sym, ts, NULL);
tmp->n.sym->attr.referenced = 1; gfc_set_sym_referenced (tmp->n.sym);
tmp->n.sym->attr.pointer = 1; gfc_add_pointer (&tmp->n.sym->attr, NULL);
gfc_add_flavor (&tmp->n.sym->attr, FL_VARIABLE, name, NULL);
select_type_stack->tmp = tmp; select_type_stack->tmp = tmp;
} }
......
...@@ -5369,7 +5369,7 @@ resolve_class_typebound_call (gfc_code *code) ...@@ -5369,7 +5369,7 @@ resolve_class_typebound_call (gfc_code *code)
} }
/* Resolve the argument expressions, */ /* Resolve the argument expressions, */
resolve_arg_exprs (code->ext.actual); resolve_arg_exprs (code->expr1->value.compcall.actual);
/* Get the data component, which is of the declared type. */ /* Get the data component, which is of the declared type. */
derived = declared->components->ts.u.derived; derived = declared->components->ts.u.derived;
......
2009-10-21 Janus Weil <janus@gcc.gnu.org>
PR fortran/41706
PR fortran/41766
* gfortran.dg/class_9.f03: Extended test case.
* gfortran.dg/select_type_7.f03: New test case.
2009-10-20 Richard Guenther <rguenther@suse.de> 2009-10-20 Richard Guenther <rguenther@suse.de>
* gcc.dg/lto/20091020-3_0.c: New testcase. * gcc.dg/lto/20091020-3_0.c: New testcase.
......
...@@ -11,6 +11,7 @@ contains ...@@ -11,6 +11,7 @@ contains
procedure, nopass :: a procedure, nopass :: a
procedure, nopass :: b procedure, nopass :: b
procedure, pass :: c procedure, pass :: c
procedure, nopass :: d
end type end type
contains contains
...@@ -30,6 +31,11 @@ contains ...@@ -30,6 +31,11 @@ contains
c = 4.*x%v c = 4.*x%v
end function end function
subroutine d (x)
real :: x
if (abs(x-3.0)>1E-3) call abort()
end subroutine
subroutine s (x) subroutine s (x)
class(t) :: x class(t) :: x
real :: r real :: r
...@@ -48,6 +54,8 @@ contains ...@@ -48,6 +54,8 @@ contains
r = x%a(x%c ()) ! failed r = x%a(x%c ()) ! failed
if (r .ne. a(c (x))) call abort if (r .ne. a(c (x))) call abort
call x%d (x%a(1.5)) ! failed
end subroutine end subroutine
end end
......
! { dg-do run }
!
! PR 41766: [OOP] SELECT TYPE selector as actual argument with INTENT(INOUT)
!
! Contributed by Janus Weil <janus@gcc.gnu.org>
implicit none
type t1
integer :: a
end type
type, extends(t1) :: t2
integer :: b
end type
class(t1),allocatable :: cp
allocate(t2 :: cp)
select type (cp)
type is (t2)
cp%a = 98
cp%b = 76
call s(cp)
print *,cp%a,cp%b
if (cp%a /= cp%b) call abort()
class default
call abort()
end select
contains
subroutine s(f)
type(t2), intent(inout) :: f
f%a = 3
f%b = 3
end subroutine
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment