]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.compile/compile-cplus-nested.cc
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.compile / compile-cplus-nested.cc
1 /* Copyright 2015-2021 Free Software Foundation, Inc.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 3 of the License, or
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15
16 class A
17 {
18 public:
19 A () : a_ (1) {}
20 int get ();
21
22 protected:
23 int a_;
24
25 private:
26 /* It is important to not /not/ use the nested class definition in A.
27 This exercises a different path through the code. */
28 struct Inner1
29 {
30 int a_;
31 Inner1 () : a_ (2) {}
32
33 struct Inner2
34 {
35 int a_;
36 Inner2 () : a_ (3) {}
37 };
38 };
39 };
40
41 int
42 A::get ()
43 {
44 A::Inner1 i1;
45 A::Inner1::Inner2 i2;
46
47 return i1.a_ + i2.a_; // break here
48 }
49
50 int var = 1234;
51
52 int
53 main ()
54 {
55 A a;
56
57 return a.get ();
58 }