aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
Diffstat (limited to 'validation')
-rw-r--r--validation/bitfield-bool-layout.c26
-rw-r--r--validation/bitfield-kr.c14
-rw-r--r--validation/compound-literal00.c18
-rw-r--r--validation/compound-literal01.c27
-rw-r--r--validation/linear/builtin_unreachable.c31
-rw-r--r--validation/linear/cast-volatile.c14
-rw-r--r--validation/linear/inline-return.c24
-rw-r--r--validation/linear/stray-phisrc.c25
-rw-r--r--validation/mem2reg/address-used00.c19
-rw-r--r--validation/mem2reg/broken-phi02.c28
-rw-r--r--validation/mem2reg/broken-phi03.c29
-rw-r--r--validation/mem2reg/cond-expr.c13
-rw-r--r--validation/mem2reg/cond-expr5.c18
-rw-r--r--validation/mem2reg/global-direct-undef.c23
-rw-r--r--validation/mem2reg/global-direct.c23
-rw-r--r--validation/mem2reg/global-loop.c20
-rw-r--r--validation/mem2reg/global-noalias.c21
-rw-r--r--validation/mem2reg/global-pointer.c26
-rw-r--r--validation/mem2reg/if-direct.c19
-rw-r--r--validation/mem2reg/if-pointer.c21
-rw-r--r--validation/mem2reg/init-global-array.c17
-rw-r--r--validation/mem2reg/init-local-array.c25
-rw-r--r--validation/mem2reg/init-local-union0.c18
-rw-r--r--validation/mem2reg/init-local-union1.c32
-rw-r--r--validation/mem2reg/init-local.c27
-rw-r--r--validation/mem2reg/loop00.c16
-rw-r--r--validation/mem2reg/loop01-global.c18
-rw-r--r--validation/mem2reg/loop02-array.c23
-rw-r--r--validation/mem2reg/loop02-global.c22
-rw-r--r--validation/mem2reg/loop02-local.c23
-rw-r--r--validation/mem2reg/loop02-pointer.c23
-rw-r--r--validation/mem2reg/quadra00.c28
-rw-r--r--validation/mem2reg/short-load.c29
-rw-r--r--validation/mem2reg/undef00.c14
-rw-r--r--validation/mem2reg/volatile-store00.c27
-rw-r--r--validation/missing-return.c20
-rw-r--r--validation/multi-input.c11
-rw-r--r--validation/optim/missing-select.c24
-rw-r--r--validation/optim/volatile-store00.c27
-rw-r--r--validation/overflow.c19
-rw-r--r--validation/preprocessor/extra-token.c15
-rw-r--r--validation/sizeof-incomplete-type.c27
-rw-r--r--validation/storage-struct-member.c20
-rw-r--r--validation/var-undef-partial.c21
-rw-r--r--validation/vla-sizeof.c37
45 files changed, 1002 insertions, 0 deletions
diff --git a/validation/bitfield-bool-layout.c b/validation/bitfield-bool-layout.c
new file mode 100644
index 00000000..4e0a2b4a
--- /dev/null
+++ b/validation/bitfield-bool-layout.c
@@ -0,0 +1,26 @@
+struct bfb {
+ _Bool a:1;
+ _Bool f:1;
+ _Bool z:1;
+};
+
+
+struct bfb foo(struct bfb s)
+{
+ return s;
+}
+
+/*
+ * check-name: bitfield-bool-layout
+ * check-description: given that bool is here 1-bit wide
+ * each field here above completely 'fill' a bool.
+ * Thus 3 bools need to be allocated, but since the
+ * alignment is 1-byte the result has a size of 3
+ * bytes, 24 bits thus instead of 8.
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-known-to-fail
+ * check-output-ignore
+ * check-output-excludes: ret\\.24
+ * check-output-contains: ret\\.8
+ */
diff --git a/validation/bitfield-kr.c b/validation/bitfield-kr.c
new file mode 100644
index 00000000..ba66c5cd
--- /dev/null
+++ b/validation/bitfield-kr.c
@@ -0,0 +1,14 @@
+static int foo(b)
+ int b: 4;
+{
+ return 0;
+}
+
+/*
+ * check-name: bitfield in K&R
+ *
+ * check-known-to-fail
+ * check-error-start
+bitfield-kr.c:2:9: error: bitfield in K&R declaration of 'foo'
+ * check-error-end
+ */
diff --git a/validation/compound-literal00.c b/validation/compound-literal00.c
new file mode 100644
index 00000000..f3069d2c
--- /dev/null
+++ b/validation/compound-literal00.c
@@ -0,0 +1,18 @@
+struct bfs {
+ int a: 2;
+ int b: 30;
+};
+
+int foo(void)
+{
+ return (struct bfs){ .a = 1, .b = 2}.b;
+}
+
+/*
+ * check-name: compound-literal00.c
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-contains: ret\\..*\\$2
+ * check-error-end
+ */
diff --git a/validation/compound-literal01.c b/validation/compound-literal01.c
new file mode 100644
index 00000000..8a4935ea
--- /dev/null
+++ b/validation/compound-literal01.c
@@ -0,0 +1,27 @@
+struct bfs {
+ int a: 2;
+ int b: 30;
+};
+
+int foo(void)
+{
+ struct bfs bf = { .a = 1, .b = 2 };
+ return (struct bfs[]){bf}[0].b;
+}
+
+int bar(void)
+{
+ struct bfs bf = { .a = 1, .b = 4 };
+ return (struct bfs[]){bf, { .a = 3, .b = 6}}[1].b;
+}
+
+/*
+ * check-name: compound-literal01.c
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-known-to-fail
+ * check-output-ignore
+ * check-output-contains: ret\\..*\\$2
+ * check-output-contains: ret\\..*\\$6
+ * check-error-end
+ */
diff --git a/validation/linear/builtin_unreachable.c b/validation/linear/builtin_unreachable.c
new file mode 100644
index 00000000..4f13b892
--- /dev/null
+++ b/validation/linear/builtin_unreachable.c
@@ -0,0 +1,31 @@
+void function_that_never_returns(void);
+
+int foo(int c)
+{
+ if (c)
+ return 1;
+ function_that_never_returns();
+ __builtin_unreachable();
+}
+
+/*
+ * check-name: __builtin_unreachable()
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-known-to-fail
+ * check-output-start
+foo:
+.L0:
+ <entry-point>
+ cbr %arg1, .L3, .L2
+
+.L2:
+ call function_that_never_returns
+ unreach
+
+.L3:
+ ret.32 $1
+
+
+ * check-output-end
+ */
diff --git a/validation/linear/cast-volatile.c b/validation/linear/cast-volatile.c
new file mode 100644
index 00000000..f8a64937
--- /dev/null
+++ b/validation/linear/cast-volatile.c
@@ -0,0 +1,14 @@
+static int foo(volatile int *a, int v)
+{
+ *a = v;
+ return *a;
+}
+
+/*
+ * check-name: cast-volatile
+ * check-command: test-linearize -fdump-ir=linearize $file
+ *
+ * check-known-to-fail
+ * check-output-ignore
+ * check-output-excludes: scast\\.
+ */
diff --git a/validation/linear/inline-return.c b/validation/linear/inline-return.c
new file mode 100644
index 00000000..b1e4d844
--- /dev/null
+++ b/validation/linear/inline-return.c
@@ -0,0 +1,24 @@
+static inline int def(void)
+{
+ return 1;
+}
+
+int foo(void)
+{
+ return def();
+}
+
+int bar(void)
+{
+ return def();
+ return 0;
+}
+
+/*
+ * check-name: inline-return.c
+ * check-command: test-linearize -fdump-ir=linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-contains: ret\\..*\\$1
+ * check-output-excludes: ret\\..*\\$0
+ */
diff --git a/validation/linear/stray-phisrc.c b/validation/linear/stray-phisrc.c
new file mode 100644
index 00000000..e9f35c89
--- /dev/null
+++ b/validation/linear/stray-phisrc.c
@@ -0,0 +1,25 @@
+static int foo(int **g)
+{
+ int i = 1;
+ int *a[2];
+ int **p;
+
+ a[1] = &i;
+ if (g)
+ p = g;
+ else
+ p = &a[0];
+ p += 1; // will point to a[1] = &i
+ if (!g)
+ **p = 0;
+ return i;
+}
+
+/*
+ * check-name: stray phisrc
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-excludes: phisrc\\.
+ */
diff --git a/validation/mem2reg/address-used00.c b/validation/mem2reg/address-used00.c
new file mode 100644
index 00000000..f2d6c87b
--- /dev/null
+++ b/validation/mem2reg/address-used00.c
@@ -0,0 +1,19 @@
+int foo(int **g, int j)
+{
+ int i = 1;
+ int *a;
+ int **p;
+
+ a = &i;
+ p = &a;
+ *p[0] = 0;
+ return i;
+}
+
+/*
+ * check-name: address-used00
+ * check-command: test-linearize -Wno-decl -fdump-ir=final $file
+ * check-known-to-fail
+ * check-output-ignore
+ * check-output-excludes: ret\\..* \\$1
+ */
diff --git a/validation/mem2reg/broken-phi02.c b/validation/mem2reg/broken-phi02.c
new file mode 100644
index 00000000..69776e0f
--- /dev/null
+++ b/validation/mem2reg/broken-phi02.c
@@ -0,0 +1,28 @@
+int foo(int a, int b)
+{
+ int x;
+ int i;
+
+ if (a)
+ i = 0;
+ else
+ i = 1;
+
+ x = 0;
+ if (b)
+ x = i;
+ return x;
+}
+
+/*
+ * check-name: broken-phi02
+ * check-description:
+ * This is an indirect test to check correctness of phi-node placement.
+ * The misplaced phi-node for 'i' (not at the meet point but where 'i'
+ * is used) causes a missed select-conversion at later stage.
+ *
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ * check-output-ignore
+ * check-output-contains: select\\.
+ */
diff --git a/validation/mem2reg/broken-phi03.c b/validation/mem2reg/broken-phi03.c
new file mode 100644
index 00000000..58b47979
--- /dev/null
+++ b/validation/mem2reg/broken-phi03.c
@@ -0,0 +1,29 @@
+int foo(int a, int b)
+{
+ int x;
+ int i;
+
+ switch (a) {
+ case 0: i = 0; break;
+ case 1: i = 1; break;
+ default: i = -1; break;
+ }
+
+ x = 0;
+ if (b)
+ x = i;
+ return x;
+}
+
+/*
+ * check-name: broken-phi03
+ * check-description:
+ * This is an indirect test to check correctness of phi-node placement.
+ * The misplaced phi-node for 'i' (not at the meet point but where 'i'
+ * is used) causes a missed select-conversion at later stage.
+ *
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ * check-output-ignore
+ * check-output-contains: select\\.
+ */
diff --git a/validation/mem2reg/cond-expr.c b/validation/mem2reg/cond-expr.c
new file mode 100644
index 00000000..f38564ef
--- /dev/null
+++ b/validation/mem2reg/cond-expr.c
@@ -0,0 +1,13 @@
+int fun(int);
+
+int foo(int a, int b, int c)
+{
+ return a ? fun(b) : fun(c);
+}
+
+/*
+ * check-name: cond-expr
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-pattern(2): phi\\.
+ */
diff --git a/validation/mem2reg/cond-expr5.c b/validation/mem2reg/cond-expr5.c
new file mode 100644
index 00000000..6c1e1c34
--- /dev/null
+++ b/validation/mem2reg/cond-expr5.c
@@ -0,0 +1,18 @@
+int foo(int p, int q, int a)
+{
+ if (p)
+ a = 0;
+ if (q)
+ a = 1;
+
+ return a;
+}
+
+/*
+ * check-name: cond-expr5
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-excludes: load\\.
+ * check-output-excludes: store\\.
+ * check-output-pattern(2): phi\\.
+ */
diff --git a/validation/mem2reg/global-direct-undef.c b/validation/mem2reg/global-direct-undef.c
new file mode 100644
index 00000000..34960e74
--- /dev/null
+++ b/validation/mem2reg/global-direct-undef.c
@@ -0,0 +1,23 @@
+int a, c, d;
+
+int foo(void)
+{
+ int b, e;
+ if (a)
+ b = c;
+ else
+ b = d;
+ if (c)
+ a = b;
+ if (b)
+ e = a;
+ return e;
+}
+
+/*
+ * check-name: global direct undef
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-pattern(4,5): load\\.
+ * check-output-pattern(1): store\\.
+ */
diff --git a/validation/mem2reg/global-direct.c b/validation/mem2reg/global-direct.c
new file mode 100644
index 00000000..ea5d42dc
--- /dev/null
+++ b/validation/mem2reg/global-direct.c
@@ -0,0 +1,23 @@
+int a, c, d;
+
+int foo(void)
+{
+ int b, e = 0;
+ if (a)
+ b = c;
+ else
+ b = d;
+ if (c)
+ a = b;
+ if (b)
+ e = a;
+ return e;
+}
+
+/*
+ * check-name: global direct
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-pattern(4,5): load\\.
+ * check-output-pattern(1): store\\.
+ */
diff --git a/validation/mem2reg/global-loop.c b/validation/mem2reg/global-loop.c
new file mode 100644
index 00000000..a232f7ed
--- /dev/null
+++ b/validation/mem2reg/global-loop.c
@@ -0,0 +1,20 @@
+struct s {
+ int c;
+ int a[];
+} s;
+int f;
+
+void fun(void);
+void foo(void)
+{
+ for (f = 1;;)
+ if (s.a[f])
+ fun();
+}
+
+/*
+ * check-name: global var as loop index
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-contains: load\\..*\\[f\\]
+ */
diff --git a/validation/mem2reg/global-noalias.c b/validation/mem2reg/global-noalias.c
new file mode 100644
index 00000000..b78b5117
--- /dev/null
+++ b/validation/mem2reg/global-noalias.c
@@ -0,0 +1,21 @@
+int a, b, c, d, e;
+
+void foo(void)
+{
+ if (a)
+ b = c;
+ else
+ b = d;
+ if (c)
+ a = b;
+ if (b)
+ e = a;
+}
+
+/*
+ * check-name: global no-alias
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-pattern(4,7): load\\.
+ * check-output-pattern(4): store\\.
+ */
diff --git a/validation/mem2reg/global-pointer.c b/validation/mem2reg/global-pointer.c
new file mode 100644
index 00000000..d312577a
--- /dev/null
+++ b/validation/mem2reg/global-pointer.c
@@ -0,0 +1,26 @@
+int a, c, d;
+
+int foo_ptr(void)
+{
+ int b, *bp = &b;
+ int e, *ep = &e;
+
+ if (a)
+ *bp = c;
+ else
+ *bp = d;
+ if (c)
+ a = *bp;
+ if (b)
+ e = a;
+ return e;
+}
+
+/*
+ * check-name: global pointer
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-known-to-fail
+ * check-output-ignore
+ * check-output-pattern(4,5): load\\.
+ * check-output-pattern(3): store\\.
+ */
diff --git a/validation/mem2reg/if-direct.c b/validation/mem2reg/if-direct.c
new file mode 100644
index 00000000..1b5a07cc
--- /dev/null
+++ b/validation/mem2reg/if-direct.c
@@ -0,0 +1,19 @@
+int foo(int c, int a, int b)
+{
+ int l;
+
+ if (c)
+ l = a;
+ else
+ l = b;
+
+ return l;
+}
+
+/*
+ * check-name: if-then-else direct
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-excludes: load\\.
+ * check-output-contains: phi\\.
+ */
diff --git a/validation/mem2reg/if-pointer.c b/validation/mem2reg/if-pointer.c
new file mode 100644
index 00000000..acfceb71
--- /dev/null
+++ b/validation/mem2reg/if-pointer.c
@@ -0,0 +1,21 @@
+int foo(int c, int a, int b)
+{
+ int l, *p = &l;
+
+ if (c)
+ *p = a;
+ else
+ *p = b;
+
+ return l + *p;
+}
+
+/*
+ * check-name: if-then-else pointer
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-known-to-fail
+ * check-output-ignore
+ * check-output-excludes: load\\.
+ * check-output-excludes: store\\.
+ * check-output-contains: phi\\.
+ */
diff --git a/validation/mem2reg/init-global-array.c b/validation/mem2reg/init-global-array.c
new file mode 100644
index 00000000..aea4135a
--- /dev/null
+++ b/validation/mem2reg/init-global-array.c
@@ -0,0 +1,17 @@
+struct {
+ int a[2];
+} s;
+
+int sarray(void)
+{
+ s.a[1] = 1;
+ return s.a[1];
+}
+
+/*
+ * check-name: init global array
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-excludes: load\\.
+ * check-output-pattern(1): store\\.
+ */
diff --git a/validation/mem2reg/init-local-array.c b/validation/mem2reg/init-local-array.c
new file mode 100644
index 00000000..2ac53bc7
--- /dev/null
+++ b/validation/mem2reg/init-local-array.c
@@ -0,0 +1,25 @@
+int array(void)
+{
+ int a[2];
+
+ a[1] = 1;
+ return a[1];
+}
+
+int sarray(void)
+{
+ struct {
+ int a[2];
+ } s;
+
+ s.a[1] = 1;
+ return s.a[1];
+}
+
+/*
+ * check-name: init local array
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-excludes: load\\.
+ * check-output-excludes: store\\.
+ */
diff --git a/validation/mem2reg/init-local-union0.c b/validation/mem2reg/init-local-union0.c
new file mode 100644
index 00000000..3a57e781
--- /dev/null
+++ b/validation/mem2reg/init-local-union0.c
@@ -0,0 +1,18 @@
+double uintfloat(void)
+{
+ union {
+ int a;
+ double f;
+ } s;
+
+ s.a = 1;
+ return s.f;
+}
+
+/*
+ * check-name: init-local union 0
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-pattern(1): store\\.32
+ * check-output-pattern(1): load\\.64
+ */
diff --git a/validation/mem2reg/init-local-union1.c b/validation/mem2reg/init-local-union1.c
new file mode 100644
index 00000000..925b0a73
--- /dev/null
+++ b/validation/mem2reg/init-local-union1.c
@@ -0,0 +1,32 @@
+double uintfloat(void)
+{
+ union {
+ int a;
+ double f;
+ } s;
+
+ s.a = 1;
+ return s.f;
+}
+
+
+int uarray(void)
+{
+ union {
+ double d;
+ int a[2];
+ } s;
+
+ s.d = 1;
+ return s.a[0];
+}
+
+/*
+ * check-name: init-local union 1
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-pattern(1): store\\.32
+ * check-output-pattern(1): load\\.64
+ * check-output-pattern(1): store\\.64
+ * check-output-pattern(1): load\\.32
+ */
diff --git a/validation/mem2reg/init-local.c b/validation/mem2reg/init-local.c
new file mode 100644
index 00000000..d51c9247
--- /dev/null
+++ b/validation/mem2reg/init-local.c
@@ -0,0 +1,27 @@
+int ssimple(void)
+{
+ struct {
+ int a;
+ } s;
+
+ s.a = 1;
+ return s.a;
+}
+
+double sdouble(void)
+{
+ struct {
+ double a;
+ } s;
+
+ s.a = 1.23;
+ return s.a;
+}
+
+/*
+ * check-name: init-local
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-excludes: load\\.
+ * check-output-excludes: store\\.
+ */
diff --git a/validation/mem2reg/loop00.c b/validation/mem2reg/loop00.c
new file mode 100644
index 00000000..de33d9f6
--- /dev/null
+++ b/validation/mem2reg/loop00.c
@@ -0,0 +1,16 @@
+int loop00(int n)
+{
+ int i, r = 0;
+
+ for (i = 1; i <= n; ++i)
+ r += i;
+ return r;
+}
+
+/*
+ * check-name: loop00
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-excludes: store\\.
+ * check-output-excludes: load\\.
+ */
diff --git a/validation/mem2reg/loop01-global.c b/validation/mem2reg/loop01-global.c
new file mode 100644
index 00000000..b6798137
--- /dev/null
+++ b/validation/mem2reg/loop01-global.c
@@ -0,0 +1,18 @@
+extern int g;
+
+void fun(void);
+void loop01(void)
+{
+ int i;
+ for (i = 0; i <= 2;)
+ if (g)
+ fun();
+}
+
+/*
+ * check-name: loop01 global
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-excludes: load\\..*\\[i\\]
+ * check-output-contains: load\\..*\\[g\\]
+ */
diff --git a/validation/mem2reg/loop02-array.c b/validation/mem2reg/loop02-array.c
new file mode 100644
index 00000000..13b0aeaf
--- /dev/null
+++ b/validation/mem2reg/loop02-array.c
@@ -0,0 +1,23 @@
+
+
+int foo(int i[])
+{
+ int j = 1;
+ i[0] = 6;
+
+ do {
+ if (i[0] != 6)
+ i[0]++;
+ i[0]++;
+ } while (i[0] != j);
+
+ return j;
+}
+
+/*
+ * check-name: loop02 array
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-pattern(0,4): load\\.
+ * check-output-pattern(1,3): store\\.
+ */
diff --git a/validation/mem2reg/loop02-global.c b/validation/mem2reg/loop02-global.c
new file mode 100644
index 00000000..a0a8b42b
--- /dev/null
+++ b/validation/mem2reg/loop02-global.c
@@ -0,0 +1,22 @@
+int i;
+
+int foo(void)
+{
+ int j = 1;
+ i = 6;
+
+ do {
+ if (i != 6)
+ i++;
+ i++;
+ } while (i != j);
+
+ return j;
+}
+
+/*
+ * check-name: loop02 global
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-excludes: load\\.
+ */
diff --git a/validation/mem2reg/loop02-local.c b/validation/mem2reg/loop02-local.c
new file mode 100644
index 00000000..a1bd602b
--- /dev/null
+++ b/validation/mem2reg/loop02-local.c
@@ -0,0 +1,23 @@
+
+
+int foo(void)
+{
+ int j = 1;
+ int i = 6;
+
+ do {
+ if (i != 6)
+ i++;
+ i++;
+ } while (i != j);
+
+ return j;
+}
+
+/*
+ * check-name: loop02 pointer
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ *
+ * check-output-ignore
+ * check-output-excludes: load\\.
+ */
diff --git a/validation/mem2reg/loop02-pointer.c b/validation/mem2reg/loop02-pointer.c
new file mode 100644
index 00000000..fdb0a8fb
--- /dev/null
+++ b/validation/mem2reg/loop02-pointer.c
@@ -0,0 +1,23 @@
+
+
+int foo(int *i)
+{
+ int j = 1;
+ *i = 6;
+
+ do {
+ if (*i != 6)
+ (*i)++;
+ (*i)++;
+ } while (*i != j);
+
+ return j;
+}
+
+/*
+ * check-name: loop02 pointer
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-pattern(0,4): load\\.
+ * check-output-pattern(1,3): store\\.
+ */
diff --git a/validation/mem2reg/quadra00.c b/validation/mem2reg/quadra00.c
new file mode 100644
index 00000000..63b489c9
--- /dev/null
+++ b/validation/mem2reg/quadra00.c
@@ -0,0 +1,28 @@
+#define TEST(N) \
+ do { \
+ d = b + a[N]; \
+ if (d < b) \
+ c++; \
+ b = d; \
+ } while (0)
+
+int foo(int *a, int b, int c)
+{
+ int d;
+
+ TEST(0);
+ TEST(1);
+ TEST(2);
+
+ return d + c;
+}
+
+/*
+ * check-name: quadratic phisrc
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ * check-output-ignore
+ * check-output-excludes: phi\\..*, .*, .*
+ * check-output-excludes: phi\\..*, .*, .*, .*
+ * check-output-pattern(6): phisrc\\.
+ */
diff --git a/validation/mem2reg/short-load.c b/validation/mem2reg/short-load.c
new file mode 100644
index 00000000..c4b4dc4b
--- /dev/null
+++ b/validation/mem2reg/short-load.c
@@ -0,0 +1,29 @@
+#ifdef __SIZEOF_INT__ == 4
+typedef unsigned int u32;
+#endif
+#ifdef __SIZEOF_SHORT__ == 2
+typedef unsigned short u16;
+#endif
+
+
+union u {
+ u32 a;
+ u16 b;
+};
+
+void bar(u16, union u);
+
+void foo(u16 val)
+{
+ union u u;
+
+ u.b = val;
+ bar(u.b, u);
+}
+
+/*
+ * check-name: short-load
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-contains: load\\.32
+ */
diff --git a/validation/mem2reg/undef00.c b/validation/mem2reg/undef00.c
new file mode 100644
index 00000000..ba9ba915
--- /dev/null
+++ b/validation/mem2reg/undef00.c
@@ -0,0 +1,14 @@
+void bad0(void)
+{
+ int *a;
+ *a++;
+}
+
+/*
+ * check-name: undef00
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-known-to-fail
+ * check-output-ignore
+ * check-output-pattern(1): load\\.
+ * check-output-pattern(1): load\\..*\\[UNDEF\\]
+ */
diff --git a/validation/mem2reg/volatile-store00.c b/validation/mem2reg/volatile-store00.c
new file mode 100644
index 00000000..d565037a
--- /dev/null
+++ b/validation/mem2reg/volatile-store00.c
@@ -0,0 +1,27 @@
+void foo(volatile int *p)
+{
+ *p = 0;
+ *p = 0;
+}
+
+void bar(void)
+{
+ extern volatile int i;
+ i = 0;
+ i = 0;
+}
+
+
+void baz(void)
+{
+ volatile int i;
+ i = 0;
+ i = 0;
+}
+
+/*
+ * check-name: keep volatile stores
+ * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file
+ * check-output-ignore
+ * check-output-pattern(1,6): store\\.
+ */
diff --git a/validation/missing-return.c b/validation/missing-return.c
new file mode 100644
index 00000000..b6ee75ef
--- /dev/null
+++ b/validation/missing-return.c
@@ -0,0 +1,20 @@
+int foo(int a)
+{
+}
+
+int bar(int a)
+{
+ if (a)
+ return 0;
+}
+
+/*
+ * check-name: missing return
+ * check-command: sparse -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-error-start
+missing-return.c:3:1: warning: control reaches end of non-void function
+missing-return.c:9:1: warning: control reaches end of non-void function
+ * check-error-end
+ */
diff --git a/validation/multi-input.c b/validation/multi-input.c
new file mode 100644
index 00000000..2443d49f
--- /dev/null
+++ b/validation/multi-input.c
@@ -0,0 +1,11 @@
+int a = 1;
+int foo(void) {}
+
+static int b = 1;
+static int bar(void) {}
+
+/*
+ * check-name: multi-input
+ * check-command: sparse -Wno-decl $file $file
+ * check-known-to-fail
+ */
diff --git a/validation/optim/missing-select.c b/validation/optim/missing-select.c
new file mode 100644
index 00000000..4796e058
--- /dev/null
+++ b/validation/optim/missing-select.c
@@ -0,0 +1,24 @@
+static int foo(int **g)
+{
+ int i = 1;
+ int *a[2];
+ int **p;
+
+ a[1] = &i;
+ if (g)
+ p = g;
+ else
+ p = &a[0];
+ if (!g)
+ **p = 0;
+ return i;
+}
+
+/*
+ * check-name: missing-select
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: select\\.
+ */
diff --git a/validation/optim/volatile-store00.c b/validation/optim/volatile-store00.c
new file mode 100644
index 00000000..451eefa1
--- /dev/null
+++ b/validation/optim/volatile-store00.c
@@ -0,0 +1,27 @@
+void foo(volatile int *p)
+{
+ *p = 0;
+ *p = 0;
+}
+
+void bar(void)
+{
+ extern volatile int i;
+ i = 0;
+ i = 0;
+}
+
+
+void baz(void)
+{
+ volatile int i;
+ i = 0;
+ i = 0;
+}
+
+/*
+ * check-name: keep volatile stores
+ * check-command: test-linearize -Wno-decl -fdump-ir=final $file
+ * check-output-ignore
+ * check-output-pattern(6): store\\.
+ */
diff --git a/validation/overflow.c b/validation/overflow.c
new file mode 100644
index 00000000..c2655e32
--- /dev/null
+++ b/validation/overflow.c
@@ -0,0 +1,19 @@
+extern int a;
+
+int a = __INT_MAX__ * 2;
+
+int foo(void)
+{
+ return __INT_MAX__ * 2;
+}
+
+/*
+ * check-name: overflow
+ * check-command: sparse -Wno-decl $file
+ *
+ * check-known-to-fail
+ * check-error-start
+bug-overflow.c:3:21: warning: integer overflow in expression
+bug-overflow.c:7:28: warning: integer overflow in expression
+ * check-error-end
+ */
diff --git a/validation/preprocessor/extra-token.c b/validation/preprocessor/extra-token.c
new file mode 100644
index 00000000..50a853c5
--- /dev/null
+++ b/validation/preprocessor/extra-token.c
@@ -0,0 +1,15 @@
+#define THIS 0
+#ifdef THIS == 1
+#endif
+
+/*
+ * check-name: preprocessor/extra-token.c
+ * check-command: sparse -E $file
+ * check-known-to-fail
+ *
+ * check-error-start
+preprocessor/extra-token.c:2:13: warning: extra tokens at end of #ifdef directive
+ * check-error-end
+ *
+ * check-output-ignore
+ */
diff --git a/validation/sizeof-incomplete-type.c b/validation/sizeof-incomplete-type.c
new file mode 100644
index 00000000..9fba00b3
--- /dev/null
+++ b/validation/sizeof-incomplete-type.c
@@ -0,0 +1,27 @@
+struct s {
+ char a;
+ char b[sizeof(struct s)];
+ char c;
+ char d[sizeof(struct s)];
+ int j:sizeof(struct s);
+};
+
+static int array[] = {
+ [0] = 0,
+ [sizeof(array)] = 1,
+ [2] = 0,
+ [sizeof(array)] = 2,
+};
+
+/*
+ * check-name: sizeof incomplete type
+ *
+ * check-known-to-fail
+ * check-error-start
+sizeof-incomplete-type.c:3:16: error: invalid application of 'sizeof' to incomplete type 'struct s'
+sizeof-incomplete-type.c:5:16: error: invalid application of 'sizeof' to incomplete type 'struct s'
+sizeof-incomplete-type.c:6:16: error: invalid application of 'sizeof' to incomplete type 'struct s'
+sizeof-incomplete-type.c:11:17: error: invalid application of 'sizeof' to incomplete type 'int[]'
+sizeof-incomplete-type.c:13:17: error: invalid application of 'sizeof' to incomplete type 'int[]'
+ * check-error-end
+ */
diff --git a/validation/storage-struct-member.c b/validation/storage-struct-member.c
new file mode 100644
index 00000000..6bd958ab
--- /dev/null
+++ b/validation/storage-struct-member.c
@@ -0,0 +1,20 @@
+int foo(a)
+ register int a;
+{
+ return a;
+}
+
+struct s {
+ register int a;
+};
+
+/*
+ * check-name: storage in struct member
+ * check-command: sparse -Wno-decl $file
+ *
+ * check-known-to-fail
+ * check-error-start
+storage-struct-member.c:2:9: warning: non-ANSI definition of function 'foo'
+storage-struct-member.c:8:9: error: storage specifier in structure definition'
+ * check-error-end
+ */
diff --git a/validation/var-undef-partial.c b/validation/var-undef-partial.c
new file mode 100644
index 00000000..2b665834
--- /dev/null
+++ b/validation/var-undef-partial.c
@@ -0,0 +1,21 @@
+int foo(int a, int b)
+{
+ int var = 0;
+ int r;
+
+ if (a)
+ var = 1;
+ if (b)
+ r = var;
+
+ return r; // undef if !b
+}
+
+/*
+ * check-name: variable partially undefined
+ * check-description: trigger a bug in symbol/memop simplification
+ * check-description: sparse-llvm is used here as semantic checker of sparse's IR
+ * check-command: sparse-llvm -Wno-decl $file
+ * check-known-to-fail
+ * check-output-ignore
+ */
diff --git a/validation/vla-sizeof.c b/validation/vla-sizeof.c
new file mode 100644
index 00000000..43079992
--- /dev/null
+++ b/validation/vla-sizeof.c
@@ -0,0 +1,37 @@
+unsigned long vla_sizeof0(int size)
+{
+ int a[size];
+ return sizeof(a);
+}
+
+unsigned long vla_sizeof1(int size)
+{
+ struct s {
+ int a[size];
+ };
+ return sizeof(struct s);
+}
+
+unsigned long vla_sizeof2(int size)
+{
+ struct s {
+ int a[size];
+ } *p;
+ return sizeof(*p);
+}
+
+void* vla_inc(int size, void *base)
+{
+ struct s {
+ int a[size];
+ } *p = base;
+
+ ++p;
+ return p;
+}
+
+/*
+ * check-name: vla-sizeof.c
+ *
+ * check-known-to-fail
+ */