Module Name: src
Committed By: rillig
Date: Sun Feb 28 01:53:50 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_245.c msg_245.exp
Log Message:
tests/lint: add test for 'illegal structure pointer combination'
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_245.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_245.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_245.c
diff -u src/tests/usr.bin/xlint/lint1/msg_245.c:1.2 src/tests/usr.bin/xlint/lint1/msg_245.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_245.c:1.2 Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_245.c Sun Feb 28 01:53:49 2021
@@ -1,7 +1,32 @@
-/* $NetBSD: msg_245.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_245.c,v 1.3 2021/02/28 01:53:49 rillig Exp $ */
# 3 "msg_245.c"
// Test for message: illegal structure pointer combination, op %s [245]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+typedef struct tag_and_typedef_tag {
+ int member;
+} tag_and_typedef_typedef;
+
+struct only_tag {
+ int member;
+};
+
+typedef struct {
+ int member;
+} only_typedef;
+
+struct {
+ int member;
+} unnamed;
+
+void sink_bool(_Bool);
+
+void
+example(tag_and_typedef_typedef both,
+ only_typedef only_typedef,
+ struct only_tag only_tag)
+{
+ sink_bool(&both == &only_tag); /* expect: 245 */
+ sink_bool(&both == &only_typedef); /* expect: 245 */
+ sink_bool(&both == &unnamed); /* expect: 245 */
+}
Index: src/tests/usr.bin/xlint/lint1/msg_245.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_245.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_245.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_245.exp:1.1 Sat Jan 2 10:22:44 2021
+++ src/tests/usr.bin/xlint/lint1/msg_245.exp Sun Feb 28 01:53:49 2021
@@ -1 +1,3 @@
-msg_245.c(6): syntax error ':' [249]
+msg_245.c(29): warning: illegal structure pointer combination, op == [245]
+msg_245.c(30): warning: illegal structure pointer combination, op == [245]
+msg_245.c(31): warning: illegal structure pointer combination, op == [245]