OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gdb/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.base/] [ptype.c] - Blame information for rev 25

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 jlechner
/*
2
 *      Test file with lots of different types, for testing the
3
 *      "ptype" command.
4
 */
5
 
6
/*
7
 *      First the basic C types.
8
 */
9
#include <stdlib.h>
10
 
11
#if !defined (__STDC__) && !defined (_AIX)
12
#define signed  /**/
13
#endif
14
 
15
char            v_char;
16
signed char     v_signed_char;
17
unsigned char   v_unsigned_char;
18
 
19
short           v_short;
20
signed short    v_signed_short;
21
unsigned short  v_unsigned_short;
22
 
23
int             v_int;
24
signed int      v_signed_int;
25
unsigned int    v_unsigned_int;
26
 
27
long            v_long;
28
signed long     v_signed_long;
29
unsigned long   v_unsigned_long;
30
 
31
float           v_float;
32
double          v_double;
33
 
34
/*
35
 *      Now some derived types, which are arrays, functions-returning,
36
 *      pointers, structures, unions, and enumerations.
37
 */
38
 
39
/**** arrays *******/
40
 
41
char            v_char_array[2];
42
signed char     v_signed_char_array[2];
43
unsigned char   v_unsigned_char_array[2];
44
 
45
short           v_short_array[2];
46
signed short    v_signed_short_array[2];
47
unsigned short  v_unsigned_short_array[2];
48
 
49
int             v_int_array[2];
50
signed int      v_signed_int_array[2];
51
unsigned int    v_unsigned_int_array[2];
52
 
53
long            v_long_array[2];
54
signed long     v_signed_long_array[2];
55
unsigned long   v_unsigned_long_array[2];
56
 
57
float           v_float_array[2];
58
double          v_double_array[2];
59
 
60
/* PR 3742 */
61
typedef char t_char_array[];
62
t_char_array *pv_char_array;
63
 
64
/**** pointers *******/
65
 
66
char            *v_char_pointer;
67
signed char     *v_signed_char_pointer;
68
unsigned char   *v_unsigned_char_pointer;
69
 
70
short           *v_short_pointer;
71
signed short    *v_signed_short_pointer;
72
unsigned short  *v_unsigned_short_pointer;
73
 
74
int             *v_int_pointer;
75
signed int      *v_signed_int_pointer;
76
unsigned int    *v_unsigned_int_pointer;
77
 
78
long            *v_long_pointer;
79
signed long     *v_signed_long_pointer;
80
unsigned long   *v_unsigned_long_pointer;
81
 
82
float           *v_float_pointer;
83
double          *v_double_pointer;
84
 
85
/**** structs *******/
86
 
87
struct t_struct {
88
    char        v_char_member;
89
    short       v_short_member;
90
    int         v_int_member;
91
    long        v_long_member;
92
    float       v_float_member;
93
    double      v_double_member;
94
} v_struct1;
95
 
96
struct t_struct *v_t_struct_p;
97
 
98
struct {
99
    char        v_char_member;
100
    short       v_short_member;
101
    int         v_int_member;
102
    long        v_long_member;
103
    float       v_float_member;
104
    double      v_double_member;
105
} v_struct2;
106
 
107
/* typedef'd struct without a tag.  */
108
typedef struct {
109
  double v_double_member;
110
  int v_int_member;
111
} t_struct3;
112
/* GCC seems to want a variable of this type, or else it won't put out
113
   a symbol.  */
114
t_struct3 v_struct3;
115
 
116
/**** unions *******/
117
 
118
union t_union {
119
    char        v_char_member;
120
    short       v_short_member;
121
    int         v_int_member;
122
    long        v_long_member;
123
    float       v_float_member;
124
    double      v_double_member;
125
} v_union;
126
 
127
union {
128
    char        v_char_member;
129
    short       v_short_member;
130
    int         v_int_member;
131
    long        v_long_member;
132
    float       v_float_member;
133
    double      v_double_member;
134
} v_union2;
135
 
136
/* typedef'd union without a tag.  */
137
typedef union {
138
  double v_double_member;
139
  int v_int_member;
140
} t_union3;
141
/* GCC seems to want a variable of this type, or else it won't put out
142
   a symbol.  */
143
t_union3 v_union3;
144
 
