From 9f9240272d6cbe64a85a6e92e223e587e8ac55c6 Mon Sep 17 00:00:00 2001 From: pault Date: Mon, 31 Dec 2007 18:05:10 +0000 Subject: [PATCH] 2007-12-31 Paul Thomas 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 PR fortran/34558 * gfortran.dg/linked_list_1.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131238 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/interface.c | 12 ++++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/linked_list_1.f90 | 32 +++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/linked_list_1.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 57574cee239..8b92ad1aa31 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2007-12-31 Paul Thomas + + 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 PR fortran/34532 diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index b242d0707f8..717f3b78258 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 7dd4fc04b85..c7a8e3e2ffe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-12-31 Paul Thomas + + PR fortran/34558 + * gfortran.dg/linked_list_1.f90: New test. + 2007-12-29 Richard Sandiford * 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 00000000000..8066bcb3954 --- /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 +! +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 -- 2.11.0