RISC-V: Add support for riscv-*-*.
[official-gcc.git] / gcc / testsuite / gcc.c-torture / compile / 20010102-1.c
bloba409b566098f51c72bb9d3f1c11e7f03b262a922
1 /* This testcase derives from gnu obstack.c/obstack.h and failed with
2 -O3 -funroll-all-loops, or -O1 -frename-registers -funroll-loops on
3 sparc-sun-solaris2.7.
5 Copyright (C) 2001 Free Software Foundation. */
7 # define PTR_INT_TYPE __PTRDIFF_TYPE__
9 struct _obstack_chunk
11 char *limit;
12 struct _obstack_chunk *prev;
13 char contents[4];
16 struct obstack
18 long chunk_size;
19 struct _obstack_chunk *chunk;
20 char *object_base;
21 char *next_free;
22 char *chunk_limit;
23 PTR_INT_TYPE temp;
24 int alignment_mask;
25 struct _obstack_chunk *(*chunkfun) (void *, long);
26 void (*freefun) (void *, struct _obstack_chunk *);
27 void *extra_arg;
28 unsigned use_extra_arg:1;
29 unsigned maybe_empty_object:1;
30 unsigned alloc_failed:1;
33 extern void _obstack_newchunk (struct obstack *, int);
35 struct fooalign {char x; double d;};
36 #define DEFAULT_ALIGNMENT \
37 ((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0))
38 union fooround {long x; double d;};
39 #define DEFAULT_ROUNDING (sizeof (union fooround))
41 #ifndef COPYING_UNIT
42 #define COPYING_UNIT int
43 #endif
45 #define CALL_CHUNKFUN(h, size) \
46 (((h) -> use_extra_arg) \
47 ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
48 : (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size)))
50 #define CALL_FREEFUN(h, old_chunk) \
51 do { \
52 if ((h) -> use_extra_arg) \
53 (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
54 else \
55 (*(void (*) (void *)) (h)->freefun) ((old_chunk)); \
56 } while (0)
58 void
59 _obstack_newchunk (h, length)
60 struct obstack *h;
61 int length;
63 register struct _obstack_chunk *old_chunk = h->chunk;
64 register struct _obstack_chunk *new_chunk;
65 register long new_size;
66 register long obj_size = h->next_free - h->object_base;
67 register long i;
68 long already;
70 new_size = (obj_size + length) + (obj_size >> 3) + 100;
71 if (new_size < h->chunk_size)
72 new_size = h->chunk_size;
74 new_chunk = CALL_CHUNKFUN (h, new_size);
75 h->chunk = new_chunk;
76 new_chunk->prev = old_chunk;
77 new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size;
79 if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT)
81 for (i = obj_size / sizeof (COPYING_UNIT) - 1;
82 i >= 0; i--)
83 ((COPYING_UNIT *)new_chunk->contents)[i]
84 = ((COPYING_UNIT *)h->object_base)[i];
85 already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT);
87 else
88 already = 0;
89 for (i = already; i < obj_size; i++)
90 new_chunk->contents[i] = h->object_base[i];
92 if (h->object_base == old_chunk->contents && ! h->maybe_empty_object)
94 new_chunk->prev = old_chunk->prev;
95 CALL_FREEFUN (h, old_chunk);
98 h->object_base = new_chunk->contents;
99 h->next_free = h->object_base + obj_size;
100 h->maybe_empty_object = 0;