[PATCH 05/17] add test for union cast

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

 



Sparse can't do this yet.
So, add a testcase for it.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/expand/union-cast.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 validation/expand/union-cast.c

diff --git a/validation/expand/union-cast.c b/validation/expand/union-cast.c
new file mode 100644
index 000000000000..a28d01f22b92
--- /dev/null
+++ b/validation/expand/union-cast.c
@@ -0,0 +1,27 @@
+union u {
+	int i;
+	struct s {
+		int a;
+	} s;
+};
+
+int foo(void)
+{
+	struct s s = { 3 };
+	union u u = (union u)s;
+	return u.s.a;
+}
+
+/*
+ * check-name: union-cast
+ * check-command: test-linearize -Wno-decl -fdump-ir $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-excludes: load\\.
+ *
+ * check-error-start
+union-cast.c:11:22: warning: cast to non-scalar
+union-cast.c:11:22: warning: cast from non-scalar
+ * check-error-end
+ */
-- 
2.24.0




[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