aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/guality/example.c
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gcc.dg/guality/example.c
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/guality/example.c')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/guality/example.c138
1 files changed, 138 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/example.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/example.c
new file mode 100644
index 000000000..26d25c285
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/example.c
@@ -0,0 +1,138 @@
+/* { dg-do run { xfail *-*-* } } */
+/* { dg-options "-g" } */
+
+#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);
+}