public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Janus Weil <janus@gcc.gnu.org>
To: gfortran <fortran@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [Patch, Fortran, OOP] PR 50227: [4.7 Regression] ICE-on-valid with allocatable class variable
Date: Thu, 01 Sep 2011 20:47:00 -0000	[thread overview]
Message-ID: <CAKwh3qhFZJR7SuT=jcamdavM0KCfSm8i714AGmyU830nKOy4FA@mail.gmail.com> (raw)

[-- 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" } }

             reply	other threads:[~2011-09-01 20:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-01 20:47 Janus Weil [this message]
2011-09-04 10:51 ` Janus Weil
2011-09-04 18:49   ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKwh3qhFZJR7SuT=jcamdavM0KCfSm8i714AGmyU830nKOy4FA@mail.gmail.com' \
    --to=janus@gcc.gnu.org \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).