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