Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / non-trivial-retval.cc
CommitLineData
778811d5
SC
1/* This testcase is part of GDB, the GNU debugger.
2
88b9d363 3 Copyright 2014-2022 Free Software Foundation, Inc.
778811d5
SC
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
18class A
19{
20public:
21 A () {}
22 A (A &obj);
23
24 int a;
25};
26
27A::A(A &obj)
28{
29 a = obj.a;
30}
31
32A
33f1 (int i1, int i2)
34{
35 A a;
36
37 a.a = i1 + i2;
38
39 return a;
40}
41
42class B
43{
44public:
45 B () {}
46 B (const B &obj);
47
48 int b;
49};
50
51B::B(const B &obj)
52{
53 b = obj.b;
54}
55
56B
57f2 (int i1, int i2)
58{
59 B b;
60
61 b.b = i1 + i2;
62
63 return b;
64}
65
3433cfa5
SC
66class B1
67{
68public:
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
82B1::B1 (const B1 &obj)
83{
84 b1 = obj.b1;
85}
86
87B1::B1 (int i) : b1 (i) { }
88
89B1
90f22 (int i1, int i2)
91{
92 B1 b1;
93
94 b1.b1 = i1 + i2;
95
96 return b1;
97}
98
2d1c107c
SC
99class C
100{
101public:
102 virtual int method ();
103
104 int c;
105};
106
107int
108C::method ()
109{
110 return c;
111}
112
113C
114f3 (int i1, int i2)
115{
116 C c;
117
118 c.c = i1 + i2;
119
120 return c;
121}
122
123class D
124{
125public:
126 int d;
127};
128
129class E : public virtual D
130{
131public:
132 int e;
133};
134
135E
136f4 (int i1, int i2)
137{
138 E e;
139
140 e.e = i1 + i2;
141
142 return e;
143}
144
778811d5
SC
145int
146main (void)
147{
148 int i1 = 23;
149 int i2 = 100;
150
151 return 0; /* Break here */
152}
This page took 0.820616 seconds and 4 git commands to generate.