* [Patch, fortran] PR87566 - ICE with class(*) and select
@ 2018-10-14 9:41 Paul Richard Thomas
2018-10-15 9:16 ` Thomas Koenig
0 siblings, 1 reply; 7+ messages in thread
From: Paul Richard Thomas @ 2018-10-14 9:41 UTC (permalink / raw)
To: fortran, gcc-patches; +Cc: burnus
[-- Attachment #1: Type: text/plain, Size: 1328 bytes --]
Tobias started this patch and I finished it in answering a question
that he had about a problem with the gimplifier. Along the way, I
tried the associate version of the select type test case and found
that it failed in a different way. The chunk in resolve_assoc_var
fixes that.
Bootstrapped and regtested on FC28/x86_64 - OK for trunk?
On checking to see if any other associate problems had been fixed, I
noticed, as had Dominique, that PR83146 was fixed. I committed the
testcase to trunk as revision 265148 to make sure that it remained so.
Paul
2018-10-14 Paul Thomas <pault@gcc.gnu.org>
Tobias Burnus <burnus@gcc.gnu.org>
PR fortran/87566
* resolve.c (resolve_assoc_var): Add missing array spec for
class associate names.
(resolve_select_type): Handle case where last typed component
of the selector has a different type to the expression.
* trans-expr.c (gfc_find_and_cut_at_last_class_ref): Replace
call to gfc_expr_to_initialize with call to gfc_copy_expr.
(gfc_conv_class_to_class): Guard assignment to 'len' field
against case where zero constant is supplied.
2018-10-14 Paul Thomas <pault@gcc.gnu.org>
Tobias Burnus <burnus@gcc.gnu.org>
PR fortran/87566
* gfortran.dg/select_type_44.f90: New test.
* gfortran.dg/associate_42.f90: New test.
[-- Attachment #2: submit.diff --]
[-- Type: text/x-patch, Size: 6150 bytes --]
Index: gcc/fortran/resolve.c
===================================================================
*** gcc/fortran/resolve.c (revision 264948)
--- gcc/fortran/resolve.c (working copy)
*************** resolve_assoc_var (gfc_symbol* sym, bool
*** 8675,8680 ****
--- 8675,8692 ----
if (as->corank != 0)
sym->attr.codimension = 1;
}
+ else if (sym->ts.type == BT_CLASS && (!CLASS_DATA (sym)->as || sym->assoc->rankguessed))
+ {
+ if (!CLASS_DATA (sym)->as)
+ CLASS_DATA (sym)->as = gfc_get_array_spec ();
+ as = CLASS_DATA (sym)->as;
+ as->rank = target->rank;
+ as->type = AS_DEFERRED;
+ as->corank = gfc_get_corank (target);
+ CLASS_DATA (sym)->attr.dimension = 1;
+ if (as->corank != 0)
+ CLASS_DATA (sym)->attr.codimension = 1;
+ }
}
else
{
*************** resolve_select_type (gfc_code *code, gfc
*** 8875,8883 ****
if (code->expr2)
{
! if (code->expr1->symtree->n.sym->attr.untyped)
! code->expr1->symtree->n.sym->ts = code->expr2->ts;
! selector_type = CLASS_DATA (code->expr2)->ts.u.derived;
if (code->expr2->rank && CLASS_DATA (code->expr1)->as)
CLASS_DATA (code->expr1)->as->rank = code->expr2->rank;
--- 8887,8910 ----
if (code->expr2)
{
! gfc_ref *ref2 = NULL;
! for (ref = code->expr2->ref; ref != NULL; ref = ref->next)
! if (ref->type == REF_COMPONENT
! && ref->u.c.component->ts.type == BT_CLASS)
! ref2 = ref;
!
! if (ref2)
! {
! if (code->expr1->symtree->n.sym->attr.untyped)
! code->expr1->symtree->n.sym->ts = ref->u.c.component->ts;
! selector_type = CLASS_DATA (ref2->u.c.component)->ts.u.derived;
! }
! else
! {
! if (code->expr1->symtree->n.sym->attr.untyped)
! code->expr1->symtree->n.sym->ts = code->expr2->ts;
! selector_type = CLASS_DATA (code->expr2)->ts.u.derived;
! }
if (code->expr2->rank && CLASS_DATA (code->expr1)->as)
CLASS_DATA (code->expr1)->as->rank = code->expr2->rank;
Index: gcc/fortran/trans-expr.c
===================================================================
*** gcc/fortran/trans-expr.c (revision 264948)
--- gcc/fortran/trans-expr.c (working copy)
*************** gfc_find_and_cut_at_last_class_ref (gfc_
*** 394,400 ****
e->ref = NULL;
}
! base_expr = gfc_expr_to_initialize (e);
/* Restore the original tail expression. */
if (class_ref)
--- 394,400 ----
e->ref = NULL;
}
! base_expr = gfc_copy_expr (e);
/* Restore the original tail expression. */
if (class_ref)
*************** gfc_conv_class_to_class (gfc_se *parmse,
*** 1131,1137 ****
/* Return the len component, except in the case of scalarized array
references, where the dynamic type cannot change. */
! if (!elemental && full_array && copyback)
gfc_add_modify (&parmse->post, tmp,
fold_convert (TREE_TYPE (tmp), ctree));
}
--- 1131,1138 ----
/* Return the len component, except in the case of scalarized array
references, where the dynamic type cannot change. */
! if (!elemental && full_array && copyback
! && (UNLIMITED_POLY (e) || VAR_P (tmp)))
gfc_add_modify (&parmse->post, tmp,
fold_convert (TREE_TYPE (tmp), ctree));
}
Index: gcc/testsuite/gfortran.dg/associate_42.f90
===================================================================
*** gcc/testsuite/gfortran.dg/associate_42.f90 (nonexistent)
--- gcc/testsuite/gfortran.dg/associate_42.f90 (working copy)
***************
*** 0 ****
--- 1,41 ----
+ ! { dg-do run }
+ !
+ ! Tests the fix for a bug that was found in the course of fixing PR87566.
+ !
+ ! Contributed by Paul Thomas <pault@gcc.gnu.org>
+ !
+ call AddArray
+ contains
+ subroutine AddArray()
+ type Object_array_pointer
+ class(*), pointer :: p(:) => null()
+ end type Object_array_pointer
+
+ type (Object_array_pointer) :: obj
+ character(3), target :: tgt1(2) = ['one','two']
+ character(5), target :: tgt2(2) = ['three','four ']
+ real, target :: tgt3(3) = [1.0,2.0,3.0]
+
+ obj%p => tgt1
+ associate (point => obj%p)
+ select type (point) ! Used to ICE here.
+ type is (character(*))
+ if (any (point .ne. tgt1)) stop 1
+ end select
+ point => tgt2
+ end associate
+
+ select type (z => obj%p)
+ type is (character(*))
+ if (any (z .ne. tgt2)) stop 2
+ end select
+
+ obj%p => tgt3
+ associate (point => obj%p)
+ select type (point)
+ type is (real)
+ if (any (point .ne. tgt3)) stop 3
+ end select
+ end associate
+ end subroutine AddArray
+ end
Index: gcc/testsuite/gfortran.dg/select_type_44.f90
===================================================================
*** gcc/testsuite/gfortran.dg/select_type_44.f90 (nonexistent)
--- gcc/testsuite/gfortran.dg/select_type_44.f90 (working copy)
***************
*** 0 ****
--- 1,42 ----
+ ! { dg-do run }
+ !
+ ! Test the fix for PR87566
+ !
+ ! Contributed by Antony Lewis <antony@cosmologist.info>
+ !
+ call AddArray
+ contains
+ subroutine AddArray()
+ type Object_array_pointer
+ class(*), pointer :: p(:) => null()
+ end type Object_array_pointer
+ class(*), pointer :: Pt => null()
+ type (Object_array_pointer) :: obj
+ character(3), target :: tgt1(2) = ['one','two']
+ character(5), target :: tgt2(2) = ['three','four ']
+
+ allocate (Pt, source = Object_array_pointer ())
+ select type (Pt)
+ type is (object_array_pointer)
+ Pt%p => tgt1
+ end select
+
+ select type (Pt)
+ class is (object_array_pointer)
+ select type (Point=> Pt%P)
+ type is (character(*))
+ if (any (Point .ne. tgt1)) stop 1
+ Point = ['abc','efg']
+ end select
+ end select
+
+ select type (Pt)
+ class is (object_array_pointer)
+ select type (Point=> Pt%P)
+ type is (character(*))
+ if (any (Point .ne. ['abc','efg'])) stop 2
+ end select
+ end select
+
+ end subroutine AddArray
+ end
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Patch, fortran] PR87566 - ICE with class(*) and select
2018-10-14 9:41 [Patch, fortran] PR87566 - ICE with class(*) and select Paul Richard Thomas
@ 2018-10-15 9:16 ` Thomas Koenig
2018-10-15 16:33 ` Paul Richard Thomas
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Koenig @ 2018-10-15 9:16 UTC (permalink / raw)
To: Paul Richard Thomas, fortran, gcc-patches; +Cc: burnus
Hi Paul,
> Bootstrapped and regtested on FC28/x86_64 - OK for trunk?
Looks good. Thanks!
Regards
Thomas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Patch, fortran] PR87566 - ICE with class(*) and select
2018-10-15 9:16 ` Thomas Koenig
@ 2018-10-15 16:33 ` Paul Richard Thomas
0 siblings, 0 replies; 7+ messages in thread
From: Paul Richard Thomas @ 2018-10-15 16:33 UTC (permalink / raw)
To: Thomas Koenig; +Cc: fortran, gcc-patches, burnus
Committed as revision 265171.
Thanks to you, Dominique and, of course, Tobias.
Paul
On Mon, 15 Oct 2018 at 10:15, Thomas Koenig <tkoenig@netcologne.de> wrote:
>
> Hi Paul,
>
> > Bootstrapped and regtested on FC28/x86_64 - OK for trunk?
>
> Looks good. Thanks!
>
> Regards
>
> Thomas
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Patch, fortran] PR87566 - ICE with class(*) and select
@ 2018-10-15 9:11 Dominique d'Humières
2018-10-15 10:39 ` Paul Richard Thomas
2018-10-15 16:52 ` Paul Richard Thomas
0 siblings, 2 replies; 7+ messages in thread
From: Dominique d'Humières @ 2018-10-15 9:11 UTC (permalink / raw)
To: Paul Richard Thomas; +Cc: gfortran, gcc-patches
Hi Paul,
The ICEs for the following PRs 58906, a variant of 77385, 80260, and 82077, have been fixed between revision r264941 + patches and r265126 + same patches + this patch + patch for pr56386.
Cheers,
Dominique
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Patch, fortran] PR87566 - ICE with class(*) and select
2018-10-15 9:11 Dominique d'Humières
@ 2018-10-15 10:39 ` Paul Richard Thomas
2018-10-15 18:27 ` Dominique d'Humières
2018-10-15 16:52 ` Paul Richard Thomas
1 sibling, 1 reply; 7+ messages in thread
From: Paul Richard Thomas @ 2018-10-15 10:39 UTC (permalink / raw)
To: Dominique Dhumieres; +Cc: fortran
Hi Dominique,
Could you clarify for me:
> The ICEs for the following PRs 58906, a variant of 77385, 80260, and 82077, have been fixed between revision r264941 + patches >>> (which patches?)
and r265126 + same patches >>> (ditto)
+ this patch + patch for pr56386.
Thanks for doing all this checking. It is a huge contribution.
Regards
Paul
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Patch, fortran] PR87566 - ICE with class(*) and select
2018-10-15 10:39 ` Paul Richard Thomas
@ 2018-10-15 18:27 ` Dominique d'Humières
0 siblings, 0 replies; 7+ messages in thread
From: Dominique d'Humières @ 2018-10-15 18:27 UTC (permalink / raw)
To: Paul Richard Thomas; +Cc: fortran
> Le 15 oct. 2018 à 12:39, Paul Richard Thomas <paul.richard.thomas@gmail.com> a écrit :
>
> Hi Dominique,
>
> Could you clarify for me:
>
>> The ICEs for the following PRs 58906, a variant of 77385, 80260, and 82077, have been fixed between revision r264941 + patches >>> (which patches?)
Mostly patches for darwin + wip.
> and r265126 + same patches >>> (ditto)
> + this patch + patch for pr56386.
Actually these PRs have been fixed (at least the ICEs) by this patch (tested on a cleaner build).
Thanks for the work.
Dominique
> Thanks for doing all this checking. It is a huge contribution.
>
> Regards
>
> Paul
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Patch, fortran] PR87566 - ICE with class(*) and select
2018-10-15 9:11 Dominique d'Humières
2018-10-15 10:39 ` Paul Richard Thomas
@ 2018-10-15 16:52 ` Paul Richard Thomas
1 sibling, 0 replies; 7+ messages in thread
From: Paul Richard Thomas @ 2018-10-15 16:52 UTC (permalink / raw)
To: Dominique Dhumieres; +Cc: fortran
Hi Dominique,
I now understand what you mean about the patches and confirm what you
say about the fixes. In fact, the original of PR77385 seems to be
fixed as well.
I will sort out which of the testcases needs to be included in the
testsuite - ie. which ones have exclusive features. I will submit to
the list, when this si done.
Many thanks, once again.
Paul
On Mon, 15 Oct 2018 at 10:11, Dominique d'Humières <dominiq@lps.ens.fr> wrote:
>
> Hi Paul,
>
> The ICEs for the following PRs 58906, a variant of 77385, 80260, and 82077, have been fixed between revision r264941 + patches and r265126 + same patches + this patch + patch for pr56386.
>
> Cheers,
>
> Dominique
>
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-10-15 18:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-14 9:41 [Patch, fortran] PR87566 - ICE with class(*) and select Paul Richard Thomas
2018-10-15 9:16 ` Thomas Koenig
2018-10-15 16:33 ` Paul Richard Thomas
2018-10-15 9:11 Dominique d'Humières
2018-10-15 10:39 ` Paul Richard Thomas
2018-10-15 18:27 ` Dominique d'Humières
2018-10-15 16:52 ` 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).