Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: demonstrate questionab...
details: https://anonhg.NetBSD.org/src/rev/4a9317ae6de6
branches: trunk
changeset: 984668:4a9317ae6de6
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Jul 15 21:12:46 2021 +0000
description:
tests/lint: demonstrate questionable warnings for pointer casts
diffstat:
tests/usr.bin/xlint/lint1/msg_135.c | 24 +++++++++++++++++++++++-
tests/usr.bin/xlint/lint1/msg_135.exp | 2 ++
tests/usr.bin/xlint/lint1/msg_247.c | 26 +++++++++++++++++++++++++-
tests/usr.bin/xlint/lint1/msg_247.exp | 2 ++
4 files changed, 52 insertions(+), 2 deletions(-)
diffs (89 lines):
diff -r c6a44c1befd3 -r 4a9317ae6de6 tests/usr.bin/xlint/lint1/msg_135.c
--- a/tests/usr.bin/xlint/lint1/msg_135.c Thu Jul 15 21:00:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_135.c Thu Jul 15 21:12:46 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_135.c,v 1.7 2021/04/17 16:58:04 rillig Exp $ */
+/* $NetBSD: msg_135.c,v 1.8 2021/07/15 21:12:46 rillig Exp $ */
# 3 "msg_135.c"
// Test for message: converting '%s' to '%s' may cause alignment problem [135]
@@ -42,3 +42,25 @@
complete = (struct complete *)incomplete;
sink(complete);
}
+
+void
+unsigned_char_to_unsigned_type(unsigned char *ucp)
+{
+ unsigned short *usp;
+
+ /* FIXME */
+ /* expect+1: warning: converting 'pointer to unsigned char' to 'pointer to unsigned short' may cause alignment problem [135] */
+ usp = (unsigned short *)ucp;
+ sink(usp);
+}
+
+void
+plain_char_to_unsigned_type(char *cp)
+{
+ unsigned short *usp;
+
+ /* FIXME */
+ /* expect+1: warning: converting 'pointer to char' to 'pointer to unsigned short' may cause alignment problem [135] */
+ usp = (unsigned short *)cp;
+ sink(usp);
+}
diff -r c6a44c1befd3 -r 4a9317ae6de6 tests/usr.bin/xlint/lint1/msg_135.exp
--- a/tests/usr.bin/xlint/lint1/msg_135.exp Thu Jul 15 21:00:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_135.exp Thu Jul 15 21:12:46 2021 +0000
@@ -1,2 +1,4 @@
msg_135.c(15): warning: converting 'pointer to const unsigned char' to 'pointer to const unsigned int' may cause alignment problem [135]
+msg_135.c(53): warning: converting 'pointer to unsigned char' to 'pointer to unsigned short' may cause alignment problem [135]
+msg_135.c(64): warning: converting 'pointer to char' to 'pointer to unsigned short' may cause alignment problem [135]
msg_135.c(20): warning: struct incomplete never defined [233]
diff -r c6a44c1befd3 -r 4a9317ae6de6 tests/usr.bin/xlint/lint1/msg_247.c
--- a/tests/usr.bin/xlint/lint1/msg_247.c Thu Jul 15 21:00:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_247.c Thu Jul 15 21:12:46 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_247.c,v 1.14 2021/07/10 17:35:54 rillig Exp $ */
+/* $NetBSD: msg_247.c,v 1.15 2021/07/15 21:12:46 rillig Exp $ */
# 3 "msg_247.c"
// Test for message: pointer cast from '%s' to '%s' may be troublesome [247]
@@ -154,3 +154,27 @@
return (struct lhash_st_OPENSSL_STRING *)OPENSSL_LH_new();
}
# 157 "msg_247.c" 2
+
+void sink(const void *);
+
+void
+unsigned_char_to_unsigned_type(unsigned char *ucp)
+{
+ unsigned short *usp;
+
+ /* FIXME */
+ /* expect+1: warning: pointer cast from 'pointer to unsigned char' to 'pointer to unsigned short' may be troublesome [247] */
+ usp = (unsigned short *)ucp;
+ sink(usp);
+}
+
+void
+plain_char_to_unsigned_type(char *cp)
+{
+ unsigned short *usp;
+
+ /* FIXME */
+ /* expect+1: warning: pointer cast from 'pointer to char' to 'pointer to unsigned short' may be troublesome [247] */
+ usp = (unsigned short *)cp;
+ sink(usp);
+}
diff -r c6a44c1befd3 -r 4a9317ae6de6 tests/usr.bin/xlint/lint1/msg_247.exp
--- a/tests/usr.bin/xlint/lint1/msg_247.exp Thu Jul 15 21:00:05 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_247.exp Thu Jul 15 21:12:46 2021 +0000
@@ -1,3 +1,5 @@
msg_247.c(31): warning: pointer cast from 'pointer to struct Other' to 'pointer to struct <unnamed>' may be troublesome [247]
msg_247.c(70): warning: pointer cast from 'pointer to struct Other' to 'pointer to signed char' may be troublesome [247]
+msg_247.c(167): warning: pointer cast from 'pointer to unsigned char' to 'pointer to unsigned short' may be troublesome [247]
+msg_247.c(178): warning: pointer cast from 'pointer to char' to 'pointer to unsigned short' may be troublesome [247]
msg_247.c(134): warning: struct lhash_st never defined [233]
Home |
Main Index |
Thread Index |
Old Index