Bug 41766 - [OOP] SELECT TYPE selector as actual argument with INTENT(INOUT)
[OOP] SELECT TYPE selector as actual argument with INTENT(INOUT)
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: fortran
4.5.0
: P3 normal
: ---
Assigned To: janus
: rejects-valid
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-10-20 16:46 UTC by janus
Modified: 2009-10-21 09:02 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-10-20 17:17:24


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description janus 2009-10-20 16:46:42 UTC
Test case:

 implicit none

 type t1
   integer :: a
 end type

 type, extends(t1) :: t2
   integer :: b
 end type

 class(t1),pointer :: cp

 allocate(t2 :: cp)

 select type (cp)
   type is (t2)
     call s(cp)
 end select

contains

  subroutine s(f)
    type(t2), intent(inout) :: f
  end subroutine

end


This fails with:

     call s(cp)
            1
Error: Actual argument at (1) must be definable as the dummy argument 'f' is INTENT = OUT/INOUT
Comment 1 janus 2009-10-20 17:17:24 UTC
Mine. Preliminary patch:

Index: gcc/fortran/match.c
===================================================================
--- gcc/fortran/match.c (Revision 153009)
+++ gcc/fortran/match.c (Arbeitskopie)
@@ -4047,9 +4047,10 @@ select_type_set_tmp (gfc_typespec *ts)

   sprintf (name, "tmp$%s", ts->u.derived->name);
   gfc_get_sym_tree (name, gfc_current_ns, &tmp, false);
-  tmp->n.sym->ts = *ts;
-  tmp->n.sym->attr.referenced = 1;
-  tmp->n.sym->attr.pointer = 1;
+  gfc_add_type (tmp->n.sym, ts, NULL);
+  gfc_set_sym_referenced (tmp->n.sym);
+  gfc_add_pointer (&tmp->n.sym->attr, NULL);
+  gfc_add_flavor (&tmp->n.sym->attr, FL_VARIABLE, name, NULL);

   select_type_stack->tmp = tmp;
 }

The important thing here is 'gfc_add_flavor'. The other three lines are just rewritten, but still do the same thing.
Comment 2 janus 2009-10-21 08:57:11 UTC
Subject: Bug 41766

Author: janus
Date: Wed Oct 21 08:56:56 2009
New Revision: 153049

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153049
Log:
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.

Added:
    trunk/gcc/testsuite/gfortran.dg/select_type_7.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/match.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/class_9.f03

Comment 3 janus 2009-10-21 09:02:25 UTC
Fixed with r153049. Closing.