Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/ipa/devirt-36.C @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 1830386684a0 |
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" } } */