Module Name: src
Committed By: rillig
Date: Sat Apr 17 16:52:09 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_135.c msg_135.exp
Log Message:
tests/lint: add test for pointer cast from incomplete struct
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_135.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_135.exp
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/msg_135.c
diff -u src/tests/usr.bin/xlint/lint1/msg_135.c:1.5 src/tests/usr.bin/xlint/lint1/msg_135.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_135.c:1.5 Sun Feb 28 01:20:54 2021
+++ src/tests/usr.bin/xlint/lint1/msg_135.c Sat Apr 17 16:52:09 2021
@@ -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 @@ read_uint(const unsigned char **pp)
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);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_135.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_135.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_135.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_135.exp:1.3 Sun Feb 28 00:40:22 2021
+++ src/tests/usr.bin/xlint/lint1/msg_135.exp Sat Apr 17 16:52:09 2021
@@ -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]