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 tests for accessin...



details:   https://anonhg.NetBSD.org/src/rev/cc29c50da996
branches:  trunk
changeset: 368251:cc29c50da996
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jul 01 20:35:18 2022 +0000

description:
tests/lint: add tests for accessing incomplete types

diffstat:

 tests/usr.bin/xlint/lint1/msg_138.c |  35 +++++++++++++++++++++++++++++++----
 1 files changed, 31 insertions(+), 4 deletions(-)

diffs (43 lines):

diff -r 38d659649ce2 -r cc29c50da996 tests/usr.bin/xlint/lint1/msg_138.c
--- a/tests/usr.bin/xlint/lint1/msg_138.c       Fri Jul 01 19:52:41 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_138.c       Fri Jul 01 20:35:18 2022 +0000
@@ -1,8 +1,35 @@
-/*     $NetBSD: msg_138.c,v 1.3 2022/06/16 16:58:36 rillig Exp $       */
+/*     $NetBSD: msg_138.c,v 1.4 2022/07/01 20:35:18 rillig Exp $       */
 # 3 "msg_138.c"
 
 // Test for message: unknown operand size, op %s [138]
 
-/* expect+1: error: syntax error ':' [249] */
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -z */
+
+struct incomplete;
+
+/*
+ * This code doesn't make sense at all, at least not in C99.
+ */
+/* ARGSUSED */
+void
+function(_Bool cond, struct incomplete *i1, struct incomplete *i2)
+{
+       /* expect+2: error: 'local' has incomplete type 'incomplete struct incomplete' [31] */
+       /* expect+1: error: cannot initialize 'incomplete struct incomplete' from 'pointer to incomplete struct incomplete' [185] */
+       struct incomplete local = i1;
+
+       /* expect+1: error: unknown operand size, op = [138] */
+       *i1 = *i2;
+
+       /* expect+1: error: unknown operand size, op : [138] */
+       return cond ? *i1 : *i2;
+}
+
+/* ARGSUSED */
+struct incomplete
+return_incomplete(struct incomplete *ptr)
+/* expect+1: error: cannot return incomplete type [67] */
+{
+       /* expect+1: error: cannot return incomplete type [212] */
+       return *ptr;
+}



Home | Main Index | Thread Index | Old Index