aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2010-11-02 16:06:21 +0100
committerMartin Jambor <jamborm@gcc.gnu.org>2010-11-02 16:06:21 +0100
commitb85020cb469d6fb73eb055c169d18b3f5c14a95a (patch)
tree6dc28e554ea1adf78ab13d47bed16c79ae66a360 /gcc
parent181e5ea4f4794af8339d86c5c186346951da810c (diff)
downloadgcc-b85020cb469d6fb73eb055c169d18b3f5c14a95a.zip
gcc-b85020cb469d6fb73eb055c169d18b3f5c14a95a.tar.gz
gcc-b85020cb469d6fb73eb055c169d18b3f5c14a95a.tar.bz2
re PR tree-optimization/45875 (ice in gimple_fold_obj_type_ref_known_binfo with -O2)
2010-11-02 Martin Jambor <mjambor@suse.cz> PR tree-optimization/45875 * gimple-fold.c (get_first_base_binfo_with_virtuals): Removed. (gimple_get_relevant_ref_binfo): Detect primary bases according to their field offset. * testsuite/g++.dg/torture/pr45875.C: New test. From-SVN: r166190
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/gimple-fold.c25
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/torture/pr45875.C25
4 files changed, 42 insertions, 20 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8a258c4..c946683 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2010-11-02 Martin Jambor <mjambor@suse.cz>
+
+ PR tree-optimization/45875
+ * gimple-fold.c (get_first_base_binfo_with_virtuals): Removed.
+ (gimple_get_relevant_ref_binfo): Detect primary bases according to
+ their field offset.
+
2010-11-02 Ian Lance Taylor <iant@google.com>
* configure.ac: Remove elf_getshdrstrndx test. Don't substitute
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 6862c126..f77b630 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -1360,22 +1360,6 @@ 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. */
@@ -1413,7 +1397,7 @@ gimple_get_relevant_ref_binfo (tree ref, tree known_binfo)
if (TREE_CODE (ref) == COMPONENT_REF)
{
tree par_type;
- tree binfo, base_binfo;
+ tree binfo;
tree field = TREE_OPERAND (ref, 1);
if (!DECL_ARTIFICIAL (field))
@@ -1431,14 +1415,15 @@ gimple_get_relevant_ref_binfo (tree ref, tree known_binfo)
|| BINFO_N_BASE_BINFOS (binfo) == 0)
return NULL_TREE;
- base_binfo = get_first_base_binfo_with_virtuals (binfo);
- if (base_binfo && BINFO_TYPE (base_binfo) != TREE_TYPE (field))
+ /* Offset 0 indicates the primary base, whose vtable contents are
+ represented in the binfo for the derived class. */
+ if (int_bit_position (field) != 0)
{
tree d_binfo;
+ /* Get descendant binfo. */
d_binfo = gimple_get_relevant_ref_binfo (TREE_OPERAND (ref, 0),
known_binfo);
- /* Get descendant binfo. */
if (!d_binfo)
return NULL_TREE;
return get_base_binfo_for_type (d_binfo, TREE_TYPE (field));
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7b38520..aa80464 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-11-02 Martin Jambor <mjambor@suse.cz>
+
+ PR tree-optimization/45875
+ * g++.dg/torture/pr45875.C: New test.
+
2010-11-02 Richard Guenther <rguenther@suse.de>
PR testsuite/46249
diff --git a/gcc/testsuite/g++.dg/torture/pr45875.C b/gcc/testsuite/g++.dg/torture/pr45875.C
new file mode 100644
index 0000000..f1347f5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr45875.C
@@ -0,0 +1,25 @@
+// { dg-do compile }
+
+struct c1 {};
+
+struct c10 : c1
+{
+ virtual void foo ();
+};
+
+struct c11 : c10, c1 // // { dg-warning "" }
+{
+ virtual void f6 ();
+};
+
+struct c28 : virtual c11
+{
+ void f6 ();
+};
+
+void check_c28 ()
+{
+ c28 obj;
+ c11 *ptr = &obj;
+ ptr->f6 ();
+}