diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-10-23 23:33:58 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-10-23 23:33:58 +0000 |
commit | 5e98110dba633896d641ed087d52fc76e2748fd2 (patch) | |
tree | 545a2facccda5811f1da92bc222edfa3b0c0864a /gcc/ipa-polymorphic-call.c | |
parent | 7d5b194cdac06ff16beb5429686eb671ddcfb9c0 (diff) | |
download | gcc-5e98110dba633896d641ed087d52fc76e2748fd2.tar.gz |
PR ipa/pr67600
* ipa-polymorphic-call.c
(ipa_polymorphic_call_context::get_dynamic_type): Do not confuse
instance offset with offset of outer type.
* g++.dg/torture/pr67600.C: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229279 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ipa-polymorphic-call.c')
-rw-r--r-- | gcc/ipa-polymorphic-call.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c index 9ce86d1c7d4..9cf09b821da 100644 --- a/gcc/ipa-polymorphic-call.c +++ b/gcc/ipa-polymorphic-call.c @@ -1512,6 +1512,7 @@ ipa_polymorphic_call_context::get_dynamic_type (tree instance, /* Remember OFFSET before it is modified by restrict_to_inner_class. This is because we do not update INSTANCE when walking inwards. */ HOST_WIDE_INT instance_offset = offset; + tree instance_outer_type = outer_type; if (otr_type) otr_type = TYPE_MAIN_VARIANT (otr_type); @@ -1599,7 +1600,7 @@ ipa_polymorphic_call_context::get_dynamic_type (tree instance, } } - /* If we failed to look up the refernece in code, build our own. */ + /* If we failed to look up the reference in code, build our own. */ if (!instance_ref) { /* If the statement in question does not use memory, we can't tell @@ -1637,13 +1638,13 @@ ipa_polymorphic_call_context::get_dynamic_type (tree instance, print_generic_expr (dump_file, otr_object, TDF_SLIM); fprintf (dump_file, " Outer instance pointer: "); print_generic_expr (dump_file, instance, TDF_SLIM); - fprintf (dump_file, " offset: %i (bits)", (int)offset); + fprintf (dump_file, " offset: %i (bits)", (int)instance_offset); fprintf (dump_file, " vtbl reference: "); print_generic_expr (dump_file, instance_ref, TDF_SLIM); fprintf (dump_file, "\n"); } - tci.offset = offset; + tci.offset = instance_offset; tci.instance = instance; tci.vtbl_ptr_ref = instance_ref; gcc_assert (TREE_CODE (instance) != MEM_REF); @@ -1709,9 +1710,12 @@ ipa_polymorphic_call_context::get_dynamic_type (tree instance, && !dynamic && !tci.seen_unanalyzed_store && !tci.multiple_types_encountered - && offset == tci.offset - && types_same_for_odr (tci.known_current_type, - outer_type))) + && ((offset == tci.offset + && types_same_for_odr (tci.known_current_type, + outer_type)) + || (instance_offset == offset + && types_same_for_odr (tci.known_current_type, + instance_outer_type))))) { if (!outer_type || tci.seen_unanalyzed_store) return false; |