Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/pr42614.c

raw
1 extern void *malloc(__SIZE_TYPE__);
2 extern void abort(void);
3 extern void free(void *);
4
5 typedef struct SEntry
6 {
7 unsigned char num;
8 } TEntry;
9
10 typedef struct STable
11 {
12 TEntry data[2];
13 } TTable;
14
15 TTable *init ()
16 {
17 return malloc(sizeof(TTable));
18 }
19
20 void
21 expect_func (int a, unsigned char *b) __attribute__ ((noinline));
22
23 static inline void
24 inlined_wrong (TEntry *entry_p, int flag);
25
26 void
27 inlined_wrong (TEntry *entry_p, int flag)
28 {
29 unsigned char index;
30 entry_p->num = 0;
31
32 if (flag == 0)
33 abort();
34
35 for (index = 0; index < 1; index++)
36 entry_p->num++;
37
38 if (!entry_p->num)
39 {
40 abort();
41 }
42 }
43
44 void
45 expect_func (int a, unsigned char *b)
46 {
47 if (__builtin_abs ((a == 0)))
48 abort ();
49 if (__builtin_abs ((b == 0)))
50 abort ();
51 }
52
53 int
54 main ()
55 {
56 unsigned char index = 0;
57 TTable *table_p = init();
58 TEntry work;
59
60 inlined_wrong (&(table_p->data[1]), 1);
61 expect_func (1, &index);
62 inlined_wrong (&work, 1);
63
64 free (table_p);
65
66 return 0;
67 }
68