Bug 45338 - Failure on interfacing a function passed as an argument as a custom operator
Summary: Failure on interfacing a function passed as an argument as a custom operator
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Thomas Koenig
URL:
Keywords: ice-on-valid-code
: 45339 (view as bug list)
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2010-08-19 10:21 UTC by Simon Smart
Modified: 2011-01-02 21:59 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.6.0
Known to fail: 4.1.2, 4.2.1, 4.3.4, 4.4.0, 4.5.0
Last reconfirmed: 2010-08-19 14:11:24


Attachments
Tentative patch (290 bytes, patch)
2010-12-29 22:56 UTC, Thomas Koenig
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Smart 2010-08-19 10:21:50 UTC
In the testcase below, compiled with:

    gfortran -c test.f90

gfortran suffers an internal compiler error:

internal compiler error: in gfc_gen_symbol_decl, at fortran/trans-decl.c:893

If the commenting on the marked line is removed, then the code compiles fine.

I have tested this case with versions 4.3.2, 4.4.1 and 4.6 (experimental, from svn trunk last night). It works correctly using ifort, PGI and pathscale compilers.

---------------------------------------

module test_mod
    
    implicit none

contains

    subroutine test_fn (cmp)

        interface operator(.myop.)
            pure function cmp (a, b) result(ret)
                integer, intent(in) :: a, b
                logical ret
            end function
        end interface

        integer :: a, b

        !print*, cmp(a, b)   ! If this line is commented out, gfortran has an
                            ! internal compiler error
        print*, a .myop. b

    end subroutine

end module
Comment 1 kargls 2010-08-19 13:08:34 UTC
*** Bug 45339 has been marked as a duplicate of this bug. ***
Comment 2 Thomas Koenig 2010-12-29 22:56:32 UTC
Created attachment 22868 [details]
Tentative patch

Sounds like the referenced attribute isn't set correctly.

We could try setting it during resolution, like this.
Comment 3 Thomas Koenig 2010-12-31 11:20:26 UTC
Author: tkoenig
Date: Fri Dec 31 11:20:22 2010
New Revision: 168366

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168366
Log:
2010-12-31  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/45338
	* resolve.c (resolve_operator):  Mark function for user-defined
	operator as referenced.

2010-12-31  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/45338
	* gfortran.dg/userdef_operator_2.f90:  New test case.


Added:
    trunk/gcc/testsuite/gfortran.dg/userdef_operator_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Thomas Koenig 2010-12-31 11:34:45 UTC
Fixed on trunk, backport to 4.5 pending.
Comment 5 Thomas Koenig 2011-01-02 21:58:06 UTC
Author: tkoenig
Date: Sun Jan  2 21:58:03 2011
New Revision: 168410

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168410
Log:
2011-02-01  Thomas Koenig  <tkoenig@gcc.gnu.org>

	Backport from mainline
	PR fortran/45338
	* resolve.c (resolve_operator):  Mark function for user-defined
	operator as referenced.

2011-02-01  Thomas Koenig  <tkoenig@gcc.gnu.org>

	Backport from mainline
	PR fortran/45338
	* gfortran.dg/userdef_operator_2.f90:  New test case.


Added:
    branches/gcc-4_5-branch/gcc/testsuite/gfortran.dg/userdef_operator_2.f90
Modified:
    branches/gcc-4_5-branch/gcc/fortran/ChangeLog
    branches/gcc-4_5-branch/gcc/fortran/resolve.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
Comment 6 Thomas Koenig 2011-01-02 21:59:12 UTC
Fixed on trunk and 4.5.  Closing.