145
/*** Functions returning type ********/
146
 
147
char            v_char_func () { return(0); }
148
signed char     v_signed_char_func () { return (0); }
149
unsigned char   v_unsigned_char_func () { return (0); }
150
 
151
short           v_short_func () { return (0); }
152
signed short    v_signed_short_func () { return (0); }
153
unsigned short  v_unsigned_short_func () { return (0); }
154
 
155
int             v_int_func () { return (0); }
156
signed int      v_signed_int_func () { return (0); }
157
unsigned int    v_unsigned_int_func () { return (0); }
158
 
159
long            v_long_func () { return (0); }
160
signed long     v_signed_long_func () { return (0); }
161
unsigned long   v_unsigned_long_func () { return (0); }
162
 
163
float           v_float_func () { return (0.0); }
164
double          v_double_func () { return (0.0); }
165
 
166
/**** Some misc more complicated things *******/
167
 
168
struct link {
169
        struct link *next;
170
#ifdef __STDC__
171
        struct link *(*linkfunc) (struct link *this, int flags);
172
#else
173
        struct link *(*linkfunc) ();
174
#endif
175
        struct t_struct stuff[1][2][3];
176
} *s_link;
177
 
178
union tu_link {
179
        struct link *next;
180
#ifdef __STDC__
181
        struct link *(*linkfunc) (struct link *this, int flags);
182
#else
183
        struct link *(*linkfunc) ();
184
#endif
185
        struct t_struct stuff[1][2][3];
186
} u_link;
187
 
188
struct outer_struct {
189
        int outer_int;
190
        struct inner_struct {
191
                int inner_int;
192
                long inner_long;
193
        }inner_struct_instance;
194
        union inner_union {
195
                int inner_union_int;
196
                long inner_union_long;
197
        }inner_union_instance;
198
        long outer_long;
199
} nested_su;
200
 
201
struct highest
202
{
203
  int a;
204
  struct
205
  {
206
    int b;
207
    struct { int c; } anonymous_level_2;
208
  } anonymous_level_1;
209
} the_highest;
210
 
211
/**** Enumerations *******/
212
 
213
enum
214
/* Work around the bug for compilers which don't put out the right stabs.  */
215
#if __GNUC__ < 2 && !defined (_AIX)
216
primary1_tag
217
#endif
218
{red1, green1, blue1} primary1;
219
 
220
enum {red, green, blue} primary;
221
enum colors {yellow, purple, pink} nonprimary;
222
 
223
enum {chevy, ford} clunker;
224
enum cars {bmw, porsche} sportscar;
225
 
226
#undef FALSE
227
#undef TRUE
228
typedef enum {FALSE, TRUE} boolean;
229
boolean v_boolean;
230
/*note: aCC has bool type predefined with 'false' and 'true'*/
231
typedef enum bvals {my_false, my_true} boolean2;
232
boolean2 v_boolean2;
233
 
234
enum misordered {two = 2, one = 1, zero = 0, three = 3};
235
 
236
/* Seems like we need a variable of this type to get the type to be put
237
   in the executable, at least for AIX xlc.  */
238
enum misordered v_misordered = three;
239
 
240
/**** Pointers to functions *******/
241
 
242
typedef int (*func_type) (int (*) (int, float), float);
243
double (*old_fptr) ();
244
double (*new_fptr) (void);
245
int (*fptr) (int, float);
246
int *(*fptr2) (int (*) (int, float), float);
247
int (*xptr) (int (*) (), int (*) (void), int);
248
int (*(*ffptr) (char)) (short);
249
int (*(*(*fffptr) (char)) (short)) (long);
250
 
251
func_type v_func_type;
252
 
