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: add test for pointer c...
details: https://anonhg.NetBSD.org/src/rev/95a85cf3c93c
branches: trunk
changeset: 961378:95a85cf3c93c
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Apr 17 16:52:09 2021 +0000
description:
tests/lint: add test for pointer cast from incomplete struct
diffstat:
tests/usr.bin/xlint/lint1/msg_135.c | 26 +++++++++++++++++++++++++-
tests/usr.bin/xlint/lint1/msg_135.exp | 4 +++-
2 files changed, 28 insertions(+), 2 deletions(-)
diffs (51 lines):
diff -r 836f93a51037 -r 95a85cf3c93c tests/usr.bin/xlint/lint1/msg_135.c
--- a/tests/usr.bin/xlint/lint1/msg_135.c Sat Apr 17 13:25:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_135.c Sat Apr 17 16:52:09 2021 +0000
@@ -1,10 +1,12 @@
-/* $NetBSD: msg_135.c,v 1.5 2021/02/28 01:20:54 rillig Exp $ */
+/* $NetBSD: msg_135.c,v 1.6 2021/04/17 16:52:09 rillig Exp $ */
# 3 "msg_135.c"
// Test for message: converting '%s' to '%s' may cause alignment problem [135]
/* lint1-extra-flags: -h */
+void sink(const void *);
+
unsigned
read_uint(const unsigned char **pp)
{
@@ -14,3 +16,25 @@
pp += sizeof(unsigned);
return val;
}
+
+struct incomplete; /* expect: never defined */
+
+struct complete {
+ int member;
+};
+
+/*
+ * These types of conversions are typically seen in OpenSSL, when converting
+ * from the publicly visible, incomplete 'struct lhash_st' to a private
+ * implementation type such as 'struct lhash_st_OPENSSL_STRING'.
+ *
+ * See openssl/lhash.h.
+ */
+void
+pointer_to_structs(struct incomplete *incomplete)
+{
+ struct complete *complete;
+
+ complete = (struct complete *)incomplete; /* expect: 135 */
+ sink(complete);
+}
diff -r 836f93a51037 -r 95a85cf3c93c tests/usr.bin/xlint/lint1/msg_135.exp
--- a/tests/usr.bin/xlint/lint1/msg_135.exp Sat Apr 17 13:25:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_135.exp Sat Apr 17 16:52:09 2021 +0000
@@ -1,1 +1,3 @@
-msg_135.c(13): warning: converting 'pointer to const unsigned char' to 'pointer to const unsigned int' may cause alignment problem [135]
+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(38): warning: converting 'pointer to incomplete struct incomplete' to 'pointer to struct complete' may cause alignment problem [135]
+msg_135.c(20): warning: struct incomplete never defined [233]
Home |
Main Index |
Thread Index |
Old Index