]>
Commit | Line | Data |
---|---|---|
5384b728 | 1 | 2002-07-11 Jakub Jelinek <jakub@redhat.com> |
2 | ||
3 | * g++.dg/opt/nrv5.C: New test. | |
4 | ||
5 | 2002-07-05 Jason Merrill <jason@redhat.com> | |
6 | ||
7 | * g++.dg/opt/nrv4.C: New test. | |
8 | ||
9 | 2002-04-09 Jason Merrill <jason@redhat.com> | |
10 | ||
11 | * g++.dg/opt/nrv3.C: New test. | |
12 | ||
13 | --- gcc/testsuite/g++.dg/opt/nrv3.C.jj Thu Apr 11 16:25:15 2002 | |
14 | +++ gcc/testsuite/g++.dg/opt/nrv3.C Tue Apr 9 19:02:43 2002 | |
15 | @@ -0,0 +1,24 @@ | |
16 | +// PR optimization/6189 | |
17 | +// Bug: we forgot about foo's nrv after writing it out. | |
18 | +// { dg-options -O3 } | |
19 | +// { dg-do run } | |
20 | + | |
21 | +struct A | |
22 | +{ | |
23 | + int i; | |
24 | +}; | |
25 | + | |
26 | + | |
27 | +A foo () | |
28 | +{ | |
29 | + A a; | |
30 | + a.i = 42; | |
31 | + return a; | |
32 | +} | |
33 | + | |
34 | + | |
35 | +int main() | |
36 | +{ | |
37 | + A b = foo(); | |
38 | + return b.i != 42; | |
39 | +} | |
40 | --- gcc/testsuite/g++.dg/opt/nrv4.C.jj Thu Apr 11 16:25:15 2002 | |
41 | +++ gcc/testsuite/g++.dg/opt/nrv4.C Fri Jul 5 17:16:56 2002 | |
42 | @@ -0,0 +1,23 @@ | |
43 | +// PR optimization/7145 | |
44 | +// Bug: The NRV optimization caused us to lose the initializer for 'ret'. | |
45 | +// { dg-options -O } | |
46 | +// { dg-do run } | |
47 | + | |
48 | +struct GdkColor { | |
49 | + long pixel; | |
50 | + short red; | |
51 | + short green; | |
52 | + short blue; | |
53 | +}; | |
54 | + | |
55 | +inline GdkColor mkcolor() { | |
56 | + GdkColor ret={0,1,2,3}; | |
57 | + return ret; | |
58 | +} | |
59 | + | |
60 | +int | |
61 | +main() | |
62 | +{ | |
63 | + GdkColor col=mkcolor(); | |
64 | + return (col.pixel != 0 || col.red != 1 || col.green != 2 || col.blue != 3); | |
65 | +} | |
66 | --- gcc/testsuite/g++.dg/opt/nrv5.C.jj Thu Apr 11 16:25:15 2002 | |
67 | +++ gcc/testsuite/g++.dg/opt/nrv5.C Thu Jul 11 11:29:33 2002 | |
68 | @@ -0,0 +1,52 @@ | |
69 | +// Test for the named return value optimization with inlining. | |
70 | +// Contributed by Jakub Jelinek <jakub@redhat.com>. | |
71 | +// { dg-do run } | |
72 | +// { dg-options -O2 } | |
73 | + | |
74 | +enum E { E0, E1, E2, E3 }; | |
75 | + | |
76 | +struct S | |
77 | +{ | |
78 | + E s0 : 2; | |
79 | + bool s1 : 1, s2 : 1, s3 : 1, s4 : 1, s5 : 1, s6 : 1; | |
80 | + S () : s1 (true), s2 (false), s0 (E1), s3 (true), s4 (false), s5 (true), s6 (false) {} | |
81 | + void foo (E x) { this->s0 = x; } | |
82 | +}; | |
83 | + | |
84 | +inline S foo () | |
85 | +{ | |
86 | + S s; | |
87 | + s.foo (E0); | |
88 | + return s; | |
89 | +} | |
90 | + | |
91 | +inline S bar () | |
92 | +{ | |
93 | + S s; | |
94 | + s.foo (E2); | |
95 | + return s; | |
96 | +} | |
97 | + | |
98 | +void check (S &s, bool isfoo); | |
99 | + | |
100 | +void test (bool isfoo) | |
101 | +{ | |
102 | + S a = isfoo ? foo () : bar (); | |
103 | + check (a, isfoo); | |
104 | +} | |
105 | + | |
106 | +extern "C" void abort (); | |
107 | + | |
108 | +void check (S &s, bool isfoo) | |
109 | +{ | |
110 | + if (! s.s1 || s.s2 || ! s.s3 || s.s4 || ! s.s5 || s.s6) | |
111 | + abort (); | |
112 | + if (s.s0 != (isfoo ? E0 : E2)) | |
113 | + abort (); | |
114 | +} | |
115 | + | |
116 | +int main () | |
117 | +{ | |
118 | + test (true); | |
119 | + test (false); | |
120 | +} |