This is in response to the following "continue statement of death"
report:

https://www.mail-archive.com/cocci@systeme.lip6.fr/msg06199.html

Coccinelle would crash in similar cases, so add a test case for it.

Signed-off-by: Jaskaran Singh <jaskaransingh7654...@gmail.com>
---
 tests/stmt_removed_and_added.c     | 8 ++++++++
 tests/stmt_removed_and_added.cocci | 7 +++++++
 tests/stmt_removed_and_added.res   | 8 ++++++++
 3 files changed, 23 insertions(+)
 create mode 100644 tests/stmt_removed_and_added.c
 create mode 100644 tests/stmt_removed_and_added.cocci
 create mode 100644 tests/stmt_removed_and_added.res

diff --git a/tests/stmt_removed_and_added.c b/tests/stmt_removed_and_added.c
new file mode 100644
index 00000000..cbc64f42
--- /dev/null
+++ b/tests/stmt_removed_and_added.c
@@ -0,0 +1,8 @@
+void main()
+{
+       for(i; j; k) {
+               if (1)
+                       continue;
+               c++;
+       }
+}
diff --git a/tests/stmt_removed_and_added.cocci 
b/tests/stmt_removed_and_added.cocci
new file mode 100644
index 00000000..93558a19
--- /dev/null
+++ b/tests/stmt_removed_and_added.cocci
@@ -0,0 +1,7 @@
+@@
+expression I, J, K;
+statement S;
+@@
+
+- for (I; J; K) S
++ while(1) S
diff --git a/tests/stmt_removed_and_added.res b/tests/stmt_removed_and_added.res
new file mode 100644
index 00000000..4b20027a
--- /dev/null
+++ b/tests/stmt_removed_and_added.res
@@ -0,0 +1,8 @@
+void main()
+{
+       while (1) {
+               if (1)
+                       continue;
+               c++;
+       }
+}
-- 
2.21.0

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to