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] PR 55983: [4.7/4.8 Regression] ICE in find_typebound_proc_uop, at fortran/class.c:2711
Date: Wed, 16 Jan 2013 14:08:00 -0000	[thread overview]
Message-ID: <CAKwh3qh7y9uXvFtQVnsiBX-b9OiW+0wCTtuM-MBo_+mcHq5CEA@mail.gmail.com> (raw)

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

Hi all,

here is a close-to-obvious patch for an ICE-on-invalid regression. It
removes as assert, which is reasonable for valid code but can fail
under error conditions (as the PR shows), and replaces it with an
equivalent IF clause.

Regtested on x86_64-unknown-linux-gnu. Ok for trunk and 4.7?

Cheers,
Janus


2013-01-16  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/55983
    * class.c (find_typebound_proc_uop): Check for f2k_derived instead of
    asserting it.


2013-01-16  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/55983
    * gfortran.dg/class_55.f90: New.

[-- Attachment #2: pr55983.diff --]
[-- Type: application/octet-stream, Size: 865 bytes --]

Index: gcc/fortran/class.c
===================================================================
--- gcc/fortran/class.c	(revision 195125)
+++ gcc/fortran/class.c	(working copy)
@@ -2707,15 +2707,17 @@ find_typebound_proc_uop (gfc_symbol* derived, gfc_
   gfc_symtree* res;
   gfc_symtree* root;
 
-  /* Set correct symbol-root.  */
-  gcc_assert (derived->f2k_derived);
-  root = (uop ? derived->f2k_derived->tb_uop_root
-	      : derived->f2k_derived->tb_sym_root);
-
   /* Set default to failure.  */
   if (t)
     *t = FAILURE;
 
+  if (derived->f2k_derived)
+    /* Set correct symbol-root.  */
+    root = (uop ? derived->f2k_derived->tb_uop_root
+		: derived->f2k_derived->tb_sym_root);
+  else
+    return NULL;
+
   /* Try to find it in the current type's namespace.  */
   res = gfc_find_symtree (root, name);
   if (res && res->n.tb && !res->n.tb->error)

[-- Attachment #3: class_55.f90 --]
[-- Type: application/octet-stream, Size: 417 bytes --]

! { dg-do compile }
!
! PR 55983: [4.7/4.8 Regression] ICE in find_typebound_proc_uop, at fortran/class.c:2711
!
! Contributed by Sylwester Arabas <slayoo@staszic.waw.pl>

  type :: mpdata_t
    class(bcd_t), pointer :: bcx, bcy   ! { dg-error "is a type that has not been declared" }
  end type
  type(mpdata_t) :: this
  call this%bcx%fill_halos()            ! { dg-error "is being used before it is defined" }
end

             reply	other threads:[~2013-01-16 14:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-16 14:08 Janus Weil [this message]
2013-01-16 18:08 ` Paul Richard Thomas
2013-01-16 19:56   ` Janus Weil

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=CAKwh3qh7y9uXvFtQVnsiBX-b9OiW+0wCTtuM-MBo_+mcHq5CEA@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).