1 /*
2    pr39339.c from the execute part of the gcc torture tests.
3  */
4 
5 #include <testfwk.h>
6 
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
10 
11 #include <string.h>
12 
13 struct C
14 {
15   unsigned int c;
16   struct D
17   {
18     unsigned int columns : 4;
19     unsigned int fore : 12;
20     unsigned int back : 6;
21     unsigned int fragment : 1;
22     unsigned int standout : 1;
23     unsigned int underline : 1;
24     unsigned int strikethrough : 1;
25     unsigned int reverse : 1;
26     unsigned int blink : 1;
27     unsigned int half : 1;
28     unsigned int bold : 1;
29     unsigned int invisible : 1;
30     unsigned int pad : 1;
31   } attr;
32 };
33 
34 struct A
35 {
36   struct C *data;
37   unsigned int len;
38 };
39 
40 struct B
41 {
42   struct A *cells;
43   unsigned char soft_wrapped : 1;
44 };
45 
46 struct E
47 {
48   long row, col;
49   struct C defaults;
50 };
51 
52 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pic14) // Lack of memory
foo(struct E * screen,unsigned int c,int columns,struct B * row)53 void foo (struct E *screen, unsigned int c, int columns, struct B *row)
54 {
55   struct D attr;
56   long col;
57   int i;
58   col = screen->col;
59   attr = screen->defaults.attr;
60   attr.columns = columns;
61   row->cells->data[col].c = c;
62   row->cells->data[col].attr = attr;
63   col++;
64   attr.fragment = 1;
65   for (i = 1; i < columns; i++)
66     {
67       row->cells->data[col].c = c;
68       row->cells->data[col].attr = attr;
69       col++;
70     }
71 }
72 #endif
73 
74 void
testTortureExecute(void)75 testTortureExecute (void)
76 {
77 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pic14) // Lack of memory
78 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
79   struct E e = {.row = 5,.col = 0,.defaults =
80       {6, {-1, -1, -1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}} };
81   struct C c[4];
82   struct A a = { c, 4 };
83   struct B b = { &a, 1 };
84   struct D d;
85   memset (&c, 0, sizeof c);
86   foo (&e, 65, 2, &b);
87   d = e.defaults.attr;
88   d.columns = 2;
89   if (memcmp (&d, &c[0].attr, sizeof d))
90     ASSERT (0);
91   d.fragment = 1;
92   if (memcmp (&d, &c[1].attr, sizeof d))
93     ASSERT (0);
94   return;
95 #endif
96 #endif
97 }
98 
99 
100