Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / testsuite / gdb.base / setvar.c
blob969de0d5e719b0958bad650bcb967d4a3ff7e495
1 #include <stdlib.h>
3 #ifdef PROTOTYPES
4 int main (int argc, char **argv, char **envp)
5 #else
6 main (argc, argv, envp)
7 int argc;
8 char **argv;
9 char **envp;
10 #endif
12 extern void dummy();
13 #ifdef usestubs
14 set_debug_traps();
15 breakpoint();
16 #endif
17 dummy();
18 return 0;
21 /* We put main() right up front so its line number doesn't keep changing. */
24 * Test file with lots of different types, for testing the
25 * "whatis" command.
29 * First the basic C types.
32 #if !defined (__STDC__) && !defined (_AIX)
33 #define signed /**/
34 #endif
36 char v_char;
37 signed char v_signed_char;
38 unsigned char v_unsigned_char;
40 short v_short;
41 signed short v_signed_short;
42 unsigned short v_unsigned_short;
44 int v_int;
45 signed int v_signed_int;
46 unsigned int v_unsigned_int;
48 long v_long;
49 signed long v_signed_long;
50 unsigned long v_unsigned_long;
52 float v_float;
53 double v_double;
56 * Now some derived types, which are arrays, functions-returning,
57 * pointers, structures, unions, and enumerations.
60 /**** arrays *******/
62 char v_char_array[2];
63 signed char v_signed_char_array[2];
64 unsigned char v_unsigned_char_array[2];
66 short v_short_array[2];
67 signed short v_signed_short_array[2];
68 unsigned short v_unsigned_short_array[2];
70 int v_int_array[2];
71 signed int v_signed_int_array[2];
72 unsigned int v_unsigned_int_array[2];
74 long v_long_array[2];
75 signed long v_signed_long_array[2];
76 unsigned long v_unsigned_long_array[2];
78 float v_float_array[2];
79 double v_double_array[2];
81 /**** pointers *******/
83 char *v_char_pointer;
84 signed char *v_signed_char_pointer;
85 unsigned char *v_unsigned_char_pointer;
87 short *v_short_pointer;
88 signed short *v_signed_short_pointer;
89 unsigned short *v_unsigned_short_pointer;
91 int *v_int_pointer;
92 signed int *v_signed_int_pointer;
93 unsigned int *v_unsigned_int_pointer;
95 long *v_long_pointer;
96 signed long *v_signed_long_pointer;
97 unsigned long *v_unsigned_long_pointer;
99 float *v_float_pointer;
100 double *v_double_pointer;
102 /**** structs *******/
104 struct t_struct {
105 char v_char_member;
106 short v_short_member;
107 int v_int_member;
108 long v_long_member;
109 float v_float_member;
110 double v_double_member;
111 } v_struct1;
113 struct {
114 char v_char_member;
115 short v_short_member;
116 int v_int_member;
117 long v_long_member;
118 float v_float_member;
119 double v_double_member;
120 } v_struct2;
122 /**** unions *******/
124 union t_union {
125 char v_char_member;
126 short v_short_member;
127 int v_int_member;
128 long v_long_member;
129 float v_float_member;
130 double v_double_member;
131 } v_union;
133 union {
134 char v_char_member;
135 short v_short_member;
136 int v_int_member;
137 long v_long_member;
138 float v_float_member;
139 double v_double_member;
140 } v_union2;
142 /*** Functions returning type ********/
144 char v_char_func () { return(0); }
145 signed char v_signed_char_func () { return (0); }
146 unsigned char v_unsigned_char_func () { return (0); }
148 short v_short_func () { return (0); }
149 signed short v_signed_short_func () { return (0); }
150 unsigned short v_unsigned_short_func () { return (0); }
152 int v_int_func () { return (0); }
153 signed int v_signed_int_func () { return (0); }
154 unsigned int v_unsigned_int_func () { return (0); }
156 long v_long_func () { return (0); }
157 signed long v_signed_long_func () { return (0); }
158 unsigned long v_unsigned_long_func () { return (0); }
160 float v_float_func () { return (0.0); }
161 double v_double_func () { return (0.0); }
163 /**** Some misc more complicated things *******/
165 struct link {
166 struct link *next;
167 #ifdef __STDC__
168 struct link *(*linkfunc) (struct link *this, int flags);
169 #else
170 struct link *(*linkfunc) ();
171 #endif
172 struct t_struct stuff[1][2][3];
173 } *s_link;
175 union tu_link {
176 struct link *next;
177 #ifdef __STDC__
178 struct link *(*linkfunc) (struct link *this, int flags);
179 #else
180 struct link *(*linkfunc) ();
181 #endif
182 struct t_struct stuff[1][2][3];
183 } u_link;
185 /**** Enumerations *******/
187 enum colors {red, green, blue} color;
188 enum cars {chevy, ford, porsche} clunker;
190 /**** Enumeration bitfields, supported by GNU C *******/
192 #ifdef __GNUC__
193 enum senum {sm1 = -1, s1 = 1};
194 struct senum_field {enum senum field:2; } sef;
195 enum uenum {u1 = 1, u2 = 2};
196 struct uenum_field {enum uenum field:2; } uef;
197 #endif
199 void
200 dummy ()
202 /* setvar.exp wants to allocate memory for constants. So make sure malloc
203 gets linked into the program. */
204 malloc (1);
206 /* Some linkers (e.g. on AIX) remove unreferenced variables,
207 so make sure to reference them. */
208 v_char = 0;
209 v_signed_char = 1;
210 v_unsigned_char = 2;
212 v_short = 3;
213 v_signed_short = 4;
214 v_unsigned_short = 5;
216 v_int = 6;
217 v_signed_int = 7;
218 v_unsigned_int = 8;
220 v_long = 9;
221 v_signed_long = 10;
222 v_unsigned_long = 11;
224 v_float = 100.0;
225 v_double = 200.0;
228 v_char_array[0] = v_char;
229 v_signed_char_array[0] = v_signed_char;
230 v_unsigned_char_array[0] = v_unsigned_char;
232 v_short_array[0] = v_short;
233 v_signed_short_array[0] = v_signed_short;
234 v_unsigned_short_array[0] = v_unsigned_short;
236 v_int_array[0] = v_int;
237 v_signed_int_array[0] = v_signed_int;
238 v_unsigned_int_array[0] = v_unsigned_int;
240 v_long_array[0] = v_long;
241 v_signed_long_array[0] = v_signed_long;
242 v_unsigned_long_array[0] = v_unsigned_long;
244 v_float_array[0] = v_float;
245 v_double_array[0] = v_double;
247 v_char_pointer = &v_char;
248 v_signed_char_pointer = &v_signed_char;
249 v_unsigned_char_pointer = &v_unsigned_char;
251 v_short_pointer = &v_short;
252 v_signed_short_pointer = &v_signed_short;
253 v_unsigned_short_pointer = &v_unsigned_short;
255 v_int_pointer = &v_int;
256 v_signed_int_pointer = &v_signed_int;
257 v_unsigned_int_pointer = &v_unsigned_int;
259 v_long_pointer = &v_long;
260 v_signed_long_pointer = &v_signed_long;
261 v_unsigned_long_pointer = &v_unsigned_long;
263 v_float_pointer = &v_float;
264 v_double_pointer = &v_double;
266 color = red;
267 clunker = porsche;
269 u_link.next = s_link;
271 v_struct2.v_int_member = v_struct1.v_int_member;
272 v_union2.v_short_member = v_union.v_short_member;
274 #ifdef __GNUC__
275 sef.field = s1;
276 uef.field = u1;
277 #endif