1 /* { dg-do run { xfail *-*-* } } */
2 /* { dg-options "-g" } */
3
4 #define GUALITY_DONT_FORCE_LIVE_AFTER -1
5
6 #ifndef STATIC_INLINE
7 #define STATIC_INLINE /*static*/
8 #endif
9
10 #include "guality.h"
11
12 #include <assert.h>
13
14 /* Test the debug info for the functions used in the VTA
15 presentation at the GCC Summit 2008. */
16
17 typedef struct list {
18 struct list *n;
19 int v;
20 } elt, *node;
21
22 STATIC_INLINE node
find_val(node c,int v,node e)23 find_val (node c, int v, node e)
24 {
25 while (c < e)
26 {
27 GUALCHK (c);
28 GUALCHK (v);
29 GUALCHK (e);
30 if (c->v == v)
31 return c;
32 GUALCHK (c);
33 GUALCHK (v);
34 GUALCHK (e);
35 c++;
36 }
37 return NULL;
38 }
39
40 STATIC_INLINE node
find_prev(node c,node w)41 find_prev (node c, node w)
42 {
43 while (c)
44 {
45 node o = c;
46 c = c->n;
47 GUALCHK (c);
48 GUALCHK (o);
49 GUALCHK (w);
50 if (c == w)
51 return o;
52 GUALCHK (c);
53 GUALCHK (o);
54 GUALCHK (w);
55 }
56 return NULL;
57 }
58
59 STATIC_INLINE node
check_arr(node c,node e)60 check_arr (node c, node e)
61 {
62 if (c == e)
63 return NULL;
64 e--;
65 while (c < e)
66 {
67 GUALCHK (c);
68 GUALCHK (e);
69 if (c->v > (c+1)->v)
70 return c;
71 GUALCHK (c);
72 GUALCHK (e);
73 c++;
74 }
75 return NULL;
76 }
77
78 STATIC_INLINE node
check_list(node c,node t)79 check_list (node c, node t)
80 {
81 while (c != t)
82 {
83 node n = c->n;
84 GUALCHK (c);
85 GUALCHK (n);
86 GUALCHK (t);
87 if (c->v > n->v)
88 return c;
89 GUALCHK (c);
90 GUALCHK (n);
91 GUALCHK (t);
92 c = n;
93 }
94 return NULL;
95 }
96
97 struct list testme[] = {
98 { &testme[1], 2 },
99 { &testme[2], 3 },
100 { &testme[3], 5 },
101 { &testme[4], 7 },
102 { &testme[5], 11 },
103 { NULL, 13 },
104 };
105
106 int
main(int argc,char * argv[])107 main (int argc, char *argv[])
108 {
109 int n = sizeof (testme) / sizeof (*testme);
110 node first, last, begin, end, ret;
111
112 GUALCHKXPR (n);
113
114 begin = first = &testme[0];
115 last = &testme[n-1];
116 end = &testme[n];
117
118 GUALCHKXPR (first);
119 GUALCHKXPR (last);
120 GUALCHKXPR (begin);
121 GUALCHKXPR (end);
122
123 ret = find_val (begin, 13, end);
124 GUALCHK (ret);
125 assert (ret == last);
126
127 ret = find_prev (first, last);
128 GUALCHK (ret);
129 assert (ret == &testme[n-2]);
130
131 ret = check_arr (begin, end);
132 GUALCHK (ret);
133 assert (!ret);
134
135 ret = check_list (first, last);
136 GUALCHK (ret);
137 assert (!ret);
138 }
139