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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.pt/] [auto_ptr.C] - Blame information for rev 699

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 jeremybenn
// { dg-do assemble  }
2
template  struct auto_ptr_ref {
3
  Y* py;
4
  auto_ptr_ref(Y* p) : py(p) {}
5
};
6
template struct auto_ptr {
7
   X* px;
8
 public:
9
   typedef X element_type;
10
 
11
   explicit auto_ptr(X* p =0) throw() : px(p) {}
12
   auto_ptr(auto_ptr& r) throw() : px(r.release()) {} // { dg-message "note" } candidate
13
   template
14
      auto_ptr(auto_ptr& r) throw() : px(r.release()) {}// { dg-message "note" } candidate
15
 
16
   auto_ptr& operator=(auto_ptr& r) throw() {
17
      reset(r.release());
18
      return *this;
19
   }
20
   template auto_ptr& operator=(auto_ptr& r) throw() {
21
      reset(r.release());
22
      return *this;
23
   }
24
 
25
   ~auto_ptr() { delete px; }
26
 
27
   X& operator*() const throw() { return *px; }
28
   X* operator->() const throw() { return px; }
29
   X* get() const throw() { return px; }
30
   X* release() throw() { X* p=px; px=0; return p; }
31
   void reset(X* p=0) throw() { if (px != p) delete px, px = p; }
32
 
33
   auto_ptr(auto_ptr_ref r) throw() : px(r.py) {} // { dg-message "note" }
34
   template operator auto_ptr_ref() throw() {
35
      return auto_ptr_ref(release());
36
   }
37
   template operator auto_ptr() throw() {
38
      return auto_ptr(release());
39
   }
40
};
41
 
42
struct Base { Base() {} virtual ~Base() {} };
43
struct Derived : Base { Derived() {} };
44
 
45
auto_ptr f() { auto_ptr null(0); return null; }
46
void g(auto_ptr) { }
47
void h(auto_ptr) { }    // { dg-error "initializing" }
48
 
49
int main() {
50
    auto_ptr x(f());
51
    auto_ptr y(f());
52
    x = y;
53
    g(f());
54
    h(f());                     // { dg-error "match" "match" } no usable copy ctor
55
    // { dg-message "candidate" "candidate note" { target *-*-* } 54 }
56
}

powered by: WebSVN 2.1.0

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