Bug 39295 - [4.3 Regression] Too strict interface conformance check
Summary: [4.3 Regression] Too strict interface conformance check
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.0
: P4 normal
Target Milestone: 4.2.5
Assignee: Paul Thomas
URL:
Keywords: rejects-valid
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2009-02-24 19:58 UTC by Tobias Burnus
Modified: 2009-03-07 16:00 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.0.3
Known to fail: 4.1.3 4.2.1 4.3.2 4.4.0
Last reconfirmed: 2009-02-26 18:45:38


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2009-02-24 19:58:04 UTC
Reported by Jon Hurst at http://gcc.gnu.org/ml/fortran/2009-02/msg00152.html

Said to compile with 4.0.3, rejected with 4.1/4.2/4.3/4.4.
Compiles with NAG f95, ifort, g95, sunf95, openf95 and pgf90.

At a glance, it looks valid but I have not checked thoroughly.

Test case by Jon Hurst:

MODULE  funcs
CONTAINS
  INTEGER FUNCTION test1(a,b,opfunc) 
    INTEGER :: a,b
    INTEGER, EXTERNAL :: opfunc
    test1 = opfunc( a, b ) 
  END FUNCTION test1
  INTEGER FUNCTION sumInts(a,b)
    INTEGER :: a,b
    sumInts = a + b
  END FUNCTION sumInts
END MODULE funcs

PROGRAM test
  USE funcs 
  INTEGER :: rs
  INTEGER, PARAMETER :: a = 2, b = 1
  rs = recSum( a, b, test1, sumInts )
  write(*,*) "Results", rs
CONTAINS
  RECURSIVE INTEGER FUNCTION recSum( a,b,UserFunction,UserOp ) RESULT( res )
    IMPLICIT NONE
    INTEGER :: a,b
    INTERFACE 
       INTEGER FUNCTION UserFunction(a,b,opfunc) 
         INTEGER :: a,b
         INTEGER, EXTERNAL :: opfunc
       END FUNCTION UserFunction
    END INTERFACE
    INTEGER, EXTERNAL :: UserOp 

    res = UserFunction( a,b, UserOp )

    if( res .lt. 10 ) then
       res = recSum( a, res, UserFunction, UserOp ) 
    end if
  END FUNCTION recSum
END PROGRAM test
Comment 1 Paul Thomas 2009-02-25 07:55:48 UTC
Confirmed

A temporary work around is to remove the interface for UserFunction and declare it to be external.

From a very quick look, the test for type and kind is failing because the formal argument does not seem to gain the attribute function at the right time.

Cheers

Paul
Comment 2 Paul Thomas 2009-02-26 18:44:03 UTC
Subject: Bug 39295

Author: pault
Date: Thu Feb 26 18:43:50 2009
New Revision: 144449

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144449
Log:
2009-02-26  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/39295
	* interface.c (compare_type_rank_if): Return 1 if the symbols
	are the same and deal with external procedures where one is
	identified to be a function or subroutine by usage but the
	other is not.

2009-02-26  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/39295
	* gfortran.dg/interface_25.f90: New test.
	* gfortran.dg/interface_26.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/interface_25.f90
    trunk/gcc/testsuite/gfortran.dg/interface_26.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/interface.c
    trunk/gcc/testsuite/ChangeLog

Comment 3 Paul Thomas 2009-02-26 18:45:38 UTC
Fixed on trunk.

I am not going to fix 4.2 but will do 4.3 in a few days.

Cheers

Paul
Comment 4 Paul Thomas 2009-03-07 15:59:02 UTC
Subject: Bug 39295

Author: pault
Date: Sat Mar  7 15:58:49 2009
New Revision: 144695

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144695
Log:
2009-03-07  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/39295
	* interface.c (compare_type_rank_if): Return 1 if the symbols
	are the same and deal with external procedures where one is
	identified to be a function or subroutine by usage but the
	other is not.

2009-03-07  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/39295
	* gfortran.dg/interface_25.f90: New test.
	* gfortran.dg/interface_26.f90: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/interface_25.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/interface_26.f90
Modified:
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/interface.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 5 Paul Thomas 2009-03-07 16:00:32 UTC
Fixed on trunk and 4.3.

Thanks for the report.

Paul