|Summary:||Wrong base-object checks for type-bound procedures|
|Product:||gcc||Reporter:||Daniel Kraft <domob>|
|Component:||fortran||Assignee:||Daniel Kraft <domob>|
|Build:||Known to work:|
|Known to fail:||Last reconfirmed:||2009-08-27 09:57:05|
|Attachments:||Test case for ELEMENTAL type-bound procedure call|
Description Daniel Kraft 2009-08-27 09:54:17 UTC
ELEMENTAL type-bound procedures (and in consequence also, for instance, type-bound operators or assignments on arrays) do not work for non-scalar passed-objects (even though the procedures are ELEMENTAL): MODULE m IMPLICIT NONE TYPE t CONTAINS PROCEDURE, PASS :: myproc END TYPE t CONTAINS ELEMENTAL INTEGER FUNCTION myproc (me) CLASS(t), INTENT(IN) :: me myproc = 42 END FUNCTION myproc END MODULE m PROGRAM main USE m IMPLICIT NONE TYPE(t) :: arr(2) PRINT *, arr%myproc () END PROGRAM main [/tmp]# gfortran-dev elemental.f03 -w elemental.f03:23.10: PRINT *, arr%myproc () 1 Error: Passed-object at (1) must be scalar This is a wrongly placed check; actually, on the declaration it should be checked that the passed-object dummy argument is scalar, non-pointer and non-allocatable, but that check is in turn missing; this one is accepted but is illegal: MODULE m IMPLICIT NONE TYPE t CONTAINS PROCEDURE, PASS :: proc1 PROCEDURE, PASS :: proc2 END TYPE t CONTAINS INTEGER FUNCTION proc1 (me) CLASS(t), INTENT(IN) :: me(:) proc1 = 42 END FUNCTION proc1 INTEGER FUNCTION proc2 (me) CLASS(t), INTENT(IN), POINTER :: me proc2 = 42 END FUNCTION proc2 ! ALLOCATABLE scalar can't be checked, but is the same. END MODULE m
Comment 1 Daniel Kraft 2009-08-27 09:57:05 UTC
I will work on this. Janus, how's that also related to PPCs? I'll leave that open for you, if there is anything to correct, also (the 'wrong' check for scalar passed-object is there literally for PPCs, too, but it may be correct there).
Comment 2 Daniel Kraft 2009-08-27 11:55:05 UTC
When this is fixed, we should also add a test-case to check that type-bound assignment does correct dependency-checking (based on elemental_subroutine_3.f90 for instance).
Comment 3 janus 2009-08-27 20:56:48 UTC
(In reply to comment #1) > Janus, how's that also related to PPCs? At first glance it seems we have the same problems for PPCs also.
Comment 4 Daniel Kraft 2009-11-07 19:45:24 UTC
See here for some discussion about this issue: http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/8cef6676b6fa3750#
Comment 5 Daniel Kraft 2009-12-08 11:39:34 UTC
Subject: Bug 41177 Author: domob Date: Tue Dec 8 11:39:20 2009 New Revision: 155086 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155086 Log: 2008-12-08 Daniel Kraft <firstname.lastname@example.org> PR fortran/41177 * gfortran.dg/typebound_proc_4.f03: Remove check for wrong error. * gfortran.dg/typebound_proc_13.f03: New test. 2008-12-08 Daniel Kraft <email@example.com> PR fortran/41177 * gfortran.h (struct symbol_attribute): New flag `class_pointer'. * symbol.c (gfc_build_class_symbol): Set the new flag. * resolve.c (update_compcall_arglist): Remove wrong check for non-scalar base-object. (check_typebound_baseobject): Add the correct version here as well as some 'not implemented' message check in the old case. (resolve_typebound_procedure): Check that the passed-object dummy argument is scalar, non-pointer and non-allocatable as it should be. Added: trunk/gcc/testsuite/gfortran.dg/typebound_proc_13.f03 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/gfortran.h trunk/gcc/fortran/resolve.c trunk/gcc/fortran/symbol.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/typebound_call_4.f03
Comment 6 Daniel Kraft 2009-12-08 11:45:27 UTC
This fixes most of the issues mentioned, except that it does not yet allow calling an ELEMENTAL type-bound procedure on a non-scalar base object; this leads to an ICE and thus I disabled it for now. I'll keep on working on this (maybe for next stage 1, though).
Comment 7 Daniel Kraft 2009-12-08 11:48:02 UTC
Created attachment 19258 [details] Test case for ELEMENTAL type-bound procedure call This is a test-case for the still missing part as per the last comment I already worked out; just attaching it so it is not lost accidentally (and as reference for what I'm thinking about).