Bug 43193 - [OOP] Calling type-bound procedure of abstract type wrongly rejected
Summary: [OOP] Calling type-bound procedure of abstract type wrongly rejected
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2010-02-26 23:56 UTC by Tobias Burnus
Modified: 2010-02-27 17:25 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2010-02-26 23:56:40 UTC
Found by Damian - and ask at
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/f5ec99089ea72b79#

gfortran rejects
   call type%abstract_parent%tbp()
with
  Error: Base object for type-bound procedure call at (1) is of ABSTRACT
type 'abstract_parent'

As long as "abstract_parent%tbp" is not deferred, I believe the call is valid and (if not overridden) identically to "type%tpb()", which is accepted.

The check has to be modified to only reject DEFERRED procedures. Regarding the standard, deferred procedures are invalid as outlined in Note 4.50. I think it is buried in

C427 (R429) If the type definition contains or inherits (4.5.6.1) a deferred binding (4.5.4), ABSTRACT shall appear.

However, as any dynamic object is not abstract, one cannot invoke a deferred procedure.
Comment 1 Tobias Burnus 2010-02-27 00:04:37 UTC
Draft patch:

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c       (Revision 157097)
+++ gcc/fortran/resolve.c
@@ -4902,10 +4902,11 @@ check_typebound_baseobject (gfc_expr* e)

   gcc_assert (base->ts.type == BT_DERIVED || base->ts.type == BT_CLASS);

-  if (base->ts.type == BT_DERIVED && base->ts.u.derived->attr.abstract)
+  if (e->value.compcall.tbp->deferred)
     {
-      gfc_error ("Base object for type-bound procedure call at %L is of"
-                " ABSTRACT type '%s'", &e->where, base->ts.u.derived->name);
+      gfc_error ("Type bound-bound procedure of base type '%s' in call "
+                "at %L has a DEFERRED binding", base->ts.u.derived->name,
+                &e->where);
       return FAILURE;
     }
Comment 2 Tobias Burnus 2010-02-27 17:25:41 UTC
Close as INVALID.

Patch posted was: http://gcc.gnu.org/ml/fortran/2010-02/msg00225.html

However, Jim Xia thinks it is invalid - and I think he is right - as C611 has:
  R611 data-ref is part-ref [ % part-ref ] ...
  C611 (R611) If the rightmost part-name is of abstract type,
              data-ref shall be polymorphic.

Thus, a data-ref something%parent, parent needs to by polymorphic (CLASS).

And for the call, one has:

  R1219 procedure designator is [...] or  data-ref % binding-name

thus in   something%parent%binding_name  "parent" needs to be polymorphic, i.e. not abstract.