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 empty an...
details: https://anonhg.NetBSD.org/src/rev/95dee802ed1a
branches: trunk
changeset: 984610:95dee802ed1a
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Jul 13 21:50:05 2021 +0000
description:
tests/lint: add tests for empty and incomplete structs
diffstat:
tests/usr.bin/xlint/lint1/msg_065.c | 17 ++++++++++++++---
tests/usr.bin/xlint/lint1/msg_065.exp | 2 +-
tests/usr.bin/xlint/lint1/msg_067.c | 20 +++++++++++++++++---
tests/usr.bin/xlint/lint1/msg_067.exp | 5 ++++-
4 files changed, 36 insertions(+), 8 deletions(-)
diffs (68 lines):
diff -r 2ab574aebd52 -r 95dee802ed1a tests/usr.bin/xlint/lint1/msg_065.c
--- a/tests/usr.bin/xlint/lint1/msg_065.c Tue Jul 13 19:38:10 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_065.c Tue Jul 13 21:50:05 2021 +0000
@@ -1,7 +1,18 @@
-/* $NetBSD: msg_065.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_065.c,v 1.3 2021/07/13 21:50:05 rillig Exp $ */
# 3 "msg_065.c"
// Test for message: %s has no named members [65]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+struct ok {
+ int member;
+};
+
+/* XXX: should generate a warning as well. */
+struct empty {
+};
+
+struct only_unnamed_members {
+ unsigned int :14;
+ unsigned int :0;
+};
+/* expect-1: warning: structure has no named members [65] */
diff -r 2ab574aebd52 -r 95dee802ed1a tests/usr.bin/xlint/lint1/msg_065.exp
--- a/tests/usr.bin/xlint/lint1/msg_065.exp Tue Jul 13 19:38:10 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_065.exp Tue Jul 13 21:50:05 2021 +0000
@@ -1,1 +1,1 @@
-msg_065.c(6): error: syntax error ':' [249]
+msg_065.c(17): warning: structure has no named members [65]
diff -r 2ab574aebd52 -r 95dee802ed1a tests/usr.bin/xlint/lint1/msg_067.c
--- a/tests/usr.bin/xlint/lint1/msg_067.c Tue Jul 13 19:38:10 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_067.c Tue Jul 13 21:50:05 2021 +0000
@@ -1,7 +1,21 @@
-/* $NetBSD: msg_067.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_067.c,v 1.3 2021/07/13 21:50:05 rillig Exp $ */
# 3 "msg_067.c"
// Test for message: cannot return incomplete type [67]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: warning: struct incomplete never defined [233] */
+struct incomplete;
+
+struct incomplete function_declaration(void);
+
+struct incomplete
+function_definition(void)
+/* expect+1: error: cannot return incomplete type [67] */
+{
+ /* FIXME: 'r' is not an argument. */
+ /* expect+1: error: argument 'r' has type 'incomplete struct incomplete' [31] */
+ struct incomplete r;
+
+ /* expect+1: error: cannot return incomplete type [212] */
+ return r;
+}
diff -r 2ab574aebd52 -r 95dee802ed1a tests/usr.bin/xlint/lint1/msg_067.exp
--- a/tests/usr.bin/xlint/lint1/msg_067.exp Tue Jul 13 19:38:10 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_067.exp Tue Jul 13 21:50:05 2021 +0000
@@ -1,1 +1,4 @@
-msg_067.c(6): error: syntax error ':' [249]
+msg_067.c(14): error: cannot return incomplete type [67]
+msg_067.c(17): error: argument 'r' has type 'incomplete struct incomplete' [31]
+msg_067.c(20): error: cannot return incomplete type [212]
+msg_067.c(7): warning: struct incomplete never defined [233]
Home |
Main Index |
Thread Index |
Old Index