[PATCH] add test case bug expand union

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

 



constant_symbol_value() needs several conditions before returning
a valid value.

However not all conditions are always met. One such case occurs when
an union is involved and the value we look after is of a different
type than the initializer.

Add two test cases showing (some of) the problems.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/bug-expand-union0.c | 21 +++++++++++++++++++++
 validation/bug-expand-union1.c | 20 ++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 validation/bug-expand-union0.c
 create mode 100644 validation/bug-expand-union1.c

diff --git a/validation/bug-expand-union0.c b/validation/bug-expand-union0.c
new file mode 100644
index 000000000..dd6d60c3e
--- /dev/null
+++ b/validation/bug-expand-union0.c
@@ -0,0 +1,21 @@
+union u {
+	char c;
+	float f;
+};
+
+static int foo(void)
+{
+	union u u = { .f = 0.123 };
+	return u.c;
+}
+
+/*
+ * check-name: bug-expand-union
+ * check description: must not infer the value from the float
+ * check-command: test-linearize $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: load\\.
+ * check-output-excludes: ret\\..*\\$
+ */
diff --git a/validation/bug-expand-union1.c b/validation/bug-expand-union1.c
new file mode 100644
index 000000000..582a1f4f8
--- /dev/null
+++ b/validation/bug-expand-union1.c
@@ -0,0 +1,20 @@
+union u {
+	int i;
+	float f;
+};
+
+static int foo(void)
+{
+	union u u = { .f = 0.123 };
+	return u.i;
+}
+
+/*
+ * check-name: bug-expand-union
+ * check description: must not infer the value from the float
+ * check-command: test-linearize $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: load\\.
+ */
-- 
2.16.3

--
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