* [Patch, fortran] PR96102 - ICE in check_host_association, at fortran/resolve.c:5994
@ 2020-08-05 14:59 Paul Richard Thomas
2020-08-05 15:40 ` Steve Kargl
0 siblings, 1 reply; 4+ messages in thread
From: Paul Richard Thomas @ 2020-08-05 14:59 UTC (permalink / raw)
To: fortran, gcc-patches; +Cc: Steve Kargl
[-- Attachment #1: Type: text/plain, Size: 210 bytes --]
The attached patch builds on a draft posted by Steve Kargl. I have left the
gcc_assert in place just in case my imagination was too limited to generate
an ICE.
Regtests OK on FC31/x86_64 - OK for trunk?
Paul
[-- Attachment #2: Change.Logs --]
[-- Type: application/octet-stream, Size: 322 bytes --]
This patch fixes PR96102. See the explanatory comment in the testcase.
2020-08-05 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/96102
* resolve.c (check_host_association): Replace the gcc_assert
with an error for internal procedures.
gcc/testsuite/
PR fortran/96102
* gfortran.dg/pr96102.f90: New test.
[-- Attachment #3: submit.diff --]
[-- Type: text/x-patch, Size: 745 bytes --]
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 2751c0ccf62..4046bed1863 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -5993,6 +5993,17 @@ check_host_association (gfc_expr *e)
if (ref->type == REF_ARRAY && ref->next == NULL)
break;
+ if ((ref == NULL || ref->type != REF_ARRAY)
+ && old_sym->attr.flavor == FL_VARIABLE
+ && sym->attr.proc == PROC_INTERNAL)
+ {
+ gfc_error ("%qs at %L is being host associated into "
+ "a contained procedure with an internal "
+ "procedure of the same name", sym->name,
+ &sym->declared_at);
+ return false;
+ }
+
gcc_assert (ref->type == REF_ARRAY);
/* Grab the start expressions from the array ref and
[-- Attachment #4: pr96102.f90 --]
[-- Type: text/x-fortran, Size: 721 bytes --]
! { dg-do compile }
!
! Test the fix for PR96102 in which the two lines with IF statements
! errors previously caused a segfault.
!
! Contributed by Gerhardt Steinmetz <gscfq@t-online.de>
!
!
module m
type mytype
integer :: i
end type
type(mytype) :: d = mytype (42) ! { dg-error "is host associated" }
integer :: n = 2 ! { dg-error "is host associated" }
contains
subroutine s
if ( n /= 0 ) stop 1 ! { dg-error "internal procedure of the same name" }
if ( d%i /= 0 ) stop 2 ! { dg-error "internal procedure of the same name" }
contains
integer function n()
n = 0
end
type(mytype) function d()
d = mytype (0)
end
end
end
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, fortran] PR96102 - ICE in check_host_association, at fortran/resolve.c:5994
2020-08-05 14:59 [Patch, fortran] PR96102 - ICE in check_host_association, at fortran/resolve.c:5994 Paul Richard Thomas
@ 2020-08-05 15:40 ` Steve Kargl
2020-08-06 5:21 ` Paul Richard Thomas
0 siblings, 1 reply; 4+ messages in thread
From: Steve Kargl @ 2020-08-05 15:40 UTC (permalink / raw)
To: Paul Richard Thomas; +Cc: fortran, gcc-patches
On Wed, Aug 05, 2020 at 03:59:38PM +0100, Paul Richard Thomas wrote:
> The attached patch builds on a draft posted by Steve Kargl. I have left the
> gcc_assert in place just in case my imagination was too limited to generate
> an ICE.
>
> Regtests OK on FC31/x86_64 - OK for trunk?
>
Looks OK to me.
--
Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, fortran] PR96102 - ICE in check_host_association, at fortran/resolve.c:5994
2020-08-05 15:40 ` Steve Kargl
@ 2020-08-06 5:21 ` Paul Richard Thomas
2020-08-09 9:58 ` Thomas Koenig
0 siblings, 1 reply; 4+ messages in thread
From: Paul Richard Thomas @ 2020-08-06 5:21 UTC (permalink / raw)
To: Steve Kargl; +Cc: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 880 bytes --]
Dear All,
Dominique has kindly pointed out that the error message in the patch does
not correspond to the errors in the testcase. This came about because the
submitted patch was an earlier version of that on my tree. Please find
attached the correct version of the patch. The principle is the same but
the error is different... if you see what I mean :-)
Paul
On Wed, 5 Aug 2020 at 16:40, Steve Kargl <sgk@troutmask.apl.washington.edu>
wrote:
> On Wed, Aug 05, 2020 at 03:59:38PM +0100, Paul Richard Thomas wrote:
> > The attached patch builds on a draft posted by Steve Kargl. I have left
> the
> > gcc_assert in place just in case my imagination was too limited to
> generate
> > an ICE.
> >
> > Regtests OK on FC31/x86_64 - OK for trunk?
> >
>
> Looks OK to me.
>
> --
> Steve
>
--
"If you can't explain it simply, you don't understand it well enough" -
Albert Einstein
[-- Attachment #2: submit.diff --]
[-- Type: text/x-patch, Size: 716 bytes --]
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 2751c0ccf62..6caddcf4ef0 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -5993,6 +5993,16 @@ check_host_association (gfc_expr *e)
if (ref->type == REF_ARRAY && ref->next == NULL)
break;
+ if ((ref == NULL || ref->type != REF_ARRAY)
+ && sym->attr.proc == PROC_INTERNAL)
+ {
+ gfc_error ("%qs at %L is host associated at %L into "
+ "a contained procedure with an internal "
+ "procedure of the same name", sym->name,
+ &old_sym->declared_at, &e->where);
+ return false;
+ }
+
gcc_assert (ref->type == REF_ARRAY);
/* Grab the start expressions from the array ref and
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, fortran] PR96102 - ICE in check_host_association, at fortran/resolve.c:5994
2020-08-06 5:21 ` Paul Richard Thomas
@ 2020-08-09 9:58 ` Thomas Koenig
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Koenig @ 2020-08-09 9:58 UTC (permalink / raw)
To: Paul Richard Thomas, Steve Kargl; +Cc: gcc-patches, fortran
Hi Paul,
> Dominique has kindly pointed out that the error message in the patch does
> not correspond to the errors in the testcase. This came about because the
> submitted patch was an earlier version of that on my tree. Please find
> attached the correct version of the patch. The principle is the same but
> the error is different... if you see what I mean :-)
OK for master.
Best regards
Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-09 9:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-05 14:59 [Patch, fortran] PR96102 - ICE in check_host_association, at fortran/resolve.c:5994 Paul Richard Thomas
2020-08-05 15:40 ` Steve Kargl
2020-08-06 5:21 ` Paul Richard Thomas
2020-08-09 9:58 ` Thomas Koenig
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).