public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran, OOP] PR 50227: [4.7 Regression] ICE-on-valid with allocatable class variable
@ 2011-09-01 20:47 Janus Weil
  2011-09-04 10:51 ` Janus Weil
  0 siblings, 1 reply; 3+ messages in thread
From: Janus Weil @ 2011-09-01 20:47 UTC (permalink / raw)
  To: gfortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 608 bytes --]

Hi all,

here is a small patch fixing a recent OOP regression. It feels a bit
like it's only fixing the effect instead of the cause (since I haven't
really found the cause). But anyway, it does fix the ICE and it is
obvious enough so that I'll commit it by Sunday if no one protests in
the meantime.

Regtested on x86_64-unknown-linux-gnu.

Cheers,
Janus


2011-09-01  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/50227
	* trans-types.c (gfc_sym_type): Check for proc_name.

2011-09-01  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/50227
	* gfortran.dg/class_45a.f03: New.
	* gfortran.dg/class_45b.f03: New.

[-- Attachment #2: pr50227.diff --]
[-- Type: text/x-diff, Size: 620 bytes --]

Index: gcc/fortran/trans-types.c
===================================================================
--- gcc/fortran/trans-types.c	(revision 178408)
+++ gcc/fortran/trans-types.c	(working copy)
@@ -2109,7 +2109,8 @@ gfc_sym_type (gfc_symbol * sym)
     {
       /* We must use pointer types for potentially absent variables.  The
 	 optimizers assume a reference type argument is never NULL.  */
-      if (sym->attr.optional || sym->ns->proc_name->attr.entry_master)
+      if (sym->attr.optional
+	  || (sym->ns->proc_name && sym->ns->proc_name->attr.entry_master))
 	type = build_pointer_type (type);
       else
 	{

[-- Attachment #3: class_45a.f03 --]
[-- Type: application/octet-stream, Size: 513 bytes --]

! { dg-do compile }
!
! PR 50227: [4.7 Regression] [OOP] ICE-on-valid with allocatable class variable
!
! Contributed by Andrew Benson <abenson@caltech.edu>

module G_Nodes
  private

  type, public :: t0
  end type
  
  type, public, extends(t0) :: t1
  end type

contains
  
  function basicGet(self)
    implicit none
    class(t0), pointer :: basicGet
    class(t0), intent(in) :: self
    select type (self)
    type is (t1)
       basicGet => self
    end select
  end function basicGet

end module G_Nodes

[-- Attachment #4: class_45b.f03 --]
[-- Type: application/octet-stream, Size: 336 bytes --]

! { dg-do run }
! { dg-additional-sources class_45a.f03 }
!
! PR 50227: [4.7 Regression] [OOP] ICE-on-valid with allocatable class variable
!
! Contributed by Andrew Benson <abenson@caltech.edu>

program Test
  use G_Nodes
  class(t0), allocatable :: c
  allocate(t1 :: c)
end program Test

! { dg-final { cleanup-modules "G_Nodes" } }

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-04 18:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-01 20:47 [Patch, Fortran, OOP] PR 50227: [4.7 Regression] ICE-on-valid with allocatable class variable Janus Weil
2011-09-04 10:51 ` Janus Weil
2011-09-04 18:49   ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).