public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-5400] Fortran: fix ICE in check_host_association [PR108544]
@ 2023-01-26 18:35 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2023-01-26 18:35 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:c8e07c7951421e718bcafbe5924e75c9aa133af9
commit r13-5400-gc8e07c7951421e718bcafbe5924e75c9aa133af9
Author: Harald Anlauf <anlauf@gmx.de>
Date: Wed Jan 25 22:47:26 2023 +0100
Fortran: fix ICE in check_host_association [PR108544]
gcc/fortran/ChangeLog:
PR fortran/108544
* resolve.cc (check_host_association): Extend host association check
so that it is not restricted to functions. Also prevent NULL pointer
dereference.
gcc/testsuite/ChangeLog:
PR fortran/108544
* gfortran.dg/pr108544.f90: New test.
* gfortran.dg/pr96102b.f90: New test.
Diff:
---
gcc/fortran/resolve.cc | 4 +++-
gcc/testsuite/gfortran.dg/pr108544.f90 | 11 +++++++++++
gcc/testsuite/gfortran.dg/pr96102b.f90 | 24 ++++++++++++++++++++++++
3 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 94213cd3cd4..9e2edf7be71 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -6087,7 +6087,6 @@ check_host_association (gfc_expr *e)
gfc_find_symbol (e->symtree->name, gfc_current_ns, 1, &sym);
if (sym && old_sym != sym
- && sym->ts.type == old_sym->ts.type
&& sym->attr.flavor == FL_PROCEDURE
&& sym->attr.contained)
{
@@ -6132,6 +6131,9 @@ check_host_association (gfc_expr *e)
return false;
}
+ if (ref == NULL)
+ return false;
+
gcc_assert (ref->type == REF_ARRAY);
/* Grab the start expressions from the array ref and
diff --git a/gcc/testsuite/gfortran.dg/pr108544.f90 b/gcc/testsuite/gfortran.dg/pr108544.f90
new file mode 100644
index 00000000000..783cb7aaf7b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr108544.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! PR fortran/108544 - ICE in check_host_association
+! Contributed by G.Steinmetz
+
+module m
+contains
+ subroutine s
+ select type (s => 1) ! { dg-error "Selector shall be polymorphic" }
+ end select
+ end
+end
diff --git a/gcc/testsuite/gfortran.dg/pr96102b.f90 b/gcc/testsuite/gfortran.dg/pr96102b.f90
new file mode 100644
index 00000000000..82147da3893
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr96102b.f90
@@ -0,0 +1,24 @@
+! { dg-do compile }
+!
+! PR fortran/108544 - host association
+! Variation of testcase pr96102.f90 using subroutines instead of functions
+
+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
+ subroutine n()
+ end
+ subroutine d()
+ end
+ end
+end
+
+! { dg-prune-output "Operands of comparison operator" }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-26 18:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-26 18:35 [gcc r13-5400] Fortran: fix ICE in check_host_association [PR108544] Harald Anlauf
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).