Bug 41873 - [OOP] Bogus Error: ABSTRACT INTERFACE must not be referenced...
Summary: [OOP] Bogus Error: ABSTRACT INTERFACE must not be referenced...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.5.0
Assignee: janus
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2009-10-29 22:41 UTC by Harald Anlauf
Modified: 2016-11-16 12:21 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-11-05 10:44:50


Attachments
Test code (380 bytes, text/plain)
2009-10-29 22:42 UTC, Harald Anlauf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Anlauf 2009-10-29 22:41:51 UTC
Hi,

the attached code compiles with ifort 11.1 and with nagfor 5.2,
but is rejected with current gfortran:


gfcbug93.f90:47.12:

    print *, ipmin% dot_g_g (g,g)
            1
Error: ABSTRACT INTERFACE 'dot' must not be referenced at (1)
gfcbug93.f90:47.12:

    print *, ipmin% dot_g_g (g,g)
            1
Error: ABSTRACT INTERFACE 'dot' must not be referenced at (1)


Cheers,
-ha
Comment 1 Harald Anlauf 2009-10-29 22:42:47 UTC
Created attachment 18931 [details]
Test code
Comment 2 Tobias Burnus 2009-10-30 15:32:20 UTC
I agree that the following error is bogus:

>    print *, ipmin% dot_g_g (g,g)
>            1
> Error: ABSTRACT INTERFACE 'dot' must not be referenced at (1)

While one might not access (type)%dot_g_g as "dot_g_g" is deferred, using (class)%dot_g_g is valid.  (And using (type)%dot_g_g is not possible as one cannot use "type(abstract_t)"; thus it might be enough to relax the check.)
Comment 3 janus 2009-11-04 16:43:57 UTC
(In reply to comment #0)
> Error: ABSTRACT INTERFACE 'dot' must not be referenced at (1)

The same error appears in PR 41556.
Comment 4 janus 2009-11-04 20:13:13 UTC
Reduced test case:


  implicit none

  type, abstract :: inner_product_class
  contains
    procedure(dot), public, nopass, deferred :: dot_g_g
  end type

  abstract interface
    real function dot ()
    end function
  end interface

contains

  subroutine cg (ipmin)
    class(inner_product_class) :: ipmin
    print *, ipmin%dot_g_g ()
  end subroutine

end


Triggers the same error message as comment #0, which, in addition to being bogus, appears twice.
Comment 5 janus 2009-11-04 20:39:39 UTC
(In reply to comment #2)
> While one might not access (type)%dot_g_g as "dot_g_g" is deferred, using
> (class)%dot_g_g is valid.  (And using (type)%dot_g_g is not possible as one
> cannot use "type(abstract_t)"; thus it might be enough to relax the check.)

It might be okay for type-bound procedures. However, this check should also catch the usage of simple abstract procedures, i.e. when adding the following to the test case in comment #4:

print *, dot()

This is illegal of course, and is not caught without the check in resolve_function.
Comment 6 janus 2009-11-05 10:43:00 UTC
Subject: Bug 41873

Author: janus
Date: Thu Nov  5 10:42:48 2009
New Revision: 153934

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153934
Log:
2009-11-05  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/41556
	PR fortran/41873
	* resolve.c (resolve_function,resolve_call): Prevent abstract interfaces
	from being called, but allow deferred type-bound procedures with
	abstract interface.


2009-11-05  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/41556
	PR fortran/41873
	* gfortran.dg/interface_abstract_4.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/interface_abstract_4.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog

Comment 7 janus 2009-11-05 10:45:43 UTC
Fixed with r153934. Closing.