Commit | Line | Data |
---|---|---|
7b282c5a SCR |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
3666a048 | 3 | Copyright 2012-2021 Free Software Foundation, Inc. |
7b282c5a SCR |
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 { | |
f7bd0f78 SC |
19 | public: |
20 | int operator+ (const int a1); | |
21 | ||
a16b0e22 SC |
22 | public: |
23 | int a; | |
7b282c5a SCR |
24 | }; |
25 | ||
f7bd0f78 SC |
26 | int |
27 | A::operator+ (const int a1) | |
28 | { | |
29 | return a + a1; | |
30 | } | |
31 | ||
a16b0e22 SC |
32 | union U { |
33 | int a; | |
34 | char c; | |
35 | }; | |
36 | ||
37 | class B : public A { | |
38 | public: | |
39 | char a; | |
40 | }; | |
41 | ||
b5b08fb4 SC |
42 | struct X |
43 | { | |
44 | union { int x; char y; }; | |
45 | union { int a; char b; }; | |
46 | }; | |
47 | ||
48 | union UU | |
49 | { | |
50 | union { int x; char y; }; | |
51 | union { int a; char b; }; | |
52 | }; | |
53 | ||
a16b0e22 | 54 | typedef B Btd; |
7b282c5a | 55 | typedef int *int_ptr; |
b5b08fb4 | 56 | typedef X Xtd; |
7b282c5a SCR |
57 | |
58 | int | |
59 | func (const A &a) | |
60 | { | |
61 | int val = 10; | |
62 | int &int_ref = val; | |
63 | int_ptr ptr = &val; | |
64 | int_ptr &int_ptr_ref = ptr; | |
65 | ||
a16b0e22 SC |
66 | B b; |
67 | B b1; | |
68 | ||
69 | b.a = 'a'; | |
70 | b.A::a = 10; | |
71 | ||
72 | B *b_obj = &b1; | |
73 | b_obj->a = 'b'; | |
74 | b_obj->A::a = 100; | |
75 | ||
76 | B &b_ref = b1; | |
77 | Btd &b_td = b1; | |
78 | ||
79 | U u; | |
80 | u.a = 99; | |
81 | ||
b5b08fb4 SC |
82 | X x; |
83 | x.x = 101; | |
84 | x.a = 102; | |
85 | ||
86 | UU uu; | |
87 | uu.x = 1000; | |
88 | ||
89 | X *x_ptr = &x; | |
90 | Xtd *xtd = &x; | |
91 | ||
7b282c5a SCR |
92 | return 0; /* Break here. */ |
93 | } | |
94 | ||
95 | int | |
96 | main () | |
97 | { | |
98 | A obj; | |
a16b0e22 | 99 | |
f7bd0f78 SC |
100 | obj.a = 5; |
101 | ||
7b282c5a SCR |
102 | return func (obj); |
103 | } |