re PR ipa/60965 (IPA: Devirtualization versus placement new)
PR ipa/60965 * ipa-devirt.c (get_class_context): Allow POD to change to non-POD. * g++.dg/ipa/devirt-32.C: New testcase. From-SVN: r210086
This commit is contained in:
parent
aaeaa9a91c
commit
e400f08159
4 changed files with 44 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
2014-05-05 Jan Hubicka <hubicka@ucw.cz>
|
||||
|
||||
PR ipa/60965
|
||||
* ipa-devirt.c (get_class_context): Allow POD to change to non-POD.
|
||||
|
||||
2014-05-05 Radovan Obradovic <robradovic@mips.com>
|
||||
Tom de Vries <tom@codesourcery.com>
|
||||
|
||||
|
|
|
@ -1137,6 +1137,17 @@ give_up:
|
|||
context->outer_type = expected_type;
|
||||
context->offset = 0;
|
||||
context->maybe_derived_type = true;
|
||||
context->maybe_in_construction = true;
|
||||
/* POD can be changed to an instance of a polymorphic type by
|
||||
placement new. Here we play safe and assume that any
|
||||
non-polymorphic type is POD. */
|
||||
if ((TREE_CODE (type) != RECORD_TYPE
|
||||
|| !TYPE_BINFO (type)
|
||||
|| !polymorphic_type_binfo_p (TYPE_BINFO (type)))
|
||||
&& (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST
|
||||
|| (offset + tree_to_uhwi (TYPE_SIZE (expected_type)) <=
|
||||
tree_to_uhwi (TYPE_SIZE (type)))))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2014-05-05 Jan Hubicka <hubicka@ucw.cz>
|
||||
|
||||
PR ipa/60965
|
||||
* g++.dg/ipa/devirt-32.C: New testcase.
|
||||
|
||||
2014-05-05 Richard Biener <rguenther@suse.de>
|
||||
|
||||
PR middle-end/61010
|
||||
|
|
23
gcc/testsuite/g++.dg/ipa/devirt-32.C
Normal file
23
gcc/testsuite/g++.dg/ipa/devirt-32.C
Normal file
|
@ -0,0 +1,23 @@
|
|||
/* { dg-options "-O2 -std=c++11 -fdump-ipa-inline" } */
|
||||
#include <new>
|
||||
|
||||
class EmbeddedObject {
|
||||
public:
|
||||
virtual int val() { return 2; }
|
||||
};
|
||||
|
||||
class Container {
|
||||
alignas(EmbeddedObject) char buffer[sizeof(EmbeddedObject)];
|
||||
public:
|
||||
EmbeddedObject *obj() { return (EmbeddedObject*)buffer; }
|
||||
Container() { new (buffer) EmbeddedObject(); }
|
||||
};
|
||||
|
||||
Container o;
|
||||
|
||||
int main()
|
||||
{
|
||||
__builtin_printf("%d\n", o.obj()->val());
|
||||
}
|
||||
/* { dg-final { scan-ipa-dump-not "__builtin_unreachable" "inline" } } */
|
||||
/* { dg-final { cleanup-ipa-dump "inline" } } */
|
Loading…
Add table
Reference in a new issue