Module Name:    src
Committed By:   rillig
Date:           Fri Jul  1 20:35:18 UTC 2022

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_138.c

Log Message:
tests/lint: add tests for accessing incomplete types


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_138.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_138.c
diff -u src/tests/usr.bin/xlint/lint1/msg_138.c:1.3 src/tests/usr.bin/xlint/lint1/msg_138.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_138.c:1.3	Thu Jun 16 16:58:36 2022
+++ src/tests/usr.bin/xlint/lint1/msg_138.c	Fri Jul  1 20:35:18 2022
@@ -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;
+}

Reply via email to