[C++ PATCH] Fix resolve_virtual_fun_from_obj_type_ref on ia64 (PR c++/31941)
Jakub Jelinek
jakub@redhat.com
Thu Aug 23 14:06:00 GMT 2007
Hi!
The following testcase ICEs during error reporting on ia64, works
on all other arches.
The problem is that resolve_virtual_fun_from_obj_type_ref doesn't
treat OBJ_TYPE_REF_TOKEN properly, on TARGET_VTABLE_USES_DESCRIPTORS
architectures OBJ_TYPE_REF_TOKEN is the index into the vtable
multiplied by TARGET_VTABLE_USES_DESCRIPTORS.
The following patch adjusts resolve_virtual_fun_from_obj_type_ref
to do the same as cp_fold_obj_type_ref.
Ok for 4.3/4.2/4.1?
2007-08-23 Jakub Jelinek <jakub@redhat.com>
PR c++/31941
* error.c (resolve_virtual_fun_from_obj_type_ref): Handle
TARGET_VTABLE_USES_DESCRIPTORS targets properly.
* g++.dg/parse/crash37.C: New test.
--- gcc/cp/error.c.jj 2007-08-20 09:49:18.000000000 +0200
+++ gcc/cp/error.c 2007-08-23 15:20:53.000000000 +0200
@@ -1438,10 +1438,14 @@ static tree
resolve_virtual_fun_from_obj_type_ref (tree ref)
{
tree obj_type = TREE_TYPE (OBJ_TYPE_REF_OBJECT (ref));
- int index = tree_low_cst (OBJ_TYPE_REF_TOKEN (ref), 1);
+ HOST_WIDE_INT index = tree_low_cst (OBJ_TYPE_REF_TOKEN (ref), 1);
tree fun = BINFO_VIRTUALS (TYPE_BINFO (TREE_TYPE (obj_type)));
- while (index--)
+ while (index)
+ {
fun = TREE_CHAIN (fun);
+ index -= (TARGET_VTABLE_USES_DESCRIPTORS
+ ? TARGET_VTABLE_USES_DESCRIPTORS : 1);
+ }
return BV_FN (fun);
}
--- gcc/testsuite/g++.dg/parse/crash37.C.jj 2007-08-23 15:34:43.000000000 +0200
+++ gcc/testsuite/g++.dg/parse/crash37.C 2007-08-23 15:32:32.000000000 +0200
@@ -0,0 +1,15 @@
+// PR c++/31941
+// { dg-do compile }
+
+struct S
+{
+ S() throw () { }
+ virtual ~S () throw ();
+ virtual const char* what () const throw ();
+};
+
+const char *
+foo (S &e)
+{
+ return e.what ().c_str (); // { dg-error "c_str.*S::what.*which is of non-class type" }
+}
Jakub
More information about the Gcc-patches
mailing list