aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorChristopher Li <sparse@chrisli.org>2013-07-25 09:37:11 -0700
committerChristopher Li <sparse@chrisli.org>2013-07-25 09:37:11 -0700
commit1c1a74106ea78f624105be6a9bb5d24268f38d91 (patch)
tree2e08c3f33ad0817aa42dedd0946c0bc21335ff6a /validation
parent5aa922d3919897481c8e65d9603ffc55e551fc19 (diff)
parentc0296d71405a97349d82e9909cad82a2af3271c2 (diff)
downloadsparse-dev-1c1a74106ea78f624105be6a9bb5d24268f38d91.tar.gz
Merge branch 'llvmcore'
Please consider pulling the latest Sparse/LLVM tree: git@github.com:penberg/sparse-llvm.git llvm/core It has various LLVM backend fixes from Jonathan and Xi.
Diffstat (limited to 'validation')
-rw-r--r--validation/backend/loop2.c14
-rw-r--r--validation/backend/store-type.c12
-rw-r--r--validation/backend/struct-access.c28
-rw-r--r--validation/backend/struct.c6
-rw-r--r--validation/backend/sum.c28
-rw-r--r--validation/cond_expr3.c17
6 files changed, 105 insertions, 0 deletions
diff --git a/validation/backend/loop2.c b/validation/backend/loop2.c
new file mode 100644
index 00000000..279af214
--- /dev/null
+++ b/validation/backend/loop2.c
@@ -0,0 +1,14 @@
+extern int op(void);
+
+static void test(void)
+{
+ int i;
+ for (i = 0; ; i++) {
+ op();
+ }
+}
+
+/*
+ * check-name: Loops with unused counter
+ * check-command: ./sparsec -c $file -o tmp.o
+ */
diff --git a/validation/backend/store-type.c b/validation/backend/store-type.c
new file mode 100644
index 00000000..9e2ce73f
--- /dev/null
+++ b/validation/backend/store-type.c
@@ -0,0 +1,12 @@
+struct foo;
+static struct foo *var;
+
+static void set(struct foo *f)
+{
+ var = f;
+}
+
+/*
+ * check-name: Type of stored objects
+ * check-command: ./sparsec -c $file -o tmp.o
+ */
diff --git a/validation/backend/struct-access.c b/validation/backend/struct-access.c
new file mode 100644
index 00000000..884b4706
--- /dev/null
+++ b/validation/backend/struct-access.c
@@ -0,0 +1,28 @@
+struct st {
+ int i, *d;
+};
+
+static int load_i(struct st *st)
+{
+ return st->i;
+}
+
+static void store_i(struct st *st, int i)
+{
+ st->i = i;
+}
+
+static int *load_d(struct st *st)
+{
+ return st->d;
+}
+
+static void store_d(struct st *st, int *d)
+{
+ st->d = d;
+}
+
+/*
+ * check-name: struct access code generation
+ * check-command: ./sparsec -c $file -o tmp.o
+ */
diff --git a/validation/backend/struct.c b/validation/backend/struct.c
index 1afaf2db..905339af 100644
--- a/validation/backend/struct.c
+++ b/validation/backend/struct.c
@@ -9,10 +9,16 @@ struct symbol {
struct symbol *next_id;
};
+struct unnamed {
+ struct { int x, y; };
+};
+
static struct symbol sym;
static struct symbol *sym_p;
static struct symbol *sym_q = &sym;
+static struct unnamed un;
+
/*
* check-name: Struct code generation
* check-command: ./sparsec -c $file -o tmp.o
diff --git a/validation/backend/sum.c b/validation/backend/sum.c
new file mode 100644
index 00000000..c9451d4b
--- /dev/null
+++ b/validation/backend/sum.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+static int sum(int n)
+{
+ int i, result = 0;
+
+ for (i = 1; i <= n; ++i)
+ result += i;
+ return result;
+}
+
+int main(int argc, char **argv)
+{
+ printf("%d\n", sum(5));
+ printf("%d\n", sum(100));
+ return 0;
+}
+
+/*
+ * check-name: sum from 1 to n
+ * check-command: ./sparsei $file
+ *
+ * check-output-start
+15
+5050
+ * check-output-end
+ */
diff --git a/validation/cond_expr3.c b/validation/cond_expr3.c
new file mode 100644
index 00000000..748409e6
--- /dev/null
+++ b/validation/cond_expr3.c
@@ -0,0 +1,17 @@
+static int icmp = 1 / (sizeof(int) - sizeof(1 > 0));
+static int fcmp = 1 / (sizeof(int) - sizeof(1.0 == 2.0 - 1.0));
+static int lnot = 1 / (sizeof(int) - sizeof(!!1.0));
+static int land = 1 / (sizeof(int) - sizeof(2 && 3));
+static int lor = 1 / (sizeof(int) - sizeof('c' || 1.0f));
+
+/*
+ * check-name: result type of relational and logical operators
+ *
+ * check-error-start
+cond_expr3.c:1:21: warning: division by zero
+cond_expr3.c:2:21: warning: division by zero
+cond_expr3.c:3:21: warning: division by zero
+cond_expr3.c:4:21: warning: division by zero
+cond_expr3.c:5:21: warning: division by zero
+ * check-error-end
+ */