253
/* Here are the sort of stabs we expect to see for the above:
254
 
255
   .stabs "func_type:t(0,100)=*(0,101)=g(0,1)(0,102)=*(0,103)=g(0,1)(0,1)(0,14)#(0,14)#",128,0,234,0
256
   .stabs "old_fptr:G(0,110)=*(0,111)=f(0,15)",32,0,231,0
257
   .stabs "new_fptr:G(0,120)=*(0,121)=g(0,15)(0,122)=(0,122)#",32,0,232,0
258
   .stabs "fptr:G(0,130)=*(0,103)#",32,0,233,0
259
   .stabs "fptr2:G(0,140)=*(0,141)=g(0,142)=*(0,1)(0,102)(0,14)#",32,0,235,0
260
   .stabs "xptr:G(0,150)=*(0,151)=g(0,1)(0,152)=*(0,153)=f(0,1)(0,154)=*(0,155)=g(0,1)(0,122)#(0,1)#",32,0,236,0
261
   .stabs "ffptr:G(0,160)=*(0,161)=g(0,162)=*(0,163)=g(0,1)(0,8)#(0,2)#",32,0,237,0\
262
   .stabs "fffptr:G(0,170)=*(0,171)=g(0,172)=*(0,173)=g(0,174)=*(0,175)=g(0,1)(0,3)#(0,8)#(0,2)#",32,0,237,0
263
 
264
   Most of these use Sun's extension for prototyped function types ---
265
   the 'g' type descriptor.  As of around 9 Feb 2002, GCC didn't emit
266
   those, but GDB can read them, so the related tests in ptype.exp
267
   will all xfail.  */
268
 
269
 
270
/***********/
271
 
272
typedef int foo;
273
 
274
foo intfoo (afoo)
275
{
276
  return (afoo * 2);
277
}
278
 
279
/***********/
280
 
281
int main ()
282
{
283
  /* Ensure that malloc is a pointer type; avoid use of "void" and any include files. */
284
/*  extern char *malloc();*/
285
 
286
  /* Some of the tests in ptype.exp require invoking malloc, so make
287
     sure it is linked in to this program.  */
288
  v_char_pointer = (char *) malloc (1);
289
 
290
#ifdef usestubs
291
  set_debug_traps();
292
  breakpoint();
293
#endif
294
  /* Some linkers (e.g. on AIX) remove unreferenced variables,
295
     so make sure to reference them. */
296
  primary = blue;
297
  primary1 = blue1;
298
  nonprimary = pink;
299
  sportscar = porsche;
300
  clunker = ford;
301
  v_struct1.v_int_member = 5;
302
  v_struct2.v_int_member = 6;
303
  v_struct3.v_int_member = 7;
304
 
305
  v_char = 0;
306
  v_signed_char = 0;
307
  v_unsigned_char = 0;
308
 
309
  v_short = 0;
310
  v_signed_short = 0;
311
  v_unsigned_short = 0;
312
 
313
  v_int = 0;
314
  v_signed_int = 0;
315
  v_unsigned_int = 0;
316
 
317
  v_long = 0;
318
  v_signed_long = 0;
319
  v_unsigned_long = 0;
320
 
321
  v_float = 0;
322
  v_double = 0;
323
 
324
  v_char_array[0] = 0;
325
  v_signed_char_array[0] = 0;
326
  v_unsigned_char_array[0] = 0;
327
 
328
  v_short_array[0] = 0;
329
  v_signed_short_array[0] = 0;
330
  v_unsigned_short_array[0] = 0;
331
 
332
  v_int_array[0] = 0;
333
  v_signed_int_array[0] = 0;
334
  v_unsigned_int_array[0] = 0;
335
 
336
  v_long_array[0] = 0;
337
  v_signed_long_array[0] = 0;
338
  v_unsigned_long_array[0] = 0;
339
 
340
  v_float_array[0] = 0;
341
  v_double_array[0] = 0;
342
 
343
  v_char_pointer = 0;
344
  v_signed_char_pointer = 0;
345
  v_unsigned_char_pointer = 0;
346
 
347
  v_short_pointer = 0;
348
  v_signed_short_pointer = 0;
349
  v_unsigned_short_pointer = 0;
350
 
351
  v_int_pointer = 0;
352
  v_signed_int_pointer = 0;
353
  v_unsigned_int_pointer = 0;
354
 
355
  v_long_pointer = 0;
356
  v_signed_long_pointer = 0;
357
  v_unsigned_long_pointer = 0;
358
 
359
  v_float_pointer = 0;
360
  v_double_pointer = 0;
361
 
362
  nested_su.outer_int = 0;
363
  v_t_struct_p = 0;
364
 
365
  the_highest.a = 0;
366
 
367
  v_boolean = FALSE;
368
  v_boolean2 = my_false;
369
  return 0;
370
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.