2013-05-24 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / pr44699.c
blob601cc78f5726ea159e9ea51e314c7c842797a9ad
1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3 typedef long unsigned int size_t;
4 typedef long int intmax_t;
5 typedef long unsigned int uintmax_t;
6 extern void *xmalloc (size_t) __attribute__ ((__malloc__));
7 extern const char *trim_filename (const char *);
9 static __inline void *
10 __inline_memcpy_chk (void *__dest, const void *__src, size_t __len)
12 return __builtin___memcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));
15 typedef unsigned int hashval_t;
16 typedef hashval_t (*htab_hash) (const void *);
17 typedef int (*htab_eq) (const void *, const void *);
18 typedef void (*htab_del) (void *);
19 typedef int (*htab_trav) (void **, void *);
20 typedef void *(*htab_alloc) (size_t, size_t);
21 typedef void (*htab_free) (void *);
23 typedef void *(*htab_alloc_with_arg) (void *, size_t, size_t);
24 typedef void (*htab_free_with_arg) (void *, void *);
25 struct htab {
26 htab_hash hash_f;
27 htab_eq eq_f;
28 htab_del del_f;
29 void ** entries;
30 size_t size;
31 size_t n_elements;
32 size_t n_deleted;
33 unsigned int searches;
34 unsigned int collisions;
35 htab_alloc alloc_f;
36 htab_free free_f;
37 void * alloc_arg;
38 htab_alloc_with_arg alloc_with_arg_f;
39 htab_free_with_arg free_with_arg_f;
40 unsigned int size_prime_index;
43 typedef struct htab *htab_t;
44 enum insert_option {NO_INSERT, INSERT};
45 extern void * htab_find (htab_t, const void *);
46 extern void ** htab_find_slot (htab_t, const void *, enum insert_option);
48 enum mode_class { MODE_RANDOM, MODE_CC, MODE_INT, MODE_PARTIAL_INT, MODE_FRACT, MODE_UFRACT, MODE_ACCUM, MODE_UACCUM, MODE_FLOAT, MODE_DECIMAL_FLOAT, MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MODE_VECTOR_INT, MODE_VECTOR_FRACT, MODE_VECTOR_UFRACT, MODE_VECTOR_ACCUM, MODE_VECTOR_UACCUM, MODE_VECTOR_FLOAT, MAX_MODE_CLASS };
50 static const char *const mode_class_names[MAX_MODE_CLASS] =
52 "MODE_RANDOM", "MODE_CC", "MODE_INT", "MODE_PARTIAL_INT", "MODE_FRACT", "MODE_UFRACT", "MODE_ACCUM", "MODE_UACCUM", "MODE_FLOAT", "MODE_DECIMAL_FLOAT", "MODE_COMPLEX_INT", "MODE_COMPLEX_FLOAT", "MODE_VECTOR_INT", "MODE_VECTOR_FRACT", "MODE_VECTOR_UFRACT", "MODE_VECTOR_ACCUM", "MODE_VECTOR_UACCUM", "MODE_VECTOR_FLOAT"
54 struct mode_data
56 struct mode_data *next;
58 const char *name;
59 enum mode_class cl;
60 unsigned int precision;
61 unsigned int bytesize;
62 unsigned int ncomponents;
63 unsigned int alignment;
64 const char *format;
66 struct mode_data *component;
67 struct mode_data *wider;
68 struct mode_data *wider_2x;
70 struct mode_data *contained;
72 struct mode_data *next_cont;
74 const char *file;
75 unsigned int line;
76 unsigned int counter;
77 unsigned int ibit;
78 unsigned int fbit;
81 static struct mode_data *modes[MAX_MODE_CLASS];
82 static unsigned int n_modes[MAX_MODE_CLASS];
83 static struct mode_data *void_mode;
85 static const struct mode_data blank_mode = {
86 0, "<unknown>", MAX_MODE_CLASS,
87 -1U, -1U, -1U, -1U,
88 0, 0, 0, 0, 0, 0,
89 "<unknown>", 0, 0, 0, 0
92 static htab_t modes_by_name;
94 static __inline__ struct mode_data *
95 find_mode (const char *name)
97 struct mode_data key;
99 key.name = name;
100 return (struct mode_data *) htab_find (modes_by_name, &key);
103 static struct mode_data *
104 new_mode (enum mode_class cl, const char *name,
105 const char *file, unsigned int line)
107 struct mode_data *m;
108 static unsigned int count = 0;
110 m = find_mode (name);
111 if (m)
113 error ("%s:%d: duplicate definition of mode \"%s\"",
114 trim_filename (file), line, name);
115 error ("%s:%d: previous definition here", m->file, m->line);
116 return m;
119 m = ((struct mode_data *) xmalloc (sizeof (struct mode_data)));
120 ((__builtin_object_size (m, 0) != (size_t) -1) ? __builtin___memcpy_chk (m, &blank_mode, sizeof (struct mode_data), __builtin_object_size (m, 0)) : __inline_memcpy_chk (m, &blank_mode, sizeof (struct mode_data)));
121 m->cl = cl;
122 m->name = name;
123 if (file)
124 m->file = trim_filename (file);
125 m->line = line;
126 m->counter = count++;
128 m->next = modes[cl];
129 modes[cl] = m;
130 n_modes[cl]++;
132 *htab_find_slot (modes_by_name, m, INSERT) = m;
134 return m;
137 static void
138 make_int_mode (const char *name,
139 unsigned int precision, unsigned int bytesize,
140 const char *file, unsigned int line)
142 struct mode_data *m = new_mode (MODE_INT, name, file, line);
143 m->bytesize = bytesize;
144 m->precision = precision;
147 static void
148 create_modes (void)
150 make_int_mode ("HI", -1U, 2, "../../work/gcc/machmode.def", 182);
154 main (int argc, char **argv)
156 create_modes ();