Commit | Line | Data |
---|---|---|
71d7dd7c AC |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
88b9d363 | 3 | Copyright 2004-2022 Free Software Foundation, Inc. |
71d7dd7c AC |
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 | |
a9762ec7 | 7 | the Free Software Foundation; either version 3 of the License, or |
71d7dd7c AC |
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. | |
a9762ec7 | 14 | |
71d7dd7c | 15 | You should have received a copy of the GNU General Public License |
a9762ec7 | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
71d7dd7c AC |
17 | |
18 | */ | |
19 | ||
20 | /* Useful abreviations. */ | |
21 | typedef void t; | |
22 | typedef char tc; | |
23 | typedef short ts; | |
24 | typedef int ti; | |
25 | typedef long tl; | |
26 | typedef long long tll; | |
27 | typedef float tf; | |
28 | typedef double td; | |
29 | typedef long double tld; | |
30 | typedef enum { e = '1' } te; | |
31 | ||
32 | /* Force the type of each field. */ | |
33 | #ifndef T | |
34 | typedef t T; | |
35 | #endif | |
36 | ||
37 | T foo = '1', L; | |
cd096ec8 | 38 | T init = '9'; |
71d7dd7c AC |
39 | |
40 | T fun() | |
41 | { | |
42 | return foo; | |
43 | } | |
44 | ||
71d7dd7c | 45 | void Fun(T foo) |
71d7dd7c AC |
46 | { |
47 | L = foo; | |
48 | } | |
49 | ||
a59add0c | 50 | void zed () |
71d7dd7c AC |
51 | { |
52 | L = 'Z'; | |
53 | } | |
54 | ||
55 | int main() | |
56 | { | |
71d7dd7c AC |
57 | int i; |
58 | ||
cd096ec8 HD |
59 | /* Use a different initial value then is later used in the |
60 | "value foo returned" test, so in case the struct is then returned | |
61 | on the stack, it doesn't have the correct value by accident. */ | |
62 | Fun(init); | |
71d7dd7c AC |
63 | |
64 | /* An infinite loop that first clears all the variables and then | |
65 | calls the function. This "hack" is to make re-testing easier - | |
177b42fe | 66 | "advance fun" is guaranteed to have always been preceded by a |
71d7dd7c AC |
67 | global variable clearing zed call. */ |
68 | ||
69 | zed (); | |
70 | while (1) | |
71 | { | |
72 | L = fun (); | |
73 | zed (); | |
74 | } | |
75 | ||
76 | return 0; | |
77 | } |