Update copyright year range in all GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / non-trivial-retval.cc
1 /* This testcase is part of GDB, the GNU debugger.
2
3 Copyright 2014-2020 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18 class A
19 {
20 public:
21 A () {}
22 A (A &obj);
23
24 int a;
25 };
26
27 A::A(A &obj)
28 {
29 a = obj.a;
30 }
31
32 A
33 f1 (int i1, int i2)
34 {
35 A a;
36
37 a.a = i1 + i2;
38
39 return a;
40 }
41
42 class B
43 {
44 public:
45 B () {}
46 B (const B &obj);
47
48 int b;
49 };
50
51 B::B(const B &obj)
52 {
53 b = obj.b;
54 }
55
56 B
57 f2 (int i1, int i2)
58 {
59 B b;
60
61 b.b = i1 + i2;
62
63 return b;
64 }
65
66 class B1
67 {
68 public:
69 B1 () {}
70 /* This class exists to test that GDB does not trip on other
71 constructors (not copy constructors) which take one
72 argument. Hence, put this decl before the copy-ctor decl.
73 If it is put after copy-ctor decl, then the decision to mark
74 this class as non-trivial will already be made and GDB will
75 not look at this constructor. */
76 B1 (int i);
77 B1 (const B1 &obj);
78
79 int b1;
80 };
81
82 B1::B1 (const B1 &obj)
83 {
84 b1 = obj.b1;
85 }
86
87 B1::B1 (int i) : b1 (i) { }
88
89 B1
90 f22 (int i1, int i2)
91 {
92 B1 b1;
93
94 b1.b1 = i1 + i2;
95
96 return b1;
97 }
98
99 class C
100 {
101 public:
102 virtual int method ();
103
104 int c;
105 };
106
107 int
108 C::method ()
109 {
110 return c;
111 }
112
113 C
114 f3 (int i1, int i2)
115 {
116 C c;
117
118 c.c = i1 + i2;
119
120 return c;
121 }
122
123 class D
124 {
125 public:
126 int d;
127 };
128
129 class E : public virtual D
130 {
131 public:
132 int e;
133 };
134
135 E
136 f4 (int i1, int i2)
137 {
138 E e;
139
140 e.e = i1 + i2;
141
142 return e;
143 }
144
145 int
146 main (void)
147 {
148 int i1 = 23;
149 int i2 = 100;
150
151 return 0; /* Break here */
152 }
This page took 0.049802 seconds and 4 git commands to generate.