2007-12-31 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 31 Dec 2007 18:10:55 +0000 (18:10 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 31 Dec 2007 18:10:55 +0000 (18:10 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131239 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/interface.c

index 717f3b7..519251e 100644 (file)
@@ -407,17 +407,19 @@ gfc_compare_derived_types (gfc_symbol *derived1, gfc_symbol *derived2)
       if (dt1->dimension && gfc_compare_array_spec (dt1->as, dt2->as) == 0)
        return 0;
 
-      /* Make sure that link lists do not put this function in an
-        endless loop!  */
+      /* Make sure that link lists do not put this function into an 
+        endless recursive 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)
+      else if ((dt1->ts.type == BT_DERIVED && derived1 == dt1->ts.derived)
+               && !(dt1->ts.type == BT_DERIVED && derived1 == dt1->ts.derived))
+       return 0;
+
+      else if (!(dt1->ts.type == BT_DERIVED && derived1 == dt1->ts.derived)
+               && (dt1->ts.type == BT_DERIVED && derived1 == dt1->ts.derived))
        return 0;
 
       dt1 = dt1->next;