User account creation filtered due to spam.

Bug 41583 - [OOP] TYPE IS rejected because of way vtable index is implemented
Summary: [OOP] TYPE IS rejected because of way vtable index is implemented
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: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2009-10-05 12:55 UTC by Tobias Burnus
Modified: 2016-11-16 12:09 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2009-10-05 12:55:03 UTC
The following program is valid but it fails to compile due to the way the indices in vtable are implemented.

Cf. http://gcc.gnu.org/ml/fortran/2009-09/msg00298.html

========= File: bb.f90 =========
module m
type t
end type t
end module m
========= File: cc.f90 =========
module m2
  use m
  type, extends(t) :: t2
  end type t2
end module m2
========= File: dd.f90 =========
use m
use m2
type,extends(t) :: t3
end type t3

integer :: i
class(t), allocatable :: a
allocate(t3 :: a)
select type(a)
  type is(t)
    i = 1
  type is(t2)
    i = 2
  type is(t3)
    i = 3
end select
print *, i
end
========================

The error message is:

$ gfortran bb.f90 cc.f90 dd.f90
dd.f90:10.10:

  type is(t)
          1
dd.f90:12.10:

  type is(t2)
          2
Error: CASE label at (1) overlaps with CASE label at (2)
Comment 1 Paul Thomas 2009-10-11 12:25:04 UTC
Subject: Bug 41583

Author: pault
Date: Sun Oct 11 12:24:51 2009
New Revision: 152641

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

	PR fortran/41583
	* decl.c (hash_value): New function.
	(gfc_match_derived_decl): Call it.

2009-10-11  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/41583
	* gfortran.dg/class_4a.f03: New test with class_4b,c and d.f03.
	* gfortran.dg/class_4b.f03: As above.
	* gfortran.dg/class_4c.f03: As above.
	* gfortran.dg/class_4d.f03: As above.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/testsuite/ChangeLog

Comment 2 Paul Thomas 2009-10-11 12:29:17 UTC
Fixed using a hash function.

TODO a proper job using vtables.

Paul