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