126a53354Schristos /* This testcase is part of GDB, the GNU debugger.
226a53354Schristos 
3*1424dfb3Schristos    Copyright 2014-2020 Free Software Foundation, Inc.
426a53354Schristos 
526a53354Schristos    This program is free software; you can redistribute it and/or modify
626a53354Schristos    it under the terms of the GNU General Public License as published by
726a53354Schristos    the Free Software Foundation; either version 3 of the License, or
826a53354Schristos    (at your option) any later version.
926a53354Schristos 
1026a53354Schristos    This program is distributed in the hope that it will be useful,
1126a53354Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
1226a53354Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1326a53354Schristos    GNU General Public License for more details.
1426a53354Schristos 
1526a53354Schristos    You should have received a copy of the GNU General Public License
1626a53354Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
1726a53354Schristos 
1826a53354Schristos class A
1926a53354Schristos {
2026a53354Schristos public:
A()2126a53354Schristos   A () {}
2226a53354Schristos   A (A &obj);
2326a53354Schristos 
2426a53354Schristos   int a;
2526a53354Schristos };
2626a53354Schristos 
A(A & obj)2726a53354Schristos A::A(A &obj)
2826a53354Schristos {
2926a53354Schristos   a = obj.a;
3026a53354Schristos }
3126a53354Schristos 
3226a53354Schristos A
f1(int i1,int i2)3326a53354Schristos f1 (int i1, int i2)
3426a53354Schristos {
3526a53354Schristos   A a;
3626a53354Schristos 
3726a53354Schristos   a.a = i1 + i2;
3826a53354Schristos 
3926a53354Schristos   return a;
4026a53354Schristos }
4126a53354Schristos 
4226a53354Schristos class B
4326a53354Schristos {
4426a53354Schristos public:
B()4526a53354Schristos   B () {}
4626a53354Schristos   B (const B &obj);
4726a53354Schristos 
4826a53354Schristos   int b;
4926a53354Schristos };
5026a53354Schristos 
B(const B & obj)5126a53354Schristos B::B(const B &obj)
5226a53354Schristos {
5326a53354Schristos   b = obj.b;
5426a53354Schristos }
5526a53354Schristos 
5626a53354Schristos B
f2(int i1,int i2)5726a53354Schristos f2 (int i1, int i2)
5826a53354Schristos {
5926a53354Schristos   B b;
6026a53354Schristos 
6126a53354Schristos   b.b = i1 + i2;
6226a53354Schristos 
6326a53354Schristos   return b;
6426a53354Schristos }
6526a53354Schristos 
6626a53354Schristos class B1
6726a53354Schristos {
6826a53354Schristos public:
B1()6926a53354Schristos   B1 () {}
7026a53354Schristos   /* This class exists to test that GDB does not trip on other
7126a53354Schristos      constructors (not copy constructors) which take one
7226a53354Schristos      argument.  Hence, put this decl before the copy-ctor decl.
7326a53354Schristos      If it is put after copy-ctor decl, then the decision to mark
7426a53354Schristos      this class as non-trivial will already be made and GDB will
7526a53354Schristos      not look at this constructor.  */
7626a53354Schristos   B1 (int i);
7726a53354Schristos   B1 (const B1 &obj);
7826a53354Schristos 
7926a53354Schristos   int b1;
8026a53354Schristos };
8126a53354Schristos 
B1(const B1 & obj)8226a53354Schristos B1::B1 (const B1 &obj)
8326a53354Schristos {
8426a53354Schristos   b1 = obj.b1;
8526a53354Schristos }
8626a53354Schristos 
B1(int i)8726a53354Schristos B1::B1 (int i) : b1 (i) { }
8826a53354Schristos 
8926a53354Schristos B1
f22(int i1,int i2)9026a53354Schristos f22 (int i1, int i2)
9126a53354Schristos {
9226a53354Schristos   B1 b1;
9326a53354Schristos 
9426a53354Schristos   b1.b1 = i1 + i2;
9526a53354Schristos 
9626a53354Schristos   return b1;
9726a53354Schristos }
9826a53354Schristos 
9926a53354Schristos class C
10026a53354Schristos {
10126a53354Schristos public:
10226a53354Schristos   virtual int method ();
10326a53354Schristos 
10426a53354Schristos   int c;
10526a53354Schristos };
10626a53354Schristos 
10726a53354Schristos int
method()10826a53354Schristos C::method ()
10926a53354Schristos {
11026a53354Schristos   return c;
11126a53354Schristos }
11226a53354Schristos 
11326a53354Schristos C
f3(int i1,int i2)11426a53354Schristos f3 (int i1, int i2)
11526a53354Schristos {
11626a53354Schristos   C c;
11726a53354Schristos 
11826a53354Schristos   c.c = i1 + i2;
11926a53354Schristos 
12026a53354Schristos   return c;
12126a53354Schristos }
12226a53354Schristos 
12326a53354Schristos class D
12426a53354Schristos {
12526a53354Schristos public:
12626a53354Schristos   int d;
12726a53354Schristos };
12826a53354Schristos 
12926a53354Schristos class E : public virtual D
13026a53354Schristos {
13126a53354Schristos public:
13226a53354Schristos   int e;
13326a53354Schristos };
13426a53354Schristos 
13526a53354Schristos E
f4(int i1,int i2)13626a53354Schristos f4 (int i1, int i2)
13726a53354Schristos {
13826a53354Schristos   E e;
13926a53354Schristos 
14026a53354Schristos   e.e = i1 + i2;
14126a53354Schristos 
14226a53354Schristos   return e;
14326a53354Schristos }
14426a53354Schristos 
14526a53354Schristos int
main(void)14626a53354Schristos main (void)
14726a53354Schristos {
14826a53354Schristos   int i1 = 23;
14926a53354Schristos   int i2 = 100;
15026a53354Schristos 
15126a53354Schristos   return 0;  /* Break here  */
15226a53354Schristos }
153