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 'illegal ...



details:   https://anonhg.NetBSD.org/src/rev/935c94aa5552
branches:  trunk
changeset: 981109:935c94aa5552
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 28 01:53:49 2021 +0000

description:
tests/lint: add test for 'illegal structure pointer combination'

diffstat:

 tests/usr.bin/xlint/lint1/msg_245.c   |  31 ++++++++++++++++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_245.exp |   4 +++-
 2 files changed, 31 insertions(+), 4 deletions(-)

diffs (47 lines):

diff -r b6a77c204e45 -r 935c94aa5552 tests/usr.bin/xlint/lint1/msg_245.c
--- a/tests/usr.bin/xlint/lint1/msg_245.c       Sun Feb 28 01:36:46 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_245.c       Sun Feb 28 01:53:49 2021 +0000
@@ -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 */
+}
diff -r b6a77c204e45 -r 935c94aa5552 tests/usr.bin/xlint/lint1/msg_245.exp
--- a/tests/usr.bin/xlint/lint1/msg_245.exp     Sun Feb 28 01:36:46 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_245.exp     Sun Feb 28 01:53:49 2021 +0000
@@ -1,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]



Home | Main Index | Thread Index | Old Index