Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/ipa/devirt-36.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 04ced10e8804 |
children |
line wrap: on
line source
/* { dg-do compile } */ /* { dg-options "-O2 -fdump-ipa-devirt-details -fdump-tree-fre1-details" } */ struct A {virtual int t(void) {return 1;}}; struct B:A {B(); virtual int t(void) {return 2;}}; struct C {int a; struct B b;}; void test2(struct A *); int m(struct B *b) { struct C *c = new (C); struct A *a = &c->b; a->t(); // This call should be devirtualized by // FRE because we know type from ctor call ((struct B *)a)->B::t(); // Make devirt possible // C++ FE won't produce inline body without this test2(a); return a->t(); // This call should be devirtualized speculatively because // test2 may change the type of A by placement new. // C++ standard is bit imprecise about this. } /* { dg-final { scan-tree-dump "converting indirect call to function virtual int B::t" "fre1" } } */ /* { dg-final { scan-ipa-dump "to virtual int B::t" "devirt" } } */ /* { dg-final { scan-ipa-dump "1 speculatively devirtualized" "devirt" } } */