1 // { dg-do run  }
2 // { dg-options "-O2" }
3 //
4 // Copyright (C) 2001 Free Software Foundation, Inc.
5 // Contributed by Nathan Sidwell 18 May 2001 <nathan@codesourcery.com>
6 
7 // Bug 2781. We forgot to copy addressability information when
8 // cloning.
9 
10 struct B
11 {
12   B(int v1);
13   void Member (int v1);
14   static void Static (int v1);
15 };
16 
17 struct D : B
18 {
19   D (int v1);
20 };
21 
22 void xswap(int& x1) ;
23 
24 int xxx = 0;
25 
B(int v1)26 B::B(int v1)
27 {
28   xswap(v1);
29   xxx = v1;
30 }
31 
Member(int v1)32 void B::Member(int v1)
33 {
34   xswap(v1);
35   xxx = v1;
36 }
37 
Static(int v1)38 void B::Static(int v1)
39 {
40   xswap(v1);
41   xxx = v1;
42 }
43 
D(int v1)44 D::D(int v1)
45   : B (v1)
46 {
47 }
48 
xswap(int & x1)49 void xswap (int& x1) { x1 = 2; }
50 
main()51 int main ()
52 {
53   B p (1);
54 
55   if (xxx != 2)
56     return 1;
57 
58   D q (1);
59   if (xxx != 2)
60     return 2;
61 
62   p.Member (1);
63   if (xxx != 2)
64     return 3;
65 
66   p.Static (1);
67   if (xxx != 2)
68     return 4;
69 
70   return 0;
71 }
72