OSDN Git Service

PR c++/31941
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Aug 2007 23:23:26 +0000 (23:23 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Aug 2007 23:23:26 +0000 (23:23 +0000)
* error.c (resolve_virtual_fun_from_obj_type_ref): Handle
TARGET_VTABLE_USES_DESCRIPTORS targets properly.

* g++.dg/parse/crash37.C: New test.

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

gcc/cp/ChangeLog
gcc/cp/error.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/crash37.C [new file with mode: 0644]

index 62b88dc..19c149d 100644 (file)
@@ -1,3 +1,9 @@
+2007-08-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/31941
+       * error.c (resolve_virtual_fun_from_obj_type_ref): Handle
+       TARGET_VTABLE_USES_DESCRIPTORS targets properly.
+
 2007-08-22  Jason Merrill  <jason@redhat.com>
 
        PR c++/29365
index 53d8223..16ba95c 100644 (file)
@@ -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);
 }
index 340c95e..ca73666 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/31941
+       * g++.dg/parse/crash37.C: New test.
+
 2007-08-23  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/17390
diff --git a/gcc/testsuite/g++.dg/parse/crash37.C b/gcc/testsuite/g++.dg/parse/crash37.C
new file mode 100644 (file)
index 0000000..8320dfa
--- /dev/null
@@ -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" }
+}