OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [ipa/] [devirt-6.C] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
/* Verify that we either do not do any devirtualization or correctly
2
   spot that foo changes the dynamic type of the passed object.  */
3
 
4
/* { dg-do run } */
5
/* { dg-options "-O3"  } */
6
 
7
extern "C" void abort (void);
8
extern "C" void *malloc(__SIZE_TYPE__);
9
 
10
inline void* operator new(__SIZE_TYPE__, void* __p) throw() { return __p;}
11
 
12
int x;
13
 
14
class A {
15
public:
16
   virtual ~A() { }
17
};
18
 
19
class B : public A {
20
public:
21
   virtual ~B() { if (x == 1) abort (); x = 1; }
22
};
23
 
24
void __attribute__((noinline,noclone)) foo (void *p)
25
{
26
 B *b = reinterpret_cast(p);
27
 b->~B();
28
 new (p) A;
29
}
30
 
31
int main()
32
{
33
 void *p = __builtin_malloc (sizeof (B));
34
 new (p) B;
35
 foo(p);
36
 reinterpret_cast(p)->~A();
37
 return 0;
38
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.