struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20020402-3.c
blob940bb3cf8e8c7ffcdae4da7ed303886c61ab651a
1 /*
2 20020402-3.c from the execute part of the gcc torture suite.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 #define NULL ((void *) 0)
13 #if !defined(__SDCC_pic14) && !defined(__SDCC_pic16) && !defined(__SDCC_pdk14) // Lack of memory
15 /* extracted from gdb sources */
17 typedef unsigned long long CORE_ADDR;
19 struct blockvector;
21 struct symtab {
22 struct blockvector *blockvector;
25 struct sec {
26 void *unused;
29 struct symbol {
30 int len;
31 char *name;
34 struct block {
35 CORE_ADDR startaddr, endaddr;
36 struct symbol *function;
37 struct block *superblock;
38 unsigned char gcc_compile_flag;
39 int nsyms;
40 struct symbol syms[1];
43 struct blockvector {
44 int nblocks;
45 struct block *block[2];
48 struct blockvector *blockvector_for_pc_sect(register CORE_ADDR pc,
49 struct symtab *symtab)
51 register struct block *b;
52 register int bot, top, half;
53 struct blockvector *bl;
55 bl = symtab->blockvector;
56 b = bl->block[0];
58 bot = 0;
59 top = bl->nblocks;
61 while (top - bot > 1)
63 half = (top - bot + 1) >> 1;
64 b = bl->block[bot + half];
65 if (b->startaddr <= pc)
66 bot += half;
67 else
68 top = bot + half;
71 while (bot >= 0)
73 b = bl->block[bot];
74 if (b->endaddr > pc)
76 return bl;
78 bot--;
80 return 0;
82 #endif
84 void testTortureExecute(void)
86 #if !(defined (__SDCC_mcs51) && defined (__SDCC_MODEL_SMALL)) && !defined(__SDCC_pdk14) // Not enough memory
87 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
88 #if !defined(__SDCC_pic14) && !defined(__SDCC_pic16) // No long long
89 struct block a = { 0, 0x10000, 0, 0, 1, 20 };
90 struct block b = { 0x10000, 0x20000, 0, 0, 1, 20 };
91 struct blockvector bv = { 2, { &a, &b } };
92 struct symtab s = { &bv };
94 struct blockvector *ret;
96 ret = blockvector_for_pc_sect(0x500, &s);
98 ASSERT (ret != NULL && ret->nblocks == 2);
99 ASSERT (ret->block[0] != NULL && ret->block[0]->startaddr == 0LL && ret->block[0]->endaddr == 65536LL);
100 ASSERT (ret->block[1] != NULL && ret->block[1]->startaddr == 65536LL && ret->block[1]->endaddr == 131072LL);
102 return;
103 #endif
104 #endif
105 #endif