Module Name: src
Committed By: rillig
Date: Fri Mar 21 20:33:47 UTC 2025
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_135.c
Log Message:
tests/lint: demonstrate questionable warning about alignment
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/xlint/lint1/msg_135.c
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.15 src/tests/usr.bin/xlint/lint1/msg_135.c:1.16
--- src/tests/usr.bin/xlint/lint1/msg_135.c:1.15 Sun Apr 23 11:52:43 2023
+++ src/tests/usr.bin/xlint/lint1/msg_135.c Fri Mar 21 20:33:47 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_135.c,v 1.15 2023/04/23 11:52:43 rillig Exp $ */
+/* $NetBSD: msg_135.c,v 1.16 2025/03/21 20:33:47 rillig Exp $ */
# 3 "msg_135.c"
// Test for message: converting '%s' to '%s' increases alignment from %u to %u [135]
@@ -107,3 +107,23 @@ cast_to_union(void)
both = (union both *)&align_8;
return both->p_align_8;
}
+
+void
+from_alignment_1_to_8(void)
+{
+ struct alignment_1 {
+ char filler[32];
+ };
+ struct alignment_8 {
+ char filler[32];
+ double numbers[4];
+ };
+
+ static struct alignment_1 *pointer_1;
+ static struct alignment_8 *pointer_8;
+
+ // FIXME: Don't warn when the old alignment is 1.
+ /* expect+1: warning: converting 'pointer to struct alignment_1' to 'pointer to struct alignment_8' increases alignment from 1 to 8 [135] */
+ pointer_8 = (struct alignment_8 *)pointer_1;
+ pointer_1 = (struct alignment_1 *)pointer_8;
+}