2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / other / copy1.C
blobd02b08fce092888ed45a18a68b44ff728b0afb2c
1 // { dg-do run }
3 // Copyright (C) 2000 Free Software Foundation, Inc.
4 // Contributed by Nathan Sidwell 30 Nov 2001 <nathan@nathan@codesourcery.com>
6 // PR 87
8 int assign = 0;
9 int ctor = 0;
10 int assignC = 0;
12 struct A {
13   int i;
15   template<class T>
16   void operator=(const T&) const
17   { 
18     assign = 1;
19   }
21   A () : i (0) {}
22   
23   template <typename T> A (const T &)
24   {
25     ctor = 1;
26   }
29 struct B : A 
33 struct C 
35   int i;
37   C (int i_) :i (i_) {}
38   
39   template <int I>
40   void operator= (const C &)
41   {
42     assignC = 1;
43   }
47 int main()
49   const A a;
50   A b;
51   B c;
53   b = a;
54   if (assign)
55     return 5;
56   
57   b.i = 100;
58   c.i = 200;
59   
60   a = b; 
62   if (!assign)
63     return 1;
64   if (a.i)
65     return 2;
67   A e (b);
68   if (ctor)
69     return 3;
70   
71   A d (c);
72   if (!ctor)
73     return 4;
75   C c0 (0);
76   C c1 (1);
78   c0 = c1;
79   if (assignC)
80     return 5;
81   
82   return 0;