OSDN Git Service

PR c++/46124
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / torture / pr45580.C
1 // { dg-do compile }
2
3 namespace std {
4     typedef __SIZE_TYPE__ size_t;
5 }
6 inline void* operator new(std::size_t, void* __p) throw() {
7     return __p;
8 }
9 class Noncopyable  { };
10 struct CollectorCell { };
11 template<typename T> class PassRefPtr {
12 public:
13     T* releaseRef() const { }
14 };
15 template <typename T> class NonNullPassRefPtr {
16 public:
17     template <class U> NonNullPassRefPtr(const PassRefPtr<U>& o)
18         : m_ptr(o.releaseRef()) { }
19     mutable T* m_ptr;
20 };
21 struct ClassInfo;
22 class JSValue { };
23 JSValue jsNull();
24 class Structure;
25 class JSGlobalData {
26     static void storeVPtrs();
27 };
28 class JSCell : public Noncopyable {
29     friend class JSObject;
30     friend class JSGlobalData;
31     virtual ~JSCell();
32 };
33 class JSObject : public JSCell {
34 public:
35     explicit JSObject(NonNullPassRefPtr<Structure>);
36     static PassRefPtr<Structure> createStructure(JSValue prototype) { }
37 };
38 class JSByteArray : public JSObject {
39     friend class JSGlobalData;
40     enum VPtrStealingHackType { VPtrStealingHack };
41     JSByteArray(VPtrStealingHackType)
42         : JSObject(createStructure(jsNull())), m_classInfo(0) { }
43     const ClassInfo* m_classInfo;
44 };
45 void JSGlobalData::storeVPtrs() {
46     CollectorCell cell;
47     void* storage = &cell;
48     JSCell* jsByteArray = new (storage) JSByteArray(JSByteArray::VPtrStealingHack);
49     jsByteArray->~JSCell();
50 }