Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/ipa/devirt-6.C @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children |
line wrap: on
line source
/* Verify that we either do not do any devirtualization or correctly spot that foo changes the dynamic type of the passed object. */ /* { dg-do run } */ /* { dg-options "-O3" } */ extern "C" void abort (void); extern "C" void *malloc(__SIZE_TYPE__); inline void* operator new(__SIZE_TYPE__, void* __p) throw() { return __p;} int x; class A { public: virtual ~A() { } }; class B : public A { public: virtual ~B() { if (x == 1) abort (); x = 1; } }; void __attribute__((noinline,noclone)) foo (void *p) { B *b = reinterpret_cast<B *>(p); b->~B(); new (p) A; } int main() { void *p = __builtin_malloc (sizeof (B)); new (p) B; foo(p); reinterpret_cast<A *>(p)->~A(); return 0; }