diff mbox

[1/3] add testcase for typedef redefinition

Message ID 20180415091807.23039-2-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show

Commit Message

Luc Van Oostenryck April 15, 2018, 9:18 a.m. UTC
Currently, sparse doesn't issue a diagnostic when a typedef
is redefined.

Add some testcases for this.

Reported-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 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 mbox

Patch

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
+ */