Bug 59662 - [4.9 Regression] [OOP] TBP subroutine call rejected in connection with BIND(C)
Summary: [4.9 Regression] [OOP] TBP subroutine call rejected in connection with BIND(C)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: 4.9.0
Assignee: janus
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2014-01-03 08:50 UTC by Salvatore Filippone
Modified: 2016-11-16 15:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.8.1
Known to fail: 4.9.0
Last reconfirmed: 2014-01-03 00:00:00


Attachments
testcase (459 bytes, text/plain)
2014-01-03 08:50 UTC, Salvatore Filippone
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Salvatore Filippone 2014-01-03 08:50:36 UTC
Created attachment 31565 [details]
testcase

The attached code fails with current trunk with what appears to be an overzealous check. The code compiles and works fine with 4.8.1.
Commenting the BIND(C) routine call or moving the foobar subroutine outside of foo masks the problem. 
-----------------------------------------------
[sfilippo@jacobi bug36]$ gfortran -v 
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gnu/4.9/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/usr/local/gnu/4.9 --enable-languages=c,c++,fortran --with-gmp=/home/travel/GNUBUILD/gmp --with-mpfr=/home/travel/GNUBUILD/mpfr --with-mpc=/home/travel/GNUBUILD/mpc --with-cloog=/home/travel/GNUBUILD/cloog : (reconfigured) ../gcc/configure --prefix=/usr/local/gnu/4.9 --with-gmp=/home/travel/GNUBUILD/gmp --with-mpfr=/home/travel/GNUBUILD/mpfr --with-mpc=/home/travel/GNUBUILD/mpc --with-cloog=/home/travel/GNUBUILD/cloog --enable-languages=c,c++,fortran,lto --no-create --no-recursion : (reconfigured) ../gcc/configure --prefix=/usr/local/gnu/4.9 --with-gmp=/home/travel/GNUBUILD/gmp --with-mpfr=/home/travel/GNUBUILD/mpfr --with-mpc=/home/travel/GNUBUILD/mpc --with-cloog=/home/travel/GNUBUILD/cloog --enable-languages=c,c++,fortran,lto --no-create --no-recursion
Thread model: posix
gcc version 4.9.0 20140102 (experimental) (GCC) 
[sfilippo@jacobi bug36]$ gfortran -c  testcase.f90
testcase.f90:59.22:

    call a%mv_to(acsc)
                      1
Error: 'mv_to_base' at (1) is not a function
Comment 1 janus 2014-01-03 09:17:02 UTC
Confirmed. There is some strange interaction with BIND(C). Reduced test case:


module base_mod

  implicit none

  type outer
  contains
    procedure, nopass :: mv_to_base
  end type

contains

  subroutine mv_to_base
  end subroutine

  subroutine foobar
    type(outer) :: a
    integer :: info
    
    interface 
      integer function try() bind(c)
      end function
    end interface

    call a%mv_to_base()
    info = try()
  end subroutine

end module
Comment 2 janus 2014-01-03 09:26:29 UTC
This PR is fixed by the patch for PR 59023 posted at:

http://gcc.gnu.org/ml/fortran/2013-12/msg00139.html
Comment 3 janus 2014-01-06 11:31:37 UTC
Author: janus
Date: Mon Jan  6 11:31:34 2014
New Revision: 206355

URL: http://gcc.gnu.org/viewcvs?rev=206355&root=gcc&view=rev
Log:
2014-01-06  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/59023
	PR fortran/59662
	* resolve.c (resolve_global_procedure): Don't apply to c-binding
	procedures.
	(gfc_verify_binding_labels): Remove duplicate line.

2014-01-06  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/59023
	* gfortran.dg/bind_c_procs_2.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/bind_c_procs_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 janus 2014-01-06 11:36:18 UTC
Fixed with r206355. Closing.