Fix: Null pointer dereference in ldlex.l
[binutils-gdb.git] / gdb / testsuite / gdb.base / store.c
blob545515dfc1030d071115e65a15c0e55ffacedc40
1 /* Check that GDB can correctly update a value, living in a register,
2 in the target. This pretty much relies on the compiler taking heed
3 of requests for values to be stored in registers. */
5 /* NOTE: carlton/2002-12-05: These functions were all static, but for
6 whatever reason that caused GCC 3.1 to optimize away some of the
7 function calls within main even when no optimization flags were
8 passed. */
10 typedef signed char charest;
12 charest
13 add_charest (register charest u, register charest v)
15 return u + v;
18 short
19 add_short (register short u, register short v)
21 return u + v;
24 int
25 add_int (register int u, register int v)
27 return u + v;
30 long
31 add_long (register long u, register long v)
33 return u + v;
36 typedef long long longest;
38 longest
39 add_longest (register longest u, register longest v)
41 return u + v;
44 float
45 add_float (register float u, register float v)
47 return u + v;
50 double
51 add_double (register double u, register double v)
53 return u + v;
56 typedef long double doublest;
58 doublest
59 add_doublest (register doublest u, register doublest v)
61 return u + v;
64 /* */
66 charest
67 wack_charest (register charest u, register charest v)
69 register charest l = u, r = v;
70 l = add_charest (l, r);
71 return l + r;
74 short
75 wack_short (register short u, register short v)
77 register short l = u, r = v;
78 l = add_short (l, r);
79 return l + r;
82 int
83 wack_int (register int u, register int v)
85 register int l = u, r = v;
86 l = add_int (l, r);
87 return l + r;
90 long
91 wack_long (register long u, register long v)
93 register long l = u, r = v;
94 l = add_long (l, r);
95 return l + r;
98 long
99 wack_longest (register longest u, register longest v)
101 register longest l = u, r = v;
102 l = add_longest (l, r);
103 return l + r;
106 float
107 wack_float (register float u, register float v)
109 register float l = u, r = v;
110 l = add_float (l, r);
111 return l + r;
114 double
115 wack_double (register double u, register double v)
117 register double l = u, r = v;
118 l = add_double (l, r);
119 return l + r;
122 doublest
123 wack_doublest (register doublest u, register doublest v)
125 register doublest l = u, r = v;
126 l = add_doublest (l, r);
127 return l + r;
130 /* */
132 struct s_1 { short s[1]; } z_1, s_1;
133 struct s_2 { short s[2]; } z_2, s_2;
134 struct s_3 { short s[3]; } z_3, s_3;
135 struct s_4 { short s[4]; } z_4, s_4;
137 struct s_1
138 add_struct_1 (struct s_1 s)
140 int i;
141 for (i = 0; i < sizeof (s) / sizeof (s.s[0]); i++)
143 s.s[i] = s.s[i] + s.s[i];
145 return s;
148 struct s_2
149 add_struct_2 (struct s_2 s)
151 int i;
152 for (i = 0; i < sizeof (s) / sizeof (s.s[0]); i++)
154 s.s[i] = s.s[i] + s.s[i];
156 return s;
159 struct s_3
160 add_struct_3 (struct s_3 s)
162 int i;
163 for (i = 0; i < sizeof (s) / sizeof (s.s[0]); i++)
165 s.s[i] = s.s[i] + s.s[i];
167 return s;
170 struct s_4
171 add_struct_4 (struct s_4 s)
173 int i;
174 for (i = 0; i < sizeof (s) / sizeof (s.s[0]); i++)
176 s.s[i] = s.s[i] + s.s[i];
178 return s;
181 struct s_1
182 wack_struct_1 (void)
184 int i; register struct s_1 u = z_1;
185 for (i = 0; i < sizeof (s_1) / sizeof (s_1.s[0]); i++) { s_1.s[i] = i + 1; }
186 u = add_struct_1 (u);
187 return u;
190 struct s_2
191 wack_struct_2 (void)
193 int i; register struct s_2 u = z_2;
194 for (i = 0; i < sizeof (s_2) / sizeof (s_2.s[0]); i++) { s_2.s[i] = i + 1; }
195 u = add_struct_2 (u);
196 return u;
199 struct s_3
200 wack_struct_3 (void)
202 int i; register struct s_3 u = z_3;
203 for (i = 0; i < sizeof (s_3) / sizeof (s_3.s[0]); i++) { s_3.s[i] = i + 1; }
204 u = add_struct_3 (u);
205 return u;
208 struct s_4
209 wack_struct_4 (void)
211 int i; register struct s_4 u = z_4;
212 for (i = 0; i < sizeof (s_4) / sizeof (s_4.s[0]); i++) { s_4.s[i] = i + 1; }
213 u = add_struct_4 (u);
214 return u;
217 /* */
219 struct f_1 {unsigned i:1;unsigned j:1;unsigned k:1; } f_1 = {1,1,1}, F_1;
220 struct f_2 {unsigned i:2;unsigned j:2;unsigned k:2; } f_2 = {1,1,1}, F_2;
221 struct f_3 {unsigned i:3;unsigned j:3;unsigned k:3; } f_3 = {1,1,1}, F_3;
222 struct f_4 {unsigned i:4;unsigned j:4;unsigned k:4; } f_4 = {1,1,1}, F_4;
224 struct f_1
225 wack_field_1 (void)
227 register struct f_1 u = f_1;
228 return u;
231 struct f_2
232 wack_field_2 (void)
234 register struct f_2 u = f_2;
235 return u;
238 struct f_3
239 wack_field_3 (void)
241 register struct f_3 u = f_3;
242 return u;
245 struct f_4
246 wack_field_4 (void)
248 register struct f_4 u = f_4;
249 return u;
252 /* */
255 main ()
257 /* These calls are for current frame test. */
258 wack_charest (-1, -2);
259 wack_short (-1, -2);
260 wack_int (-1, -2);
261 wack_long (-1, -2);
262 wack_longest (-1, -2);
263 wack_float (-1, -2);
264 wack_double (-1, -2);
265 wack_doublest (-1, -2);
267 /* These calls are for up frame. */
268 wack_charest (-1, -2);
269 wack_short (-1, -2);
270 wack_int (-1, -2);
271 wack_long (-1, -2);
272 wack_longest (-1, -2);
273 wack_float (-1, -2);
274 wack_double (-1, -2);
275 wack_doublest (-1, -2);
277 /* These calls are for current frame test. */
278 wack_struct_1 ();
279 wack_struct_2 ();
280 wack_struct_3 ();
281 wack_struct_4 ();
283 /* These calls are for up frame. */
284 wack_struct_1 ();
285 wack_struct_2 ();
286 wack_struct_3 ();
287 wack_struct_4 ();
289 wack_field_1 ();
290 wack_field_2 ();
291 wack_field_3 ();
292 wack_field_4 ();
294 return 0;