Bug 31214 - User-defined operator using entry leads to ICE
Summary: User-defined operator using entry leads to ICE
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2007-03-16 11:43 UTC by Joost VandeVondele
Modified: 2007-08-12 10:27 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.1.3 4.2.0 4.3.0
Last reconfirmed: 2007-03-16 19:42:12


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joost VandeVondele 2007-03-16 11:43:58 UTC
A recent gfortran ICEs on the following code:

module type_mod
  implicit none

  type x
     integer x
  end type x
  type y
     integer x
  end type y
  type z
     integer x
  end type z

  interface assignment(=)
     module procedure equals
  end interface assignment(=)

  interface operator(//)
     module procedure a_op_b, b_op_a
  end interface operator(//)

  contains
     subroutine equals(x,y)
        type(z), intent(in) :: y
        type(z), intent(out) :: x

        x%x = y%x
     end subroutine equals

     function a_op_b(a,b)
        type(x), intent(in) :: a
        type(y), intent(in) :: b
        type(z) a_op_b
        type(z) b_op_a
     entry b_op_a(b,a)
        a_op_b%x = a%x/b%x
     end function a_op_b
end module type_mod

program test
  use type_mod
  implicit none
  type(x) :: x1 = x(19)
  type(y) :: y1 = y(7)
  type(z) z1

  z1 = x1//y1
  write(*,*) 'x1//y1 = ',z1
  z1 = y1//x1
  write(*,*) 'y1//x1 = ',z1
end program test
Comment 1 Francois-Xavier Coudert 2007-03-16 19:42:12 UTC
Reduced testcase:

module test
  implicit none

  interface operator(.foo.)
     module procedure b_op_a
  end interface operator(.foo.)

  contains

     function a_op_b()
        integer, intent(in) :: a, b
        integer :: a_op_b, b_op_a
     entry b_op_a(a,b)
     end function a_op_b

end module test

$ gfortran -c a.f90 
a.f90:13.17:

     entry b_op_a(a,b)
                1
Internal Error at (1):
insert_bbt(): Duplicate key found!
Comment 2 Paul Thomas 2007-04-07 21:18:33 UTC
Subject: Bug 31214

Author: pault
Date: Sat Apr  7 21:18:17 2007
New Revision: 123642

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

	PR fortran/31214
	* trans-decl.c (gfc_get_symbol_decl): Allow unreferenced use
	associated symbols.

2007-04-07  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/31424
	* gfortran.dg/unreferenced_use_assoc_1.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/unreferenced_use_assoc_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/testsuite/ChangeLog

Comment 3 Paul Thomas 2007-04-07 21:31:33 UTC
Fixed on trumk

Paul
Comment 4 Joost VandeVondele 2007-05-30 14:04:04 UTC
the original testcase fails (again/still?)
Comment 5 Paul Thomas 2007-06-21 20:48:47 UTC
(In reply to comment #4)
> the original testcase fails (again/still?)
> 

Hmmm - it no longer ICEs but gives an error.

I'll have a look.

Paul
Comment 6 patchapp@dberlin.org 2007-08-04 11:50:16 UTC
Subject: Bug number PR31214

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-08/msg00239.html
Comment 7 Paul Thomas 2007-08-04 20:46:27 UTC
Subject: Bug 31214

Author: pault
Date: Sat Aug  4 20:46:11 2007
New Revision: 127213

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127213
Log:
2007-08-04  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/31214
	* symbol.c (get_unique_symtree): Moved from module.c.
	* module.c (get_unique_symtree): Moved to symbol.c.
	* decl.c (get_proc_name): Transfer the typespec from the local
	symbol to the module symbol, in the case that an entry is also
	a module procedure.  Ensure the local symbol is cleaned up by
	pointing to it with a unique symtree.

	* dump_parse_tree (gfc_show_code_node): Add EXEC_ASSIGN_CALL.

2007-08-04  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/31214
	* gfortran.dg/entry_13.f90: New test.

	* gfortran.dg/entry_12.f90: Clean up .mod file.


Added:
    trunk/gcc/testsuite/gfortran.dg/entry_13.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/dump-parse-tree.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/module.c
    trunk/gcc/fortran/symbol.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/entry_12.f90

Comment 8 Paul Thomas 2007-08-04 20:58:23 UTC
Subject: Bug 31214

Author: pault
Date: Sat Aug  4 20:58:11 2007
New Revision: 127214

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127214
Log:
2007-08-04  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/31214
	* symbol.c (get_unique_symtree): Moved from module.c.
	* module.c (get_unique_symtree): Moved to symbol.c.
	* decl.c (get_proc_name): Transfer the typespec from the local
	symbol to the module symbol, in the case that an entry is also
	a module procedure.  Ensure the local symbol is cleaned up by
	pointing to it with a unique symtree.

	* dump_parse_tree (gfc_show_code_node): Add EXEC_ASSIGN_CALL.

2007-08-04  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/31214
	* gfortran.dg/entry_13.f90: New test.

	* gfortran.dg/entry_12.f90: Clean up .mod file.


Modified:
    trunk/gcc/fortran/ChangeLog

Comment 9 Francois-Xavier Coudert 2007-08-12 10:27:49 UTC
Fixed by Paul.