summaryrefslogtreecommitdiff
path: root/regress/usr.bin/xlint
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2006-05-05 20:02:12 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2006-05-05 20:02:12 +0000
commit05073aa4a229b774efd26755d5b7d55d80a5f6a9 (patch)
tree7f3c7526424c5980cb7f47b187c321db468a2a50 /regress/usr.bin/xlint
parentb13853901a1ffc2e1d3686eaef4f6731037f19d5 (diff)
test pointer casts
Diffstat (limited to 'regress/usr.bin/xlint')
-rw-r--r--regress/usr.bin/xlint/Makefile5
-rw-r--r--regress/usr.bin/xlint/test-23.c65
-rw-r--r--regress/usr.bin/xlint/test-23.c.exp17
3 files changed, 85 insertions, 2 deletions
diff --git a/regress/usr.bin/xlint/Makefile b/regress/usr.bin/xlint/Makefile
index 110509395ff..8e1994580e0 100644
--- a/regress/usr.bin/xlint/Makefile
+++ b/regress/usr.bin/xlint/Makefile
@@ -1,6 +1,7 @@
-# $OpenBSD: Makefile,v 1.25 2006/05/03 18:45:25 cloder Exp $
+# $OpenBSD: Makefile,v 1.26 2006/05/05 20:02:11 otto Exp $
-TEST_MODULES= 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 22
+TEST_MODULES= 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 22 \
+ 23
LINT= lint
LINTFLAGS?= -chabx
diff --git a/regress/usr.bin/xlint/test-23.c b/regress/usr.bin/xlint/test-23.c
new file mode 100644
index 00000000000..ae88f440f79
--- /dev/null
+++ b/regress/usr.bin/xlint/test-23.c
@@ -0,0 +1,65 @@
+/* $OpenBSD: test-23.c,v 1.1 2006/05/05 20:02:11 otto Exp $ */
+
+/*
+ * Placed in the public domain by Otto Moerbeek <otto@drijf.net>.
+ *
+ * Test pointer casts
+ */
+
+struct foo {
+ int a;
+};
+
+void
+f(void)
+{
+ void *vp = 0;
+ char *cp = 0;
+ signed char *scp = 0;
+ unsigned char *ucp = 0;
+ short *sp = 0;
+ struct foo *fp = 0;
+
+ vp = (void *)vp;
+ vp = (void *)cp;
+ vp = (void *)scp;
+ vp = (void *)ucp;
+ vp = (void *)sp;
+ vp = (void *)fp;
+
+ cp = (char *)vp;
+ cp = (char *)cp;
+ cp = (char *)ucp;
+ cp = (char *)scp;
+ cp = (char *)sp;
+ cp = (char *)fp;
+
+ scp = (signed char *)vp;
+ scp = (signed char *)cp;
+ scp = (signed char *)ucp;
+ scp = (signed char *)scp;
+ scp = (signed char *)sp;
+ scp = (signed char *)fp;
+
+ ucp = (unsigned char *)vp;
+ ucp = (unsigned char *)cp;
+ ucp = (unsigned char *)ucp;
+ ucp = (unsigned char *)scp;
+ ucp = (unsigned char *)sp;
+ ucp = (unsigned char *)fp;
+
+ sp = (short *)vp;
+ sp = (short *)cp;
+ sp = (short *)ucp;
+ sp = (short *)scp;
+ sp = (short *)sp;
+ sp = (short *)fp;
+
+ fp = (struct foo *)vp;
+ fp = (struct foo *)cp;
+ fp = (struct foo *)ucp;
+ fp = (struct foo *)scp;
+ fp = (struct foo *)sp;
+ fp = (struct foo *)fp;
+
+}
diff --git a/regress/usr.bin/xlint/test-23.c.exp b/regress/usr.bin/xlint/test-23.c.exp
new file mode 100644
index 00000000000..6c3fdcc4b34
--- /dev/null
+++ b/regress/usr.bin/xlint/test-23.c.exp
@@ -0,0 +1,17 @@
+test-23.c:52: warning: possible pointer alignment problem
+test-23.c:52: warning: pointer casts may be troublesome
+test-23.c:53: warning: possible pointer alignment problem
+test-23.c:53: warning: pointer casts may be troublesome
+test-23.c:54: warning: possible pointer alignment problem
+test-23.c:54: warning: pointer casts may be troublesome
+test-23.c:56: warning: pointer casts may be troublesome
+test-23.c:59: warning: possible pointer alignment problem
+test-23.c:59: warning: pointer casts may be troublesome
+test-23.c:60: warning: possible pointer alignment problem
+test-23.c:60: warning: pointer casts may be troublesome
+test-23.c:61: warning: possible pointer alignment problem
+test-23.c:61: warning: pointer casts may be troublesome
+test-23.c:62: warning: possible pointer alignment problem
+test-23.c:62: warning: pointer casts may be troublesome
+Lint pass2:
+test-23.c:14: f defined, but never used