Fix: Null pointer dereference in ldlex.l
[binutils-gdb.git] / gdb / testsuite / gdb.base / exprs.c
blob195b88e9142a805bd6f9274d79539b1f0894780c
1 int main (int argc, char **argv, char **envp)
3 extern void dummy();
4 dummy();
5 return 0;
9 /* We put main() right up front so its line number doesn't keep changing. */
12 * Test file with lots of different types, for testing the
13 * "whatis" command.
17 * First the basic C types.
20 #if !defined (__STDC__) && !defined (_AIX)
21 #define signed /**/
22 #endif
24 char v_char;
25 signed char v_signed_char;
26 unsigned char v_unsigned_char;
28 short v_short;
29 signed short v_signed_short;
30 unsigned short v_unsigned_short;
32 int v_int;
33 signed int v_signed_int;
34 unsigned int v_unsigned_int;
36 long v_long;
37 signed long v_signed_long;
38 unsigned long v_unsigned_long;
40 float v_float;
41 double v_double;
43 * Now some derived types, which are arrays, functions-returning,
44 * pointers, structures, unions, and enumerations.
47 /**** arrays *******/
49 char v_char_array[2];
50 signed char v_signed_char_array[2];
51 unsigned char v_unsigned_char_array[2];
53 short v_short_array[2];
54 signed short v_signed_short_array[2];
55 unsigned short v_unsigned_short_array[2];
57 int v_int_array[2];
58 signed int v_signed_int_array[2];
59 unsigned int v_unsigned_int_array[2];
61 long v_long_array[2];
62 signed long v_signed_long_array[2];
63 unsigned long v_unsigned_long_array[2];
65 float v_float_array[2];
66 double v_double_array[2];
68 /**** initialized array *******/
70 int v_int_array_init[2] = { 10, 20 };
72 /**** pointers *******/
74 char *v_char_pointer;
75 signed char *v_signed_char_pointer;
76 unsigned char *v_unsigned_char_pointer;
78 short *v_short_pointer;
79 signed short *v_signed_short_pointer;
80 unsigned short *v_unsigned_short_pointer;
82 int *v_int_pointer;
83 signed int *v_signed_int_pointer;
84 unsigned int *v_unsigned_int_pointer;
86 long *v_long_pointer;
87 signed long *v_signed_long_pointer;
88 unsigned long *v_unsigned_long_pointer;
90 float *v_float_pointer;
91 double *v_double_pointer;
93 /**** structs *******/
95 struct t_struct {
96 char v_char_member;
97 short v_short_member;
98 int v_int_member;
99 long v_long_member;
100 float v_float_member;
101 double v_double_member;
102 } v_struct1;
104 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_struct2;
113 /**** unions *******/
115 union t_union {
116 char v_char_member;
117 short v_short_member;
118 int v_int_member;
119 long v_long_member;
120 float v_float_member;
121 double v_double_member;
122 } v_union;
124 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_union2;
133 /*** Functions returning type ********/
135 char v_char_func () { return(0); }
136 signed char v_signed_char_func () { return (0); }
137 unsigned char v_unsigned_char_func () { return (0); }
139 short v_short_func () { return (0); }
140 signed short v_signed_short_func () { return (0); }
141 unsigned short v_unsigned_short_func () { return (0); }
143 int v_int_func () { return (0); }
144 signed int v_signed_int_func () { return (0); }
145 unsigned int v_unsigned_int_func () { return (0); }
147 long v_long_func () { return (0); }
148 signed long v_signed_long_func () { return (0); }
149 unsigned long v_unsigned_long_func () { return (0); }
151 float v_float_func () { return (0.0); }
152 double v_double_func () { return (0.0); }
154 /**** Some misc more complicated things *******/
156 struct link {
157 struct link *next;
158 #ifdef __STDC__
159 struct link *(*linkfunc) (struct link *self, int flags);
160 #else
161 struct link *(*linkfunc) ();
162 #endif
163 struct t_struct stuff[1][2][3];
164 } *s_link;
166 union tu_link {
167 struct link *next;
168 #ifdef __STDC__
169 struct link *(*linkfunc) (struct link *self, int flags);
170 #else
171 struct link *(*linkfunc) ();
172 #endif
173 struct t_struct stuff[1][2][3];
174 } u_link;
176 /**** Enumerations *******/
178 enum colors {red, green, blue} color;
179 enum cars {chevy, ford, porsche} clunker;
181 struct t_struct *null_t_struct;
183 void dummy()
185 /* Some linkers (e.g. on AIX) remove unreferenced variables,
186 so make sure to reference them. */
187 v_char = 0;
188 v_signed_char = 1;
189 v_unsigned_char = 2;
191 v_short = 3;
192 v_signed_short = 4;
193 v_unsigned_short = 5;
195 v_int = 6;
196 v_signed_int = 7;
197 v_unsigned_int = 8;
199 v_long = 9;
200 v_signed_long = 10;
201 v_unsigned_long = 11;
203 v_float = 100.0;
204 v_double = 200.0;
205 v_char_array[0] = v_char;
206 v_signed_char_array[0] = v_signed_char;
207 v_unsigned_char_array[0] = v_unsigned_char;
209 v_short_array[0] = v_short;
210 v_signed_short_array[0] = v_signed_short;
211 v_unsigned_short_array[0] = v_unsigned_short;
213 v_int_array[0] = v_int;
214 v_signed_int_array[0] = v_signed_int;
215 v_unsigned_int_array[0] = v_unsigned_int;
217 v_long_array[0] = v_long;
218 v_signed_long_array[0] = v_signed_long;
219 v_unsigned_long_array[0] = v_unsigned_long;
221 v_float_array[0] = v_float;
222 v_double_array[0] = v_double;
223 v_char_pointer = &v_char;
224 v_signed_char_pointer = &v_signed_char;
225 v_unsigned_char_pointer = &v_unsigned_char;
227 v_short_pointer = &v_short;
228 v_signed_short_pointer = &v_signed_short;
229 v_unsigned_short_pointer = &v_unsigned_short;
231 v_int_pointer = &v_int;
232 v_signed_int_pointer = &v_signed_int;
233 v_unsigned_int_pointer = &v_unsigned_int;
235 v_long_pointer = &v_long;
236 v_signed_long_pointer = &v_signed_long;
237 v_unsigned_long_pointer = &v_unsigned_long;
239 v_float_pointer = &v_float;
240 v_double_pointer = &v_double;
242 color = red;
243 clunker = porsche;
245 u_link.next = s_link;
247 v_struct2.v_int_member = v_struct1.v_int_member;
248 v_union2.v_short_member = v_union.v_short_member;