aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-02-21 01:38:24 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-05-01 16:29:22 +0200
commit5ae9f08e7ae1de633ab1936062b58a51ea4c3c5c (patch)
treee1d2293f1569c953d1421da8b6ccd9f23f9ccdaa
parent8d5d4cef846d7120fbaffc3ee78e796c582bc890 (diff)
downloadsparse-dev-5ae9f08e7ae1de633ab1936062b58a51ea4c3c5c.tar.gz
add testcase for typedef redefinition
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>
-rw-r--r--validation/typedef-redef-c89.c13
-rw-r--r--validation/typedef-redef.c14
2 files changed, 27 insertions, 0 deletions
diff --git a/validation/typedef-redef-c89.c b/validation/typedef-redef-c89.c
new file mode 100644
index 00000000..6d4dc28c
--- /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 00000000..b719ff9a
--- /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
+ */