[C++ PATCH]: Fix catch match bug

Nathan Sidwell nathan@codesourcery.com
Thu May 25 04:17:00 GMT 2000


Hi,
I've installed the attached patch and testcases which fix and test
a bug in the old-abi catch matcher I discovered whilst revamping
the new-abi's matcher.

booted and tested on i686-pc-linux-gnu

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2000-05-24  Nathan Sidwell  <nathan@codesourcery.com>

	* tinfo.h (__user_type_info::contained_virtual_p): New
	predicate.
	* tinfo.cc (__user_type_info::do_upcast): Fix bug with diamond
	shaped heirarchy.
	(__vmi_class_type_info::__do_upcast): Fix bug with NULL pointer to
	diamond shaped heirarchy. Add early out for mixed diamond and
	duplicate shaped heirarchy.

Index: cp/tinfo.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/tinfo.h,v
retrieving revision 1.15
diff -c -3 -p -r1.15 tinfo.h
*** tinfo.h	2000/03/21 16:12:24	1.15
--- tinfo.h	2000/05/24 16:19:56
*************** struct __user_type_info : public std::ty
*** 79,84 ****
--- 79,89 ----
      return (access_path & (contained_mask | contained_virtual_mask))
             == contained_mask;
    }
+   static inline bool contained_virtual_p (sub_kind access_path)
+   {
+     return (access_path & (contained_mask | contained_virtual_mask))
+            == (contained_mask | contained_virtual_mask);
+   }
    
    struct upcast_result
    {
Index: cp/tinfo.cc
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/tinfo.cc,v
retrieving revision 1.31
diff -c -3 -p -r1.31 tinfo.cc
*** tinfo.cc	2000/05/24 14:17:25	1.31
--- tinfo.cc	2000/05/24 16:19:57
*************** do_upcast (sub_kind access_path,
*** 286,292 ****
  	sub_access = sub_kind (sub_access | contained_virtual_mask);
        if (base_list[i].access != PUBLIC)
          sub_access = sub_kind (sub_access & ~contained_public_mask);
!       if (base_list[i].base->do_upcast (sub_access, target, p, result2))
          return true; // must fail
        if (result2.base_type)
          {
--- 286,293 ----
  	sub_access = sub_kind (sub_access | contained_virtual_mask);
        if (base_list[i].access != PUBLIC)
          sub_access = sub_kind (sub_access & ~contained_public_mask);
!       if (base_list[i].base->do_upcast (sub_access, target, p, result2)
!           && !contained_virtual_p (result2.whole2target))
          return true; // must fail
        if (result2.base_type)
          {
*************** do_upcast (sub_kind access_path,
*** 321,326 ****
--- 322,329 ----
                    result.whole2target = contained_ambig;
                    return true;
                  }
+               result.whole2target
+                   = sub_kind (result.whole2target | result2.whole2target);
              }
          }
      }
*************** __do_upcast (const __class_type_info *ds
*** 1095,1102 ****
                  }
                else
                  {
                    if (!(vmi_flags & diamond_shaped_mask))
!                     return true; // cannot have a more accessible base
                  }
              }
            else if (result.dst_ptr != result2.dst_ptr)
--- 1098,1107 ----
                  }
                else
                  {
+                   if (!virtual_p (result.part2dst))
+                     return true; // cannot have another path
                    if (!(vmi_flags & diamond_shaped_mask))
!                     return true; // cannot have a more accessible path
                  }
              }
            else if (result.dst_ptr != result2.dst_ptr)
*************** __do_upcast (const __class_type_info *ds
*** 1125,1130 ****
--- 1130,1137 ----
                    result.part2dst = __contained_ambig;
                    return true;
                  }
+               result.part2dst
+                   = __sub_kind (result.part2dst | result2.part2dst);
              }
          }
      }


More information about the Gcc-patches mailing list