aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2017-01-17 16:11:00 +0100
committerMartin Liska <marxin@gcc.gnu.org>2017-01-17 15:11:00 +0000
commit4f197ff9a82986bea40e6075c55b45348e4495ef (patch)
treeaa831e6b8e4dbe3d5b87f14a88d0c7462426950d /gcc
parent408de159d47ec1da831ec7c8fa752c68fad618c8 (diff)
downloadgcc-4f197ff9a82986bea40e6075c55b45348e4495ef.zip
gcc-4f197ff9a82986bea40e6075c55b45348e4495ef.tar.gz
gcc-4f197ff9a82986bea40e6075c55b45348e4495ef.tar.bz2
Fix wrong assumption in contains_type_p (PR ipa/71207).
2017-01-17 Martin Liska <mliska@suse.cz> PR ipa/71207 * g++.dg/ipa/pr71207.C: New test. 2017-01-17 Martin Liska <mliska@suse.cz> PR ipa/71207 * ipa-polymorphic-call.c (contains_type_p): Fix wrong assumption and add comment. From-SVN: r244530
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/ipa-polymorphic-call.c12
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/ipa/pr71207.C42
4 files changed, 59 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 43419be..282d1c9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-01-17 Martin Liska <mliska@suse.cz>
+
+ PR ipa/71207
+ * ipa-polymorphic-call.c (contains_type_p): Fix wrong
+ assumption and add comment.
+
2017-01-17 Nathan Sidwell <nathan@acm.org>
* ipa-visibility.c (localize_node): New function, broken out of ...
diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c
index da64ce4..e690d05 100644
--- a/gcc/ipa-polymorphic-call.c
+++ b/gcc/ipa-polymorphic-call.c
@@ -463,12 +463,12 @@ contains_type_p (tree outer_type, HOST_WIDE_INT offset,
/* Check that type is within range. */
if (offset < 0)
return false;
- if (TYPE_SIZE (outer_type) && TYPE_SIZE (otr_type)
- && TREE_CODE (TYPE_SIZE (outer_type)) == INTEGER_CST
- && TREE_CODE (TYPE_SIZE (otr_type)) == INTEGER_CST
- && wi::ltu_p (wi::to_offset (TYPE_SIZE (outer_type)),
- (wi::to_offset (TYPE_SIZE (otr_type)) + offset)))
- return false;
+
+ /* PR ipa/71207
+ As OUTER_TYPE can be a type which has a diamond virtual inheritance,
+ it's not necessary that INNER_TYPE will fit within OUTER_TYPE with
+ a given offset. It can happen that INNER_TYPE also contains a base object,
+ however it would point to the same instance in the OUTER_TYPE. */
context.offset = offset;
context.outer_type = TYPE_MAIN_VARIANT (outer_type);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c34cac3..f7d4fa2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-01-17 Martin Liska <mliska@suse.cz>
+
+ PR ipa/71207
+ * g++.dg/ipa/pr71207.C: New test.
+
2017-01-17 Jan Hubicka <hubicka@ucw.cz>
PR middle-end/77445
diff --git a/gcc/testsuite/g++.dg/ipa/pr71207.C b/gcc/testsuite/g++.dg/ipa/pr71207.C
new file mode 100644
index 0000000..19a0399
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr71207.C
@@ -0,0 +1,42 @@
+/* PR ipa/71207 */
+/* { dg-do run } */
+
+class Class1
+{
+public:
+ Class1() {};
+ virtual ~Class1() {};
+
+protected:
+ unsigned Field1;
+};
+
+class Class2 : public virtual Class1
+{
+};
+
+class Class3 : public virtual Class1
+{
+public:
+ virtual void Method1() = 0;
+
+ void Method2()
+ {
+ Method1();
+ }
+};
+
+class Class4 : public Class2, public virtual Class3
+{
+public:
+ Class4() {};
+ virtual void Method1() {};
+};
+
+int main()
+{
+ Class4 var1;
+ var1.Method2();
+
+ return 0;
+}