[PATCH 11/15] add test case for compound literals

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/compound-literal00.c | 18 ++++++++++++++++++
 validation/compound-literal01.c | 27 +++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 validation/compound-literal00.c
 create mode 100644 validation/compound-literal01.c

diff --git a/validation/compound-literal00.c b/validation/compound-literal00.c
new file mode 100644
index 000000000..f3069d2ca
--- /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 000000000..8a4935ea7
--- /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
+ */
-- 
2.14.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux