[PATCH 1/2] add test for evaluation of invalid assignments

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

 



Due to the way compatible_assignment_types()'s handle type
incompatibilities and how expression with an invalid type
are nevertheless processed by linearize_expression(), some
invalid assignments retunr unwanted error messages (and
working around them can create some others).

Here are 2 relatively simple tests triggering the situation.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/eval-bad-assign1.c | 15 +++++++++++++++
 validation/eval-bad-assign2.c | 22 ++++++++++++++++++++++
 2 files changed, 37 insertions(+)
 create mode 100644 validation/eval-bad-assign1.c
 create mode 100644 validation/eval-bad-assign2.c

diff --git a/validation/eval-bad-assign1.c b/validation/eval-bad-assign1.c
new file mode 100644
index 000000000..bce4d3d38
--- /dev/null
+++ b/validation/eval-bad-assign1.c
@@ -0,0 +1,15 @@
+static void kos(int *r, int a)
+{
+	r = ({ __builtin_types_compatible_p(int, int); });
+}
+
+/*
+ * check-name: eval-bad-assign1
+ * check-known-to-fail
+ *
+ * check-error-start
+eval-bad-assign1.c:3:11: warning: incorrect type in assignment (different base types)
+eval-bad-assign1.c:3:11:    expected int *r
+eval-bad-assign1.c:3:11:    got int
+ * check-error-end
+ */
diff --git a/validation/eval-bad-assign2.c b/validation/eval-bad-assign2.c
new file mode 100644
index 000000000..4d08cb907
--- /dev/null
+++ b/validation/eval-bad-assign2.c
@@ -0,0 +1,22 @@
+struct s {
+	char c[1];
+};
+
+struct s fun(void);
+
+
+static void foo(void)
+{
+	char c[1];
+	c = fun().c;
+}
+
+/*
+ * check-name: eval-bad-assign2
+ *
+ * check-error-start
+eval-bad-assign2.c:11:11: warning: incorrect type in assignment (invalid types)
+eval-bad-assign2.c:11:11:    expected char c[1]
+eval-bad-assign2.c:11:11:    got char *
+ * check-error-end
+ */
-- 
2.23.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