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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.dg/] [opt/] [nrv5.C] - Blame information for rev 853

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

Line No. Rev Author Line
1 149 jeremybenn
// PR c++/7279
2
// Test for the named return value optimization with inlining.
3
// Contributed by Jakub Jelinek .
4
// { dg-do run }
5
// { dg-options -O2 }
6
 
7
enum E { E0, E1, E2, E3 };
8
 
9
struct S
10
{
11
  E s0 : 2;
12
  bool s1 : 1, s2 : 1, s3 : 1, s4 : 1, s5 : 1, s6 : 1;
13
  S ();
14
  void foo (E x);
15
};
16
 
17
S::S() : s1 (true), s2 (false), s0 (E1), s3 (true), s4 (false),
18
         s5 (true), s6 (false) {}
19
void S::foo (E x) { this->s0 = x; }
20
 
21
inline S foo ()
22
{
23
  S s;
24
  s.foo (E0);
25
  return s;
26
}
27
 
28
inline S bar ()
29
{
30
  S s;
31
  s.foo (E2);
32
  return s;
33
}
34
 
35
void check (S &s, bool isfoo);
36
 
37
void test (bool isfoo)
38
{
39
  S a = isfoo ? foo () : bar ();
40
  check (a, isfoo);
41
}
42
 
43
extern "C" void abort ();
44
 
45
void check (S &s, bool isfoo)
46
{
47
  if (! s.s1 || s.s2 || ! s.s3 || s.s4 || ! s.s5 || s.s6)
48
    abort ();
49
  if (s.s0 != (isfoo ? E0 : E2))
50
    abort ();
51
}
52
 
53
int main ()
54
{
55
  test (true);
56
  test (false);
57
}

powered by: WebSVN 2.1.0

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