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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [opt/] [const1.C] - Blame information for rev 751

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// This testcase was miscompiled on IA-64 to read from unitialized memory
2
// and dereference it.
3
// { dg-do run }
4
// { dg-options "-O2" }
5
 
6
struct A
7
{
8
  A () { a = 1; }
9
  void a1 () { a++; }
10
  bool a2 () { return !--a; }
11
  unsigned int a;
12
};
13
 
14
struct B {};
15
 
16
template  struct C
17
{
18
  C () {}
19
  C (const T& t) : c (t) {}
20
  C *next, *prev;
21
  T c;
22
};
23
 
24
template  struct D
25
{
26
  C *d;
27
  D () : d (0) {}
28
  D (C *x) : d (x) {}
29
  D (const D& x) : d (x.d) {}
30
  bool operator!= (const D& x) const { return d != x.d; }
31
  const T& operator* () const { return d->c; }
32
  D operator++ (int) { D t = *this; d = d->next; return t; }
33
};
34
 
35
template  struct E
36
{
37
  C *e;
38
  E () : e (0) {}
39
  E (C *p) : e (p) {}
40
  E (const E& x) : e (x.e) {}
41
  E (const D& x) : e (x.e) {}
42
  bool operator!= (const E& x) const { return e != x.e; }
43
  const T& operator* () const { return e->c; }
44
  E& operator++ () { e = e->next; return *this; }
45
};
46
 
47
template  struct F : public A
48
{
49
  C *f;
50
  unsigned long f0;
51
  F () { f = new C; f->next = f->prev = f; f0 = 0; }
52
  F (const F& x) : A ()
53
  {
54
    f = new C; f->next = f->prev = f; f0 = 0;
55
    D b (x.f->next), e (x.f), i (f);
56
    while (b != e)
57
      f1 (i, *b++);
58
  }
59
 
60
  ~F ()
61
  {
62
    C *p = f->next;
63
    while (p != f)
64
      {
65
        C *x = p->next;
66
        delete p;
67
        p = x;
68
      }
69
    delete f;
70
  }
71
 
72
  D f1 (D x, const T& y)
73
  {
74
    C *p = new C (y);
75
    p->next = x.d;
76
    p->prev = x.d->prev;
77
    x.d->prev->next = p;
78
    x.d->prev = p;
79
    f0++;
80
    return p;
81
  }
82
};
83
 
84
template  struct G
85
{
86
  F *g;
87
  G () { g = new F; }
88
  G (const G& x) { g = x.g; g->a1 (); }
89
  ~G () {}
90
  G& operator= (const G& x) { x.g->a1 (); g = x.g; return *this; }
91
  D g1 () { g4 (); return D (g->f); }
92
  E g1 () const { return E (g->f); }
93
  E g2 () const { return E (g->f->next); }
94
  D g3 (const T& x) { g4 (); return g->f1 (g1 (), x); }
95
  void g4 () { if (g->a > 1) { g->a2 (); g = new F (*g); } }
96
 
97
  G operator+ (const G& x) const
98
  {
99
    G x2 (*this);
100
    for (E i = x.g2 (); i != x.g1 (); ++i)
101
      x2.g3 (*i);
102
    return x2;
103
  }
104
 
105
  G& operator+= (const G& x)
106
  {
107
    for (E i = x.g2 (); i != x.g1 (); ++i)
108
      g3 (*i);
109
    return *this;
110
  }
111
};
112
 
113
struct H : public G
114
{
115
  H () {}
116
  H (const H& x) : G (x) {}
117
  H (const G& x) : G (x) {}
118
};
119
 
120
void foo ();
121
 
122
int
123
main ()
124
{
125
  H a = H () + H ();
126
  a += H ();
127
  H b;
128
  b = H () + H ();
129
}

powered by: WebSVN 2.1.0

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