[PATCH 1/5] unqual: add testcases

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

 



Add some testcases related to qualifier dropping / lvalue conversion.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/eval/unqual-comma.c     | 13 +++++++++++++
 validation/eval/unqual-postop.c    | 23 +++++++++++++++++++++++
 validation/eval/unqual-stmt-expr.c | 13 +++++++++++++
 validation/eval/unqual02.c         | 26 ++++++++++++++++++++++++++
 4 files changed, 75 insertions(+)
 create mode 100644 validation/eval/unqual-comma.c
 create mode 100644 validation/eval/unqual-postop.c
 create mode 100644 validation/eval/unqual-stmt-expr.c
 create mode 100644 validation/eval/unqual02.c

diff --git a/validation/eval/unqual-comma.c b/validation/eval/unqual-comma.c
new file mode 100644
index 000000000000..e06586cd43e3
--- /dev/null
+++ b/validation/eval/unqual-comma.c
@@ -0,0 +1,13 @@
+#define __unqual_typeof(x) typeof(((void)0, (x)))
+
+int *foo(volatile int x);
+int *foo(volatile int x)
+{
+	extern __unqual_typeof(x) y;
+	return &y;
+}
+
+/*
+ * check-name: unqual-comma
+ * check-known-to-fail
+ */
diff --git a/validation/eval/unqual-postop.c b/validation/eval/unqual-postop.c
new file mode 100644
index 000000000000..fb3082dc8836
--- /dev/null
+++ b/validation/eval/unqual-postop.c
@@ -0,0 +1,23 @@
+static void test_volatile(void)
+{
+	volatile int x = 0;
+	int *pp;
+
+	typeof(++x)		v1; pp = &v1;	// KO
+	typeof(x++)		v2; pp = &v2;	// KO
+}
+
+/*
+ * check-name: unqual-postop
+ * check-command: sparse -Wno-declaration-after-statement $file
+ * check-known-to-fail
+ *
+ * check-error-start
+eval/unqual-postop.c:6:40: warning: incorrect type in assignment (different modifiers)
+eval/unqual-postop.c:6:40:    expected int *pp
+eval/unqual-postop.c:6:40:    got int volatile *
+eval/unqual-postop.c:7:40: warning: incorrect type in assignment (different modifiers)
+eval/unqual-postop.c:7:40:    expected int *pp
+eval/unqual-postop.c:7:40:    got int volatile *
+ * check-error-end
+ */
diff --git a/validation/eval/unqual-stmt-expr.c b/validation/eval/unqual-stmt-expr.c
new file mode 100644
index 000000000000..bac6cb6b197f
--- /dev/null
+++ b/validation/eval/unqual-stmt-expr.c
@@ -0,0 +1,13 @@
+#define __unqual_typeof(x) typeof(({ x; }))
+
+int *foo(volatile int x);
+int *foo(volatile int x)
+{
+	extern __unqual_typeof(x) y;
+	return &y;
+}
+
+/*
+ * check-name: unqual-stmt-expr
+ * check-known-to-fail
+ */
diff --git a/validation/eval/unqual02.c b/validation/eval/unqual02.c
new file mode 100644
index 000000000000..f136cbd50510
--- /dev/null
+++ b/validation/eval/unqual02.c
@@ -0,0 +1,26 @@
+static void test_const(volatile int x)
+{
+	const int x = 0;
+	typeof(1?x:x)		i3; i3 = 0;	// should be OK
+	typeof(+x)		i4; i4 = 0;	// should be OK
+	typeof(-x)		i5; i5 = 0;	// should be OK
+	typeof(!x)		i6; i6 = 0;	// should be OK
+	typeof(x+x)		i7; i7 = 0;	// should be OK
+}
+
+static void test_volatile(void)
+{
+	volatile int x = 0;
+	int *pp;
+
+	typeof(1?x:x)		i3; pp = &i3;	// should be OK
+	typeof(+x)		i4; pp = &i4;	// should be OK
+	typeof(-x)		i5; pp = &i5;	// should be OK
+	typeof(!x)		i6; pp = &i6;	// should be OK
+	typeof(x+x)		i7; pp = &i7;	// should be OK
+}
+
+/*
+ * check-name: unqual02
+ * check-command: sparse -Wno-declaration-after-statement $file
+ */
-- 
2.29.2




[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