[PATCH 1/3] add testcase for typedef redefinition

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

 



Currently, sparse doesn't issue a diagnostic when a typedef
is redefined.

Add some testcases for this.

Reported-by: Matthew Wilcox <willy@xxxxxxxxxxxxx>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/typedef-redef-c89.c | 13 +++++++++++++
 validation/typedef-redef.c     | 14 ++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 validation/typedef-redef-c89.c
 create mode 100644 validation/typedef-redef.c

diff --git a/validation/typedef-redef-c89.c b/validation/typedef-redef-c89.c
new file mode 100644
index 000000000..6d4dc28c1
--- /dev/null
+++ b/validation/typedef-redef-c89.c
@@ -0,0 +1,13 @@
+typedef int int_t;
+typedef int int_t;
+
+/*
+ * check-name: typedef-redef-c89
+ * check-command: sparse -std=c89 --pedantic $file
+ * check-known-to-fail
+ *
+ * check-error-start
+typedef-redef-c89.c:2:13: warning: redefinition of typedef 'int_t'
+typedef-redef-c89.c:1:13: info: originally defined here
+ * check-error-end
+ */
diff --git a/validation/typedef-redef.c b/validation/typedef-redef.c
new file mode 100644
index 000000000..b719ff9a4
--- /dev/null
+++ b/validation/typedef-redef.c
@@ -0,0 +1,14 @@
+typedef int  ok_t;
+typedef int  ok_t;
+
+typedef int  ko_t;
+typedef long ko_t;
+
+/*
+ * check-name: typedef-redef
+ * check-known-to-fail
+ *
+ * check-error-start
+typedef-redef.c:5:14: error: symbol 'ko_t' redeclared with different type (originally declared at typedef-redef.c:4) - different type sizes
+ * check-error-end
+ */
-- 
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