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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 jeremybenn
// { dg-do run  }
2
// Copyright (C) 1999 Free Software Foundation, Inc.
3
// Contributed by Nathan Sidwell 14 Jan 1999 
4
 
5
// Make sure objects with mutable members are never placed in a read only
6
// section.
7
 
8
// All these are POD structs, and hence do not need ctors
9
struct A { mutable int i; };
10
struct B { A a; };
11
struct C { A a[1]; };
12
struct D { static A const a; };
13
 
14
// all these are static consts and hence naively suitable for a read only
15
// section. But they contain a mutable, so must be in a writable section.
16
static int const i = 0;
17
static A const a = {0};
18
static B const b = {{0}};
19
static C const c = {{{0}}};
20
static A const aa[] = {{0}};
21
static B const bb[] = {{{0}}};
22
static C const cc[] = {{{{0}}}};
23
A const D::a = {0};
24
 
25
int main()
26
{
27
  a.i = 05;
28
  b.a.i = 05;
29
  c.a[0].i = 05;
30
  aa[0].i = 05;
31
  bb[0].a.i = 05;
32
  cc[0].a[0].i = 05;
33
  D::a.i = 05;
34
 
35
  if(!a.i) return 1;
36
  if(!b.a.i) return 1;
37
  if(!c.a[0].i) return 1;
38
  if(!aa[0].i) return 1;
39
  if(!bb[0].a.i) return 1;
40
  if(!cc[0].a[0].i) return 1;
41
  if(!D::a.i) return 1;
42
 
43
  return 0;
44
}

powered by: WebSVN 2.1.0

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