aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/linear
diff options
Diffstat (limited to 'validation/linear')
-rw-r--r--validation/linear/asm-toplevel.c7
-rw-r--r--validation/linear/missing-return0.c10
-rw-r--r--validation/linear/missing-return1.c15
-rw-r--r--validation/linear/missing-return2.c11
-rw-r--r--validation/linear/missing-return3.c18
-rw-r--r--validation/linear/missing-return4.c14
-rw-r--r--validation/linear/missing-return5.c23
-rw-r--r--validation/linear/unreachable-label0.c19
8 files changed, 117 insertions, 0 deletions
diff --git a/validation/linear/asm-toplevel.c b/validation/linear/asm-toplevel.c
new file mode 100644
index 00000000..8bdd7fc1
--- /dev/null
+++ b/validation/linear/asm-toplevel.c
@@ -0,0 +1,7 @@
+__asm__("/* nothing */");
+/*
+ * check-name: asm-toplevel.c
+ * check-command: test-linearize $file
+ * check-output-ignore
+ * check-output-contains: asm *".. nothing .."
+ */
diff --git a/validation/linear/missing-return0.c b/validation/linear/missing-return0.c
new file mode 100644
index 00000000..77ab5abd
--- /dev/null
+++ b/validation/linear/missing-return0.c
@@ -0,0 +1,10 @@
+static int foo(int a)
+{
+ if (a)
+ return 1;
+}
+
+/*
+ * check-name: missing-return0
+ * check-command: sparse -vir -flinearize=last $file
+ */
diff --git a/validation/linear/missing-return1.c b/validation/linear/missing-return1.c
new file mode 100644
index 00000000..4a8a9517
--- /dev/null
+++ b/validation/linear/missing-return1.c
@@ -0,0 +1,15 @@
+static inline int fun(int a)
+{
+ if (a)
+ return 1;
+}
+
+static int foo(int a)
+{
+ return fun(a);
+}
+
+/*
+ * check-name: missing-return1
+ * check-command: sparse -vir -flinearize=last $file
+ */
diff --git a/validation/linear/missing-return2.c b/validation/linear/missing-return2.c
new file mode 100644
index 00000000..395dcc14
--- /dev/null
+++ b/validation/linear/missing-return2.c
@@ -0,0 +1,11 @@
+static int foo(int a)
+{
+ switch (a)
+ case 3:
+ return 4;
+}
+
+/*
+ * check-name: missing-return2
+ * check-command: sparse -vir -flinearize=last $file
+ */
diff --git a/validation/linear/missing-return3.c b/validation/linear/missing-return3.c
new file mode 100644
index 00000000..b32e5eea
--- /dev/null
+++ b/validation/linear/missing-return3.c
@@ -0,0 +1,18 @@
+static int foo(int a)
+{
+ if (a)
+ return;
+}
+
+static void ref(void)
+{
+}
+
+/*
+ * check-name: missing-return3
+ * check-command: sparse -vir -flinearize=last $file
+ *
+ * check-error-start
+linear/missing-return3.c:4:17: error: return with no return value
+ * check-error-end
+ */
diff --git a/validation/linear/missing-return4.c b/validation/linear/missing-return4.c
new file mode 100644
index 00000000..779893a0
--- /dev/null
+++ b/validation/linear/missing-return4.c
@@ -0,0 +1,14 @@
+static int foo(int a)
+{
+ int r = a;
+ r;
+}
+
+/*
+ * check-name: missing-return4
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-error-ignore
+ * check-output-ignore
+ * check-output-contains: ret\\..*UNDEF
+ */
diff --git a/validation/linear/missing-return5.c b/validation/linear/missing-return5.c
new file mode 100644
index 00000000..e5504a19
--- /dev/null
+++ b/validation/linear/missing-return5.c
@@ -0,0 +1,23 @@
+int foo(int p)
+{
+ if (p)
+ return 0;
+}
+
+int bar(int p)
+{
+ if (p)
+ return 0;
+ p++;
+}
+
+/*
+ * check-name: missing/undef return
+ * check-command: test-linearize -Wno-decl -fdump-ir=linearize $file
+ *
+ * check-output-ignore
+ * check-output-pattern(2): phi\\..*,.*
+ * check-output-pattern(2): phisrc\\..*\\$0
+ * check-output-pattern(2): phisrc\\..*UNDEF
+ * check-output-excludes: ret\\..*\\$0
+ */
diff --git a/validation/linear/unreachable-label0.c b/validation/linear/unreachable-label0.c
new file mode 100644
index 00000000..695e5cb0
--- /dev/null
+++ b/validation/linear/unreachable-label0.c
@@ -0,0 +1,19 @@
+static int foo(int a)
+{
+ goto label;
+ switch(a) {
+ default:
+label:
+ break;
+ }
+ return 0;
+}
+
+/*
+ * check-name: unreachable-label0
+ * check-command: test-linearize $file
+ *
+ * check-output-ignore
+ * check-output-contains: ret\\.
+ * check-output-excludes: END
+ */