xref: /openbsd-src/gnu/lib/libstdc++/libstdc++/testsuite/20_util/auto_ptr_neg.cc (revision 03a78d155d6fff5698289342b62759a75b20d130)
1*03a78d15Sespie // Copyright (C) 2002 Free Software Foundation
2*03a78d15Sespie //
3*03a78d15Sespie // This file is part of the GNU ISO C++ Library.  This library is free
4*03a78d15Sespie // software; you can redistribute it and/or modify it under the
5*03a78d15Sespie // terms of the GNU General Public License as published by the
6*03a78d15Sespie // Free Software Foundation; either version 2, or (at your option)
7*03a78d15Sespie // any later version.
8*03a78d15Sespie 
9*03a78d15Sespie // This library is distributed in the hope that it will be useful,
10*03a78d15Sespie // but WITHOUT ANY WARRANTY; without even the implied warranty of
11*03a78d15Sespie // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12*03a78d15Sespie // GNU General Public License for more details.
13*03a78d15Sespie 
14*03a78d15Sespie // You should have received a copy of the GNU General Public License along
15*03a78d15Sespie // with this library; see the file COPYING.  If not, write to the Free
16*03a78d15Sespie // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17*03a78d15Sespie // USA.
18*03a78d15Sespie 
19*03a78d15Sespie // 20.4.5 Template class auto_ptr negative tests [lib.auto.ptr]
20*03a78d15Sespie 
21*03a78d15Sespie #include <memory>
22*03a78d15Sespie #include <testsuite_hooks.h>
23*03a78d15Sespie 
24*03a78d15Sespie // { dg-do compile }
25*03a78d15Sespie // { dg-excess-errors "" }
26*03a78d15Sespie 
27*03a78d15Sespie // via Jack Reeves <jack_reeves@hispeed.ch>
28*03a78d15Sespie // libstdc++/3946
29*03a78d15Sespie // http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html
30*03a78d15Sespie struct Base { };
31*03a78d15Sespie struct Derived : public Base { };
32*03a78d15Sespie 
33*03a78d15Sespie std::auto_ptr<Derived>
foo()34*03a78d15Sespie foo() { return std::auto_ptr<Derived>(new Derived); }
35*03a78d15Sespie 
36*03a78d15Sespie int
test01()37*03a78d15Sespie test01()
38*03a78d15Sespie {
39*03a78d15Sespie   std::auto_ptr<Base> ptr2;
40*03a78d15Sespie   ptr2 = new Base; // { dg-error "no" "candidates" "auto_ptr"}
41*03a78d15Sespie   return 0;
42*03a78d15Sespie }
43*03a78d15Sespie 
44*03a78d15Sespie int
main()45*03a78d15Sespie main()
46*03a78d15Sespie {
47*03a78d15Sespie   test01();
48*03a78d15Sespie 
49*03a78d15Sespie   return 0;
50*03a78d15Sespie }
51