public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR99818 - [10/11 Regression] ICE in gfc_get_tree_for_caf_expr, at fortran/trans-expr.c:2186
@ 2021-04-01 13:44 Paul Richard Thomas
  2021-04-02  3:11 ` Jerry DeLisle
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Richard Thomas @ 2021-04-01 13:44 UTC (permalink / raw)
  To: fortran, gcc-patches

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

This one is trivial. The wrong error message was transformed by my patch
for PR98897 into an ICE. This patch now produces the correct error.

Regtests OK on FC33/x86_64 - OK for the affected branches?

Paul

Fortran: Fix ICE on wrong code [PR99818].

2021-04-01  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran/ChangeLog

PR fortran/99818
* interface.c (compare_parameter): The codimension attribute is
applied to the _data field of class formal arguments.

gcc/testsuite/ChangeLog

PR fortran/99818
* gfortran.dg/coarray_48.f90: New test.

[-- Attachment #2: submit.diff --]
[-- Type: text/x-patch, Size: 1772 bytes --]

diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index f7ca52e6550..60736123550 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -2327,6 +2327,7 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual,
   bool rank_check, is_pointer;
   char err[200];
   gfc_component *ppc;
+  bool codimension = false;
 
   /* If the formal arg has type BT_VOID, it's to one of the iso_c_binding
      procs c_f_pointer or c_f_procpointer, and we need to accept most
@@ -2490,7 +2491,12 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual,
       return false;
     }
 
-  if (formal->attr.codimension && !gfc_is_coarray (actual))
+  if (formal->ts.type == BT_CLASS && formal->attr.class_ok)
+    codimension = CLASS_DATA (formal)->attr.codimension;
+  else
+    codimension = formal->attr.codimension;
+
+  if (codimension && !gfc_is_coarray (actual))
     {
       if (where)
 	gfc_error ("Actual argument to %qs at %L must be a coarray",
@@ -2498,7 +2504,7 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual,
       return false;
     }
 
-  if (formal->attr.codimension && formal->attr.allocatable)
+  if (codimension && formal->attr.allocatable)
     {
       gfc_ref *last = NULL;
 
@@ -2520,7 +2526,7 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual,
 	}
     }
 
-  if (formal->attr.codimension)
+  if (codimension)
     {
       /* F2008, 12.5.2.8 + Corrig 2 (IR F08/0048).  */
       /* F2018, 12.5.2.8.  */
@@ -2586,7 +2592,7 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual,
       return false;
     }
 
-  if (formal->attr.allocatable && !formal->attr.codimension
+  if (formal->attr.allocatable && !codimension
       && actual_attr.codimension)
     {
       if (formal->attr.intent == INTENT_OUT)

[-- Attachment #3: coarray_48.f90 --]
[-- Type: text/x-fortran, Size: 436 bytes --]

! { dg-do compile }
! { dg-options "-fcoarray=lib" }
!
! Fix for P99818 in which wrong code caused an ICE.
!
! Contributed by Gerhard Steinmetz <gscfq@t-online.de>
!
module m
   type t
      integer :: a
   contains
      procedure :: s
   end type
contains
   subroutine s(x)
      class(t) :: x[*]
   end
end
program p
   use m
   associate (y => t(1))
      call y%s           ! { dg-error "must be a coarray" }
   end associate
end

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

* Re: [Patch, fortran] PR99818 - [10/11 Regression] ICE in gfc_get_tree_for_caf_expr, at fortran/trans-expr.c:2186
  2021-04-01 13:44 [Patch, fortran] PR99818 - [10/11 Regression] ICE in gfc_get_tree_for_caf_expr, at fortran/trans-expr.c:2186 Paul Richard Thomas
@ 2021-04-02  3:11 ` Jerry DeLisle
  2021-04-05  6:24   ` Paul Richard Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Jerry DeLisle @ 2021-04-02  3:11 UTC (permalink / raw)
  To: Paul Richard Thomas, fortran, gcc-patches

Paul,

This looks OK to me for Trunk. I believe 10 is in freeze so it may have 
to wait or get release manager approval.

Jerry

On 4/1/21 6:44 AM, Paul Richard Thomas via Fortran wrote:
> This one is trivial. The wrong error message was transformed by my patch
> for PR98897 into an ICE. This patch now produces the correct error.
>
> Regtests OK on FC33/x86_64 - OK for the affected branches?
>
> Paul
>
> Fortran: Fix ICE on wrong code [PR99818].
>
> 2021-04-01  Paul Thomas  <pault@gcc.gnu.org>
>
> gcc/fortran/ChangeLog
>
> PR fortran/99818
> * interface.c (compare_parameter): The codimension attribute is
> applied to the _data field of class formal arguments.
>
> gcc/testsuite/ChangeLog
>
> PR fortran/99818
> * gfortran.dg/coarray_48.f90: New test.


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

* Re: [Patch, fortran] PR99818 - [10/11 Regression] ICE in gfc_get_tree_for_caf_expr, at fortran/trans-expr.c:2186
  2021-04-02  3:11 ` Jerry DeLisle
@ 2021-04-05  6:24   ` Paul Richard Thomas
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Richard Thomas @ 2021-04-05  6:24 UTC (permalink / raw)
  To: Jerry DeLisle; +Cc: fortran, gcc-patches

Hi Jerry,

A belated thanks is in order. Pushed as
fc27115d6107f219e6f3dc610c99210005fe9dc5. I'll wait a little while for
10-branch since it is an ICE on wrong code.

Regards

Paul


On Fri, 2 Apr 2021 at 04:11, Jerry DeLisle <jvdelisle@charter.net> wrote:

> Paul,
>
> This looks OK to me for Trunk. I believe 10 is in freeze so it may have
> to wait or get release manager approval.
>
> Jerry
>
> On 4/1/21 6:44 AM, Paul Richard Thomas via Fortran wrote:
> > This one is trivial. The wrong error message was transformed by my patch
> > for PR98897 into an ICE. This patch now produces the correct error.
> >
> > Regtests OK on FC33/x86_64 - OK for the affected branches?
> >
> > Paul
> >
> > Fortran: Fix ICE on wrong code [PR99818].
> >
> > 2021-04-01  Paul Thomas  <pault@gcc.gnu.org>
> >
> > gcc/fortran/ChangeLog
> >
> > PR fortran/99818
> > * interface.c (compare_parameter): The codimension attribute is
> > applied to the _data field of class formal arguments.
> >
> > gcc/testsuite/ChangeLog
> >
> > PR fortran/99818
> > * gfortran.dg/coarray_48.f90: New test.
>
>

-- 
"If you can't explain it simply, you don't understand it well enough" -
Albert Einstein

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

end of thread, other threads:[~2021-04-05  6:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01 13:44 [Patch, fortran] PR99818 - [10/11 Regression] ICE in gfc_get_tree_for_caf_expr, at fortran/trans-expr.c:2186 Paul Richard Thomas
2021-04-02  3:11 ` Jerry DeLisle
2021-04-05  6:24   ` Paul Richard Thomas

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