OSDN Git Service

2010-06-28 Martin Jambor <mjambor@suse.cz>
authorjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Jun 2010 15:42:01 +0000 (15:42 +0000)
committerjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Jun 2010 15:42:01 +0000 (15:42 +0000)
PR c++/44535
* gimple-fold.c (get_first_base_binfo_with_virtuals): New function.
(gimple_get_relevant_ref_binfo): Use get_first_base_binfo_with_virtuals
instead of BINFO_BASE_BINFO.

* testsuite/g++.dg/torture/pr44535.C: New test.

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

gcc/ChangeLog
gcc/gimple-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr44535.C [new file with mode: 0644]

index fd8b6d9..1b4f2d1 100644 (file)
@@ -1,3 +1,10 @@
+2010-06-28  Martin Jambor  <mjambor@suse.cz>
+
+       PR c++/44535
+       * gimple-fold.c (get_first_base_binfo_with_virtuals): New function.
+       (gimple_get_relevant_ref_binfo): Use get_first_base_binfo_with_virtuals
+       instead of BINFO_BASE_BINFO.
+
 2010-06-28  Michael Matz  <matz@suse.de>
 
        PR middle-end/44592
index 8fb604d..491611f 100644 (file)
@@ -1476,6 +1476,22 @@ gimple_fold_builtin (gimple stmt)
   return result;
 }
 
+/* Return the first of the base binfos of BINFO that has virtual functions.  */
+
+static tree
+get_first_base_binfo_with_virtuals (tree binfo)
+{
+  int i;
+  tree base_binfo;
+
+  for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+    if (BINFO_VIRTUALS (base_binfo))
+      return base_binfo;
+
+  return NULL_TREE;
+}
+
+
 /* Search for a base binfo of BINFO that corresponds to TYPE and return it if
    it is found or NULL_TREE if it is not.  */
 
@@ -1531,8 +1547,8 @@ gimple_get_relevant_ref_binfo (tree ref, tree known_binfo)
              || BINFO_N_BASE_BINFOS (binfo) == 0)
            return NULL_TREE;
 
-         base_binfo = BINFO_BASE_BINFO (binfo, 0);
-         if (BINFO_TYPE (base_binfo) != TREE_TYPE (field))
+         base_binfo = get_first_base_binfo_with_virtuals (binfo);
+         if (base_binfo && BINFO_TYPE (base_binfo) != TREE_TYPE (field))
            {
              tree d_binfo;
 
index 7bdfc34..3326446 100644 (file)
@@ -1,3 +1,8 @@
+2010-06-28  Martin Jambor  <mjambor@suse.cz>
+
+       PR c++/44535
+       * g++.dg/torture/pr44535.C: New test.
+
 2010-06-28  Michael Matz  <matz@suse.de>
 
        PR middle-end/44592
diff --git a/gcc/testsuite/g++.dg/torture/pr44535.C b/gcc/testsuite/g++.dg/torture/pr44535.C
new file mode 100644 (file)
index 0000000..9126f39
--- /dev/null
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+
+namespace FOO {
+
+template <typename T>
+class A
+{
+public:
+    void Enum();
+    virtual void OnProv() = 0;
+    virtual ~A() { }
+};
+typedef A<char> B;
+
+template<typename T>
+void A<T>::Enum ()
+{
+    OnProv ();
+}
+} // namespace FOO
+
+class C {};
+
+class D: public C, public FOO::B {
+public:
+    void OnProv() {}
+};
+
+int main(int argc, char *argv[])
+{
+    D x;
+    x.Enum();
+    return 0;
+}