From: Jason Merrill Date: Sun, 24 May 1998 14:00:07 +0000 (-0400) Subject: new X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=60f06d2f91a13bec192a76b6665dc441692bf924;p=gcc.git new From-SVN: r20021 --- diff --git a/gcc/testsuite/g++.old-deja/g++.other/delete1.C b/gcc/testsuite/g++.old-deja/g++.other/delete1.C new file mode 100644 index 00000000000..6386fe1883b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/delete1.C @@ -0,0 +1,15 @@ +//Build don't link: +struct cl_heap_ring{ + void operator delete (void* ptr) { } + cl_heap_ring () + { } +}; + +struct cl_heap_null_ring : public cl_heap_ring { + void operator delete (void* ptr) { } +}; + +void f() +{ + new cl_heap_null_ring(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/virtual1.C b/gcc/testsuite/g++.old-deja/g++.other/virtual1.C new file mode 100644 index 00000000000..28483177bf9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/virtual1.C @@ -0,0 +1,13 @@ +// Build don't link: + +struct S0 { virtual void f1 () { } }; + +struct S1 : virtual public S0 { virtual void f1 () { } }; + +struct S2 : public S1 { virtual void f1 () { } }; + +struct S3 : virtual public S0 { virtual void f1 () { } }; + +struct S4 : public S3 { }; + +void creator () { new S4; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/auto_ptr.C b/gcc/testsuite/g++.old-deja/g++.pt/auto_ptr.C new file mode 100644 index 00000000000..dd5b988b316 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/auto_ptr.C @@ -0,0 +1,54 @@ +template struct auto_ptr_ref { + Y* py; + auto_ptr_ref(Y* p) : py(p) {} +}; +template struct auto_ptr { + X* px; + public: + typedef X element_type; + + explicit auto_ptr(X* p =0) throw() : px(p) {} + auto_ptr(auto_ptr& r) throw() : px(r.release()) {} + template + auto_ptr(auto_ptr& r) throw() : px(r.release()) {} + + auto_ptr& operator=(auto_ptr& r) throw() { + reset(r.release()); + return *this; + } + template auto_ptr& operator=(auto_ptr& r) throw() { + reset(r.release()); + return *this; + } + + ~auto_ptr() { delete px; } + + X& operator*() const throw() { return *px; } + X* operator->() const throw() { return px; } + X* get() const throw() { return px; } + X* release() throw() { X* p=px; px=0; return p; } + void reset(X* p=0) throw() { if (px != p) delete px, px = p; } + + auto_ptr(auto_ptr_ref r) throw() : px(r.py) {} + template operator auto_ptr_ref() throw() { + return auto_ptr_ref(release()); + } + template operator auto_ptr() throw() { + return auto_ptr(release()); + } +}; + +struct Base { Base() {} virtual ~Base() {} }; +struct Derived : Base { Derived() {}; }; + +auto_ptr f() { auto_ptr null(0); return null; } +void g(auto_ptr) { } +void h(auto_ptr) { } + +int main() { + auto_ptr x(f()); + auto_ptr y(f()); + x = y; + g(f()); + h(f()); +}