* gcc.dg/torture/stackalign/builtin-apply-2.c: Fix skip-if syntax.
[official-gcc.git] / gcc / testsuite / gcc.dg / guality / example.c
blob26d25c2859091540f58e7c6f71911d7c1017ab26
1 /* { dg-do run { xfail *-*-* } } */
2 /* { dg-options "-g" } */
4 #define GUALITY_DONT_FORCE_LIVE_AFTER -1
6 #ifndef STATIC_INLINE
7 #define STATIC_INLINE /*static*/
8 #endif
10 #include "guality.h"
12 #include <assert.h>
14 /* Test the debug info for the functions used in the VTA
15 presentation at the GCC Summit 2008. */
17 typedef struct list {
18 struct list *n;
19 int v;
20 } elt, *node;
22 STATIC_INLINE node
23 find_val (node c, int v, node e)
25 while (c < e)
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++;
37 return NULL;
40 STATIC_INLINE node
41 find_prev (node c, node w)
43 while (c)
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);
56 return NULL;
59 STATIC_INLINE node
60 check_arr (node c, node e)
62 if (c == e)
63 return NULL;
64 e--;
65 while (c < e)
67 GUALCHK (c);
68 GUALCHK (e);
69 if (c->v > (c+1)->v)
70 return c;
71 GUALCHK (c);
72 GUALCHK (e);
73 c++;
75 return NULL;
78 STATIC_INLINE node
79 check_list (node c, node t)
81 while (c != t)
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;
94 return NULL;
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 },
107 main (int argc, char *argv[])
109 int n = sizeof (testme) / sizeof (*testme);
110 node first, last, begin, end, ret;
112 GUALCHKXPR (n);
114 begin = first = &testme[0];
115 last = &testme[n-1];
116 end = &testme[n];
118 GUALCHKXPR (first);
119 GUALCHKXPR (last);
120 GUALCHKXPR (begin);
121 GUALCHKXPR (end);
123 ret = find_val (begin, 13, end);
124 GUALCHK (ret);
125 assert (ret == last);
127 ret = find_prev (first, last);
128 GUALCHK (ret);
129 assert (ret == &testme[n-2]);
131 ret = check_arr (begin, end);
132 GUALCHK (ret);
133 assert (!ret);
135 ret = check_list (first, last);
136 GUALCHK (ret);
137 assert (!ret);