Module Name: src Committed By: rillig Date: Tue Jul 13 21:50:05 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: msg_065.c msg_065.exp msg_067.c msg_067.exp Log Message: tests/lint: add tests for empty and incomplete structs To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_065.c \ src/tests/usr.bin/xlint/lint1/msg_065.exp \ src/tests/usr.bin/xlint/lint1/msg_067.c \ src/tests/usr.bin/xlint/lint1/msg_067.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_065.c diff -u src/tests/usr.bin/xlint/lint1/msg_065.c:1.2 src/tests/usr.bin/xlint/lint1/msg_065.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_065.c:1.2 Sun Feb 21 09:07:58 2021 +++ src/tests/usr.bin/xlint/lint1/msg_065.c Tue Jul 13 21:50:05 2021 @@ -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] */ Index: src/tests/usr.bin/xlint/lint1/msg_065.exp diff -u src/tests/usr.bin/xlint/lint1/msg_065.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_065.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_065.exp:1.2 Sun Mar 21 20:44:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_065.exp Tue Jul 13 21:50:05 2021 @@ -1 +1 @@ -msg_065.c(6): error: syntax error ':' [249] +msg_065.c(17): warning: structure has no named members [65] Index: src/tests/usr.bin/xlint/lint1/msg_067.c diff -u src/tests/usr.bin/xlint/lint1/msg_067.c:1.2 src/tests/usr.bin/xlint/lint1/msg_067.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_067.c:1.2 Sun Feb 21 09:07:58 2021 +++ src/tests/usr.bin/xlint/lint1/msg_067.c Tue Jul 13 21:50:05 2021 @@ -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; +} Index: src/tests/usr.bin/xlint/lint1/msg_067.exp diff -u src/tests/usr.bin/xlint/lint1/msg_067.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_067.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_067.exp:1.2 Sun Mar 21 20:44:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_067.exp Tue Jul 13 21:50:05 2021 @@ -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]