diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2015-10-24 01:33:58 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2015-10-23 23:33:58 +0000 |
commit | d36475161db73e68889937a5304b1ed13e8603e9 (patch) | |
tree | 545a2facccda5811f1da92bc222edfa3b0c0864a /gcc/ipa-polymorphic-call.c | |
parent | 3c7a8ece3e130a713f6ec6a900cadfbe50583d91 (diff) | |
download | gcc-d36475161db73e68889937a5304b1ed13e8603e9.zip gcc-d36475161db73e68889937a5304b1ed13e8603e9.tar.gz gcc-d36475161db73e68889937a5304b1ed13e8603e9.tar.bz2 |
PR ipa/pr67600
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.
From-SVN: r229279
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 9ce86d1..9cf09b8 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; |