aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/linear
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-04-12 09:26:22 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-05-21 17:27:45 +0200
commit633a390c169082646e7172c753f319568ef22695 (patch)
tree77b6196e9d4175a006684ceb0627a3fa12e5c625 /validation/linear
parent0b6d161ed1cc0f2226482d64c56fe9dc89bc0ebf (diff)
downloadsparse-dev-633a390c169082646e7172c753f319568ef22695.tar.gz
bad-goto: reorganize testcases and add some more
Reorganize the testcases related to the 'scope' of labels and add a few new ones. Also, some related testcases have some unreported errors other than the features being tested. This is a problem since such tescases can still fail after the feature being tested is fixed or implemented. So, fix these testcases or split them so that they each test a unique feature. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/linear')
-rw-r--r--validation/linear/goto-invalid.c (renamed from validation/linear/invalid-labels0.c)4
-rw-r--r--validation/linear/goto-stmt-expr-conditional.c (renamed from validation/linear/goto-and-expr-stmt0.c)4
-rw-r--r--validation/linear/goto-stmt-expr-short-circuit.c32
-rw-r--r--validation/linear/label-scope-cgoto.c11
-rw-r--r--validation/linear/label-stmt-dropped.c26
-rw-r--r--validation/linear/label-stmt-expr0.c17
-rw-r--r--validation/linear/label-unreachable.c (renamed from validation/linear/unreachable-label0.c)3
7 files changed, 92 insertions, 5 deletions
diff --git a/validation/linear/invalid-labels0.c b/validation/linear/goto-invalid.c
index ae3bf728..569d0b0d 100644
--- a/validation/linear/invalid-labels0.c
+++ b/validation/linear/goto-invalid.c
@@ -9,11 +9,11 @@ void bar(void)
}
/*
- * check-name: invalid-labels0
+ * check-name: goto-invalid
* check-command: test-linearize -Wno-decl $file
* check-known-to-fail
*
+ * check-error-ignore
* check-output-ignore
* check-output-excludes: END
- * check-error-ignore
*/
diff --git a/validation/linear/goto-and-expr-stmt0.c b/validation/linear/goto-stmt-expr-conditional.c
index 54881353..6576052b 100644
--- a/validation/linear/goto-and-expr-stmt0.c
+++ b/validation/linear/goto-stmt-expr-conditional.c
@@ -18,11 +18,11 @@ a:
}
/*
- * check-name: goto-and-expr-stmt0
+ * check-name: goto-stmt-expr-conditional
* check-command: test-linearize -Wno-decl $file
* check-known-to-fail
*
+ * check-error-ignore
* check-output-ignore
* check-output-excludes: END
- * check-error-ignore
*/
diff --git a/validation/linear/goto-stmt-expr-short-circuit.c b/validation/linear/goto-stmt-expr-short-circuit.c
new file mode 100644
index 00000000..426315e6
--- /dev/null
+++ b/validation/linear/goto-stmt-expr-short-circuit.c
@@ -0,0 +1,32 @@
+int foo(int p)
+{
+ goto inside;
+ if (0 && ({
+inside:
+ return 1;
+ 2;
+ }))
+ return 3;
+ return 4;
+}
+
+int bar(int p)
+{
+ if (0 && ({
+inside:
+ return 1;
+ 2;
+ }))
+ return 3;
+ goto inside;
+}
+
+/*
+ * check-name: goto-stmt-expr-short-circuit
+ * check-command: test-linearize -Wno-decl $file
+ * check-known-to-fail
+ *
+ * check-error-ignore
+ * check-output-ignore
+ * check-output-excludes: END
+ */
diff --git a/validation/linear/label-scope-cgoto.c b/validation/linear/label-scope-cgoto.c
new file mode 100644
index 00000000..592f1ce4
--- /dev/null
+++ b/validation/linear/label-scope-cgoto.c
@@ -0,0 +1,11 @@
+#include <label-scope-cgoto.c>
+
+/*
+ * check-name: linear/label-scope-cgoto
+ * check-command: test-linearize -Wno-decl -I. $file
+ * check-known-to-fail
+ *
+ * check-error-ignore
+ * check-output-ignore
+ * check-output-excludes: END
+ */
diff --git a/validation/linear/label-stmt-dropped.c b/validation/linear/label-stmt-dropped.c
new file mode 100644
index 00000000..74e0f2e6
--- /dev/null
+++ b/validation/linear/label-stmt-dropped.c
@@ -0,0 +1,26 @@
+/*
+ * Verify that the statement following an unused label
+ * is not discarded with the label.
+ */
+
+static int bad(int a, int b)
+{
+ int r = 0;
+
+start:
+ r += a;
+ r += b;
+
+ if (!r)
+ goto start;
+ return r;
+}
+
+/*
+ * check-name: label-stmt-dropped
+ * check-command: test-linearize $file
+ *
+ * check-output-ignore
+ * check-output-contains: add
+ * check-output-contains: %arg1
+ */
diff --git a/validation/linear/label-stmt-expr0.c b/validation/linear/label-stmt-expr0.c
new file mode 100644
index 00000000..ff3c0980
--- /dev/null
+++ b/validation/linear/label-stmt-expr0.c
@@ -0,0 +1,17 @@
+int foo(void);
+int foo(void)
+{
+ int r;
+
+ r = ({ goto label; label: 1; });
+ return r;
+}
+
+/*
+ * check-name: label-stmt-expr0
+ * check-command: test-linearize $file
+ * check-output-ignore
+ *
+ * check-output-excludes: ret\\.32\$
+ * check-output-contains: ret\\.32 *\\$1
+ */
diff --git a/validation/linear/unreachable-label0.c b/validation/linear/label-unreachable.c
index 695e5cb0..a44e1211 100644
--- a/validation/linear/unreachable-label0.c
+++ b/validation/linear/label-unreachable.c
@@ -10,9 +10,10 @@ label:
}
/*
- * check-name: unreachable-label0
+ * check-name: label-unreachable
* check-command: test-linearize $file
*
+ * check-error-ignore
* check-output-ignore
* check-output-contains: ret\\.
* check-output-excludes: END