]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/31941 ("confused by earlier errors" message without earlier error message)
authorJakub Jelinek <jakub@redhat.com>
Fri, 24 Aug 2007 17:12:41 +0000 (19:12 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 24 Aug 2007 17:12:41 +0000 (19:12 +0200)
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.

From-SVN: r127778

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

index db4c828b133e81428c30305f4ee80cf75ef07204..39875472b86cd419c9d2471832f8031749e1632f 100644 (file)
@@ -1,5 +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.
+
        PR c++/32898
        * name-lookup.c (set_decl_namespace): lookup_qualified_name failure
        is error_mark_node rather than NULL_TREE.
index fa25db7978d72a8cb14685fd8a41deca375534ce..c169cabedb646dff0b9a9f44654bd6f767a98e3e 100644 (file)
@@ -1305,10 +1305,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 7e1bc9295060b2e64074ca4932ec728d669c3779..4b2eca0b450cd0cacbdd2b50f2912238853db7ff 100644 (file)
@@ -1,5 +1,8 @@
 2007-08-24  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/31941
+       * g++.dg/parse/crash37.C: New test.
+
        PR c++/32898
        * g++.dg/lookup/ns3.C: New test.
 
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" }
+}