aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2007-12-31 18:05:10 +0000
committerPaul Thomas <pault@gcc.gnu.org>2007-12-31 18:05:10 +0000
commit63287e10a8527f9ed9d7c3939943ab1bc66aa46b (patch)
treedaf721ae8c46819c335ccc6f7647203507b90390 /gcc
parent881466d851f3c806692bda4569a4534d89848104 (diff)
downloadgcc-63287e10a8527f9ed9d7c3939943ab1bc66aa46b.zip
gcc-63287e10a8527f9ed9d7c3939943ab1bc66aa46b.tar.gz
gcc-63287e10a8527f9ed9d7c3939943ab1bc66aa46b.tar.bz2
re PR fortran/34558 (ICE with same TYPE in both program and interface)
2007-12-31 Paul Thomas <pault@gcc.gnu.org> PR fortran/34558 * interface.c (gfc_compare_types): Prevent linked lists from putting this function into an endless recursive loop. 2007-12-31 Paul Thomas <pault@gcc.gnu.org> PR fortran/34558 * gfortran.dg/linked_list_1.f90: New test. From-SVN: r131238
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/interface.c12
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/linked_list_1.f9032
4 files changed, 54 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 57574ce..8b92ad1 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2007-12-31 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/34558
+ * interface.c (gfc_compare_types): Prevent linked lists from
+ putting this function into an endless recursive loop.
+
2007-12-26 Daniel Franke <franke.daniel@gmail.com>
PR fortran/34532
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index b242d07..717f3b7 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -407,7 +407,17 @@ gfc_compare_derived_types (gfc_symbol *derived1, gfc_symbol *derived2)
if (dt1->dimension && gfc_compare_array_spec (dt1->as, dt2->as) == 0)
return 0;
- if (gfc_compare_types (&dt1->ts, &dt2->ts) == 0)
+ /* Make sure that link lists do not put this function in an
+ endless loop! */
+ if (!(dt1->ts.type == BT_DERIVED && derived1 == dt1->ts.derived)
+ && !(dt1->ts.type == BT_DERIVED && derived1 == dt1->ts.derived)
+ && gfc_compare_types (&dt1->ts, &dt2->ts) == 0)
+ return 0;
+
+ else if (dt1->ts.type != BT_DERIVED
+ || derived1 != dt1->ts.derived
+ || dt2->ts.type != BT_DERIVED
+ || derived2 != dt2->ts.derived)
return 0;
dt1 = dt1->next;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7dd4fc0..c7a8e3e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-12-31 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/34558
+ * gfortran.dg/linked_list_1.f90: New test.
+
2007-12-29 Richard Sandiford <rsandifo@nildram.co.uk>
* lib/objc.exp (objc_libgcc_s_path): Set objc_libgcc_s_path
diff --git a/gcc/testsuite/gfortran.dg/linked_list_1.f90 b/gcc/testsuite/gfortran.dg/linked_list_1.f90
new file mode 100644
index 0000000..8066bcb
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/linked_list_1.f90
@@ -0,0 +1,32 @@
+! { dg-do compile }
+! Regression. ICE on valid code.
+! The following worked with 4.1.3 and 4.2.2, but failed
+! (segmentation fault) with 4.3.0 because the type comparison
+! tried to comparethe types of the components of type(node), even
+! though the only component is of type(node).
+!
+! Found using the Fortran Company Fortran 90 Test Suite (Lite),
+! Version 1.4
+!
+! Reported by Tobias Burnus <burnus@gcc.gnu.org>
+!
+program error
+ implicit none
+ type node
+ sequence
+ type(node), pointer :: next
+ end type
+ type(node), pointer :: list
+
+ interface
+ subroutine insert(ptr)
+ implicit none
+ type node
+ sequence
+ type(node), pointer :: next
+ end type
+ type(node), pointer :: ptr
+ end subroutine insert
+ end interface
+ allocate (list);
+end program error