Module Name: src Committed By: rillig Date: Sun Feb 27 12:00:27 UTC 2022
Modified Files: src/tests/usr.bin/xlint/lint1: msg_047.c msg_047.exp msg_313.c msg_313.exp msg_315.c msg_315.exp msg_317.c msg_317.exp msg_319.c msg_319.exp msg_321.c msg_321.exp Log Message: tests/lint: add tests for messages referring to C99 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_047.c \ src/tests/usr.bin/xlint/lint1/msg_313.c \ src/tests/usr.bin/xlint/lint1/msg_317.c \ src/tests/usr.bin/xlint/lint1/msg_319.c \ src/tests/usr.bin/xlint/lint1/msg_321.c cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_047.exp \ src/tests/usr.bin/xlint/lint1/msg_313.exp \ src/tests/usr.bin/xlint/lint1/msg_315.c \ src/tests/usr.bin/xlint/lint1/msg_315.exp \ src/tests/usr.bin/xlint/lint1/msg_317.exp \ src/tests/usr.bin/xlint/lint1/msg_319.exp \ src/tests/usr.bin/xlint/lint1/msg_321.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_047.c diff -u src/tests/usr.bin/xlint/lint1/msg_047.c:1.3 src/tests/usr.bin/xlint/lint1/msg_047.c:1.4 --- src/tests/usr.bin/xlint/lint1/msg_047.c:1.3 Sun Feb 27 11:40:30 2022 +++ src/tests/usr.bin/xlint/lint1/msg_047.c Sun Feb 27 12:00:27 2022 @@ -1,7 +1,18 @@ -/* $NetBSD: msg_047.c,v 1.3 2022/02/27 11:40:30 rillig Exp $ */ +/* $NetBSD: msg_047.c,v 1.4 2022/02/27 12:00:27 rillig Exp $ */ # 3 "msg_047.c" -// Test for message: zero sized %s is a C99 feature [47] +/* Test for message: zero sized %s is a C99 feature [47] */ -TODO: "Add example code that triggers the above message." /* expect: 249 */ -TODO: "Add example code that almost triggers the above message." +/* lint1-flags: -sw */ + +struct empty { + /* TODO: The C99 syntax in 6.7.2.1 requires at least 1 member. */ +}; +/* expect-1: error: zero sized struct is a C99 feature [47] */ + +struct zero_sized { + /* expect+2: error: zero sized array is a C99 extension [322] */ + /* expect+1: error: zero sized array in struct is a C99 extension: dummy [39] */ + char dummy[0]; +}; +/* expect-1: error: zero sized struct is a C99 feature [47] */ Index: src/tests/usr.bin/xlint/lint1/msg_313.c diff -u src/tests/usr.bin/xlint/lint1/msg_313.c:1.3 src/tests/usr.bin/xlint/lint1/msg_313.c:1.4 --- src/tests/usr.bin/xlint/lint1/msg_313.c:1.3 Sun Feb 27 11:40:30 2022 +++ src/tests/usr.bin/xlint/lint1/msg_313.c Sun Feb 27 12:00:27 2022 @@ -1,7 +1,15 @@ -/* $NetBSD: msg_313.c,v 1.3 2022/02/27 11:40:30 rillig Exp $ */ +/* $NetBSD: msg_313.c,v 1.4 2022/02/27 12:00:27 rillig Exp $ */ # 3 "msg_313.c" -// Test for message: struct or union member name in initializer is a C99 feature [313] +/* Test for message: struct or union member name in initializer is a C99 feature [313] */ -TODO: "Add example code that triggers the above message." /* expect: 249 */ -TODO: "Add example code that almost triggers the above message." +/* lint1-flags: -sw */ + +struct point { + int x, y; +} p = { + /* expect+1: warning: struct or union member name in initializer is a C99 feature [313] */ + .x = 3, + /* expect+1: warning: struct or union member name in initializer is a C99 feature [313] */ + .y = 4, +}; Index: src/tests/usr.bin/xlint/lint1/msg_317.c diff -u src/tests/usr.bin/xlint/lint1/msg_317.c:1.3 src/tests/usr.bin/xlint/lint1/msg_317.c:1.4 --- src/tests/usr.bin/xlint/lint1/msg_317.c:1.3 Sun Feb 27 11:40:30 2022 +++ src/tests/usr.bin/xlint/lint1/msg_317.c Sun Feb 27 12:00:27 2022 @@ -1,7 +1,13 @@ -/* $NetBSD: msg_317.c,v 1.3 2022/02/27 11:40:30 rillig Exp $ */ +/* $NetBSD: msg_317.c,v 1.4 2022/02/27 12:00:27 rillig Exp $ */ # 3 "msg_317.c" -// Test for message: __func__ is a C99 feature [317] +/* Test for message: __func__ is a C99 feature [317] */ -TODO: "Add example code that triggers the above message." /* expect: 249 */ -TODO: "Add example code that almost triggers the above message." +/* lint1-flags: -sw */ + +const char * +function(void) +{ + /* expect+1: warning: __func__ is a C99 feature [317] */ + return __func__; +} Index: src/tests/usr.bin/xlint/lint1/msg_319.c diff -u src/tests/usr.bin/xlint/lint1/msg_319.c:1.3 src/tests/usr.bin/xlint/lint1/msg_319.c:1.4 --- src/tests/usr.bin/xlint/lint1/msg_319.c:1.3 Sun Feb 27 11:40:30 2022 +++ src/tests/usr.bin/xlint/lint1/msg_319.c Sun Feb 27 12:00:27 2022 @@ -1,7 +1,20 @@ -/* $NetBSD: msg_319.c,v 1.3 2022/02/27 11:40:30 rillig Exp $ */ +/* $NetBSD: msg_319.c,v 1.4 2022/02/27 12:00:27 rillig Exp $ */ # 3 "msg_319.c" -// Test for message: compound literals are a C99/GCC extension [319] +/* Test for message: compound literals are a C99/GCC extension [319] */ -TODO: "Add example code that triggers the above message." /* expect: 249 */ -TODO: "Add example code that almost triggers the above message." +/* lint1-flags: -sw */ + +/* expect+2: error: compound literals are a C99/GCC extension [319] */ +/* expect+1: error: non-constant initializer [177] */ +int number = (int) { 3 }; + +struct point { + int x; + int y; +} point = (struct point) { + 3, + 4, +}; +/* expect-1: error: compound literals are a C99/GCC extension [319] */ +/* expect-2: error: {}-enclosed initializer required [181] */ Index: src/tests/usr.bin/xlint/lint1/msg_321.c diff -u src/tests/usr.bin/xlint/lint1/msg_321.c:1.3 src/tests/usr.bin/xlint/lint1/msg_321.c:1.4 --- src/tests/usr.bin/xlint/lint1/msg_321.c:1.3 Sun Feb 27 11:40:30 2022 +++ src/tests/usr.bin/xlint/lint1/msg_321.c Sun Feb 27 12:00:27 2022 @@ -1,7 +1,13 @@ -/* $NetBSD: msg_321.c,v 1.3 2022/02/27 11:40:30 rillig Exp $ */ +/* $NetBSD: msg_321.c,v 1.4 2022/02/27 12:00:27 rillig Exp $ */ # 3 "msg_321.c" -// Test for message: array initializer with designators is a C99 feature [321] +/* Test for message: array initializer with designators is a C99 feature [321] */ -TODO: "Add example code that triggers the above message." /* expect: 249 */ -TODO: "Add example code that almost triggers the above message." +/* lint1-flags: -sw */ + +int vector[3] = { + /* expect+1: warning: array initializer with designators is a C99 feature [321] */ + [0] = 3, + /* expect+1: warning: array initializer with designators is a C99 feature [321] */ + [1] = 5, +}; Index: src/tests/usr.bin/xlint/lint1/msg_047.exp diff -u src/tests/usr.bin/xlint/lint1/msg_047.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_047.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_047.exp:1.2 Sun Mar 21 20:44:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_047.exp Sun Feb 27 12:00:27 2022 @@ -1 +1,4 @@ -msg_047.c(6): error: syntax error ':' [249] +msg_047.c(10): error: zero sized struct is a C99 feature [47] +msg_047.c(16): error: zero sized array is a C99 extension [322] +msg_047.c(16): error: zero sized array in struct is a C99 extension: dummy [39] +msg_047.c(17): error: zero sized struct is a C99 feature [47] Index: src/tests/usr.bin/xlint/lint1/msg_313.exp diff -u src/tests/usr.bin/xlint/lint1/msg_313.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_313.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_313.exp:1.2 Sun Mar 21 20:45:00 2021 +++ src/tests/usr.bin/xlint/lint1/msg_313.exp Sun Feb 27 12:00:27 2022 @@ -1 +1,2 @@ -msg_313.c(6): error: syntax error ':' [249] +msg_313.c(12): warning: struct or union member name in initializer is a C99 feature [313] +msg_313.c(14): warning: struct or union member name in initializer is a C99 feature [313] Index: src/tests/usr.bin/xlint/lint1/msg_315.c diff -u src/tests/usr.bin/xlint/lint1/msg_315.c:1.2 src/tests/usr.bin/xlint/lint1/msg_315.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_315.c:1.2 Sun Feb 21 09:07:58 2021 +++ src/tests/usr.bin/xlint/lint1/msg_315.c Sun Feb 27 12:00:27 2022 @@ -1,7 +1,15 @@ -/* $NetBSD: msg_315.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */ +/* $NetBSD: msg_315.c,v 1.3 2022/02/27 12:00:27 rillig Exp $ */ # 3 "msg_315.c" // Test for message: GCC style struct or union member name in initializer [315] -TODO: "Add example code that triggers the above message." /* expect: 249 */ -TODO: "Add example code that almost triggers the above message." +/* lint1-flags: -Sw */ + +struct point { + int x, y; +} p = { + /* expect+1: warning: GCC style struct or union member name in initializer [315] */ + x: 3, + /* expect+1: warning: GCC style struct or union member name in initializer [315] */ + y: 4, +}; Index: src/tests/usr.bin/xlint/lint1/msg_315.exp diff -u src/tests/usr.bin/xlint/lint1/msg_315.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_315.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_315.exp:1.2 Sun Mar 21 20:45:00 2021 +++ src/tests/usr.bin/xlint/lint1/msg_315.exp Sun Feb 27 12:00:27 2022 @@ -1 +1,2 @@ -msg_315.c(6): error: syntax error ':' [249] +msg_315.c(12): warning: GCC style struct or union member name in initializer [315] +msg_315.c(14): warning: GCC style struct or union member name in initializer [315] Index: src/tests/usr.bin/xlint/lint1/msg_317.exp diff -u src/tests/usr.bin/xlint/lint1/msg_317.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_317.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_317.exp:1.2 Sun Mar 21 20:45:00 2021 +++ src/tests/usr.bin/xlint/lint1/msg_317.exp Sun Feb 27 12:00:27 2022 @@ -1 +1 @@ -msg_317.c(6): error: syntax error ':' [249] +msg_317.c(12): warning: __func__ is a C99 feature [317] Index: src/tests/usr.bin/xlint/lint1/msg_319.exp diff -u src/tests/usr.bin/xlint/lint1/msg_319.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_319.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_319.exp:1.2 Sun Mar 21 20:45:00 2021 +++ src/tests/usr.bin/xlint/lint1/msg_319.exp Sun Feb 27 12:00:27 2022 @@ -1 +1,4 @@ -msg_319.c(6): error: syntax error ':' [249] +msg_319.c(10): error: compound literals are a C99/GCC extension [319] +msg_319.c(10): error: non-constant initializer [177] +msg_319.c(18): error: compound literals are a C99/GCC extension [319] +msg_319.c(18): error: {}-enclosed initializer required [181] Index: src/tests/usr.bin/xlint/lint1/msg_321.exp diff -u src/tests/usr.bin/xlint/lint1/msg_321.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_321.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_321.exp:1.2 Sun Mar 21 20:45:00 2021 +++ src/tests/usr.bin/xlint/lint1/msg_321.exp Sun Feb 27 12:00:27 2022 @@ -1 +1,2 @@ -msg_321.c(6): error: syntax error ':' [249] +msg_321.c(10): warning: array initializer with designators is a C99 feature [321] +msg_321.c(12): warning: array initializer with designators is a C99 feature [321]