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 messages...



details:   https://anonhg.NetBSD.org/src/rev/23c6dac806de
branches:  trunk
changeset: 362054:23c6dac806de
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 27 12:00:27 2022 +0000

description:
tests/lint: add tests for messages referring to C99

diffstat:

 tests/usr.bin/xlint/lint1/msg_047.c   |  19 +++++++++++++++----
 tests/usr.bin/xlint/lint1/msg_047.exp |   5 ++++-
 tests/usr.bin/xlint/lint1/msg_313.c   |  16 ++++++++++++----
 tests/usr.bin/xlint/lint1/msg_313.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_315.c   |  14 +++++++++++---
 tests/usr.bin/xlint/lint1/msg_315.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_317.c   |  14 ++++++++++----
 tests/usr.bin/xlint/lint1/msg_317.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_319.c   |  21 +++++++++++++++++----
 tests/usr.bin/xlint/lint1/msg_319.exp |   5 ++++-
 tests/usr.bin/xlint/lint1/msg_321.c   |  14 ++++++++++----
 tests/usr.bin/xlint/lint1/msg_321.exp |   3 ++-
 12 files changed, 90 insertions(+), 29 deletions(-)

diffs (186 lines):

diff -r ee2fcd9f0832 -r 23c6dac806de tests/usr.bin/xlint/lint1/msg_047.c
--- a/tests/usr.bin/xlint/lint1/msg_047.c       Sun Feb 27 11:49:28 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_047.c       Sun Feb 27 12:00:27 2022 +0000
@@ -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] */
+
+/* lint1-flags: -sw */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+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] */
diff -r ee2fcd9f0832 -r 23c6dac806de tests/usr.bin/xlint/lint1/msg_047.exp
--- a/tests/usr.bin/xlint/lint1/msg_047.exp     Sun Feb 27 11:49:28 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_047.exp     Sun Feb 27 12:00:27 2022 +0000
@@ -1,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]
diff -r ee2fcd9f0832 -r 23c6dac806de tests/usr.bin/xlint/lint1/msg_313.c
--- a/tests/usr.bin/xlint/lint1/msg_313.c       Sun Feb 27 11:49:28 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_313.c       Sun Feb 27 12:00:27 2022 +0000
@@ -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] */
+
+/* lint1-flags: -sw */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+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,
+};
diff -r ee2fcd9f0832 -r 23c6dac806de tests/usr.bin/xlint/lint1/msg_313.exp
--- a/tests/usr.bin/xlint/lint1/msg_313.exp     Sun Feb 27 11:49:28 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_313.exp     Sun Feb 27 12:00:27 2022 +0000
@@ -1,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]
diff -r ee2fcd9f0832 -r 23c6dac806de tests/usr.bin/xlint/lint1/msg_315.c
--- a/tests/usr.bin/xlint/lint1/msg_315.c       Sun Feb 27 11:49:28 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_315.c       Sun Feb 27 12:00:27 2022 +0000
@@ -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,
+};
diff -r ee2fcd9f0832 -r 23c6dac806de tests/usr.bin/xlint/lint1/msg_315.exp
--- a/tests/usr.bin/xlint/lint1/msg_315.exp     Sun Feb 27 11:49:28 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_315.exp     Sun Feb 27 12:00:27 2022 +0000
@@ -1,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]
diff -r ee2fcd9f0832 -r 23c6dac806de tests/usr.bin/xlint/lint1/msg_317.c
--- a/tests/usr.bin/xlint/lint1/msg_317.c       Sun Feb 27 11:49:28 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_317.c       Sun Feb 27 12:00:27 2022 +0000
@@ -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] */
+
+/* lint1-flags: -sw */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+const char *
+function(void)
+{
+       /* expect+1: warning: __func__ is a C99 feature [317] */
+       return __func__;
+}
diff -r ee2fcd9f0832 -r 23c6dac806de tests/usr.bin/xlint/lint1/msg_317.exp
--- a/tests/usr.bin/xlint/lint1/msg_317.exp     Sun Feb 27 11:49:28 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_317.exp     Sun Feb 27 12:00:27 2022 +0000
@@ -1,1 +1,1 @@
-msg_317.c(6): error: syntax error ':' [249]
+msg_317.c(12): warning: __func__ is a C99 feature [317]
diff -r ee2fcd9f0832 -r 23c6dac806de tests/usr.bin/xlint/lint1/msg_319.c
--- a/tests/usr.bin/xlint/lint1/msg_319.c       Sun Feb 27 11:49:28 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_319.c       Sun Feb 27 12:00:27 2022 +0000
@@ -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] */
+
+/* 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 };
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+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] */
diff -r ee2fcd9f0832 -r 23c6dac806de tests/usr.bin/xlint/lint1/msg_319.exp
--- a/tests/usr.bin/xlint/lint1/msg_319.exp     Sun Feb 27 11:49:28 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_319.exp     Sun Feb 27 12:00:27 2022 +0000
@@ -1,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]
diff -r ee2fcd9f0832 -r 23c6dac806de tests/usr.bin/xlint/lint1/msg_321.c
--- a/tests/usr.bin/xlint/lint1/msg_321.c       Sun Feb 27 11:49:28 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_321.c       Sun Feb 27 12:00:27 2022 +0000
@@ -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] */
+
+/* lint1-flags: -sw */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+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,
+};
diff -r ee2fcd9f0832 -r 23c6dac806de tests/usr.bin/xlint/lint1/msg_321.exp
--- a/tests/usr.bin/xlint/lint1/msg_321.exp     Sun Feb 27 11:49:28 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_321.exp     Sun Feb 27 12:00:27 2022 +0000
@@ -1,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]



Home | Main Index | Thread Index | Old Index