Commit | Line | Data |
---|---|---|
858be34c PA |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
e2882c85 | 3 | Copyright 2002-2018 Free Software Foundation, Inc. |
858be34c PA |
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 | struct aggregate | |
19 | { | |
20 | int i1; | |
21 | int i2; | |
22 | int i3; | |
23 | }; | |
24 | ||
25 | void keepalive_float (double *var) { } | |
26 | void keepalive_int (int *var) { } | |
27 | void keepalive_aggregate (struct aggregate *var) { } | |
28 | ||
29 | #define PREFIXIFY(PREFIX, VAR) \ | |
30 | PREFIX ## _ ## VAR | |
31 | ||
32 | #define DEF_STATICS(PREFIX) \ | |
33 | static int PREFIXIFY(PREFIX, s_var_int) = 4; \ | |
34 | static double PREFIXIFY(PREFIX, s_var_float) = 3.14f; \ | |
35 | static struct aggregate PREFIXIFY(PREFIX, s_var_aggregate) \ | |
36 | = { 1, 2, 3 }; \ | |
37 | \ | |
38 | keepalive_int (&PREFIXIFY(PREFIX, s_var_int)); \ | |
39 | keepalive_float (&PREFIXIFY(PREFIX, s_var_float)); \ | |
40 | keepalive_aggregate (&PREFIXIFY(PREFIX, s_var_aggregate)); | |
41 | ||
42 | #ifdef __cplusplus | |
43 | ||
44 | struct S | |
45 | { | |
46 | void inline_method () | |
47 | { | |
48 | DEF_STATICS (S_IM); | |
49 | } | |
50 | static void static_inline_method () | |
51 | { | |
52 | DEF_STATICS (S_SIM); | |
53 | } | |
54 | ||
55 | void method (); | |
3693fdb3 PA |
56 | void method () const; |
57 | void method () volatile; | |
58 | void method () volatile const; | |
59 | ||
858be34c PA |
60 | static void static_method (); |
61 | }; | |
62 | ||
63 | S s; | |
3693fdb3 PA |
64 | const S c_s = {}; |
65 | volatile S v_s = {}; | |
66 | const volatile S cv_s = {}; | |
858be34c PA |
67 | |
68 | void | |
69 | S::method () | |
70 | { | |
71 | DEF_STATICS (S_M); | |
72 | } | |
73 | ||
3693fdb3 PA |
74 | void |
75 | S::method () const | |
76 | { | |
77 | DEF_STATICS (S_M_C); | |
78 | } | |
79 | ||
80 | void | |
81 | S::method () volatile | |
82 | { | |
83 | DEF_STATICS (S_M_V); | |
84 | } | |
85 | ||
86 | void | |
87 | S::method () const volatile | |
88 | { | |
89 | DEF_STATICS (S_M_CV); | |
90 | } | |
91 | ||
858be34c PA |
92 | void |
93 | S::static_method () | |
94 | { | |
95 | DEF_STATICS (S_SM); | |
96 | } | |
97 | ||
98 | template <typename T> | |
99 | struct S2 | |
100 | { | |
101 | void method (); | |
102 | static void static_method (); | |
103 | ||
104 | void inline_method () | |
105 | { | |
106 | DEF_STATICS (S2_IM); | |
107 | } | |
108 | ||
109 | static void static_inline_method () | |
110 | { | |
111 | DEF_STATICS (S2_SIM); | |
112 | } | |
113 | }; | |
114 | ||
115 | template<typename T> | |
116 | void | |
117 | S2<T>::method () | |
118 | { | |
119 | DEF_STATICS (S2_M); | |
120 | } | |
121 | ||
122 | template<typename T> | |
123 | void | |
124 | S2<T>::static_method () | |
125 | { | |
126 | DEF_STATICS (S2_SM); | |
127 | } | |
128 | ||
129 | S2<int> s2; | |
130 | ||
131 | #endif | |
132 | ||
133 | void | |
134 | free_func (void) | |
135 | { | |
136 | DEF_STATICS (FF); | |
137 | } | |
138 | ||
139 | static inline void | |
140 | free_inline_func (void) | |
141 | { | |
142 | DEF_STATICS (FIF); | |
143 | } | |
144 | ||
145 | int | |
146 | main () | |
147 | { | |
148 | for (int i = 0; i < 1000; i++) | |
149 | { | |
150 | free_func (); | |
151 | free_inline_func (); | |
152 | ||
153 | #ifdef __cplusplus | |
154 | s.method (); | |
3693fdb3 PA |
155 | c_s.method (); |
156 | v_s.method (); | |
157 | cv_s.method (); | |
858be34c PA |
158 | s.inline_method (); |
159 | S::static_method (); | |
160 | S::static_inline_method (); | |
161 | ||
162 | s2.method (); | |
163 | s2.inline_method (); | |
164 | S2<int>::static_method (); | |
165 | S2<int>::static_inline_method (); | |
166 | #endif | |
167 | } | |
168 | ||
169 | return 0; | |
170 | } |