public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] PR 55983: [4.7/4.8 Regression] ICE in find_typebound_proc_uop, at fortran/class.c:2711
@ 2013-01-16 14:08 Janus Weil
  2013-01-16 18:08 ` Paul Richard Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Janus Weil @ 2013-01-16 14:08 UTC (permalink / raw)
  To: gfortran, gcc-patches

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

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

* Re: [Patch, Fortran] PR 55983: [4.7/4.8 Regression] ICE in find_typebound_proc_uop, at fortran/class.c:2711
  2013-01-16 14:08 [Patch, Fortran] PR 55983: [4.7/4.8 Regression] ICE in find_typebound_proc_uop, at fortran/class.c:2711 Janus Weil
@ 2013-01-16 18:08 ` Paul Richard Thomas
  2013-01-16 19:56   ` Janus Weil
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Richard Thomas @ 2013-01-16 18:08 UTC (permalink / raw)
  To: Janus Weil; +Cc: gfortran, gcc-patches

Dear Janus,

As you say, this is close to being obvious - OK for trunk and for 4.7.

Thanks for the patch.

Cheers

Paul

On 16 January 2013 15:08, Janus Weil <janus@gcc.gnu.org> wrote:
> 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.



-- 
The knack of flying is learning how to throw yourself at the ground and miss.
       --Hitchhikers Guide to the Galaxy

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

* Re: [Patch, Fortran] PR 55983: [4.7/4.8 Regression] ICE in find_typebound_proc_uop, at fortran/class.c:2711
  2013-01-16 18:08 ` Paul Richard Thomas
@ 2013-01-16 19:56   ` Janus Weil
  0 siblings, 0 replies; 3+ messages in thread
From: Janus Weil @ 2013-01-16 19:56 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: gfortran, gcc-patches

> As you say, this is close to being obvious - OK for trunk and for 4.7.

Thanks, guys. Committed to trunk as 195251. Will do 4.7 soon ...

Cheers,
Janus



> On 16 January 2013 15:08, Janus Weil <janus@gcc.gnu.org> wrote:
>> 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.
>
>
>
> --
> The knack of flying is learning how to throw yourself at the ground and miss.
>        --Hitchhikers Guide to the Galaxy

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

end of thread, other threads:[~2013-01-16 19:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-16 14:08 [Patch, Fortran] PR 55983: [4.7/4.8 Regression] ICE in find_typebound_proc_uop, at fortran/class.c:2711 Janus Weil
2013-01-16 18:08 ` Paul Richard Thomas
2013-01-16 19:56   ` Janus Weil

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).