FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / mutable1.C
blob3fd0c3e6b7cd0a99461d27b0216413d71501c000
1 // Copyright (C) 1999 Free Software Foundation, Inc.
2 // Contributed by Nathan Sidwell 14 Jan 1999 <nathan@acm.org>
4 // Make sure objects with mutable members are never placed in a read only
5 // section.
7 // All these are POD structs, and hence do not need ctors
8 struct A { mutable int i; };
9 struct B { A a; };
10 struct C { A a[1]; };
11 struct D { static A const a; };
13 // all these are static consts and hence naively suitable for a read only
14 // section. But they contain a mutable, so must be in a writable section.
15 static int const i = 0;
16 static A const a = {0};
17 static B const b = {{0}};
18 static C const c = {{{0}}};
19 static A const aa[] = {{0}};
20 static B const bb[] = {{{0}}};
21 static C const cc[] = {{{{0}}}};
22 A const D::a = {0};
24 int main()
26   a.i = 05;
27   b.a.i = 05;
28   c.a[0].i = 05;
29   aa[0].i = 05;
30   bb[0].a.i = 05;
31   cc[0].a[0].i = 05;
32   D::a.i = 05;
33   
34   if(!a.i) return 1;
35   if(!b.a.i) return 1;
36   if(!c.a[0].i) return 1;
37   if(!aa[0].i) return 1;
38   if(!bb[0].a.i) return 1;
39   if(!cc[0].a[0].i) return 1;
40   if(!D::a.i) return 1;
42   return 0;