Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src tests/lint: add more tests for covering the grammar
details: https://anonhg.NetBSD.org/src/rev/dda956f58a70
branches: trunk
changeset: 1022228:dda956f58a70
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jul 10 09:24:26 2021 +0000
description:
tests/lint: add more tests for covering the grammar
diffstat:
distrib/sets/lists/tests/mi | 6 +++++-
tests/usr.bin/xlint/lint1/Makefile | 6 +++++-
tests/usr.bin/xlint/lint1/decl_arg.c | 8 +++++++-
tests/usr.bin/xlint/lint1/init.c | 24 ++++++++++++++++++++++++
tests/usr.bin/xlint/lint1/init.exp | 1 +
tests/usr.bin/xlint/lint1/init_c90.c | 23 +++++++++++++++++++++++
tests/usr.bin/xlint/lint1/init_c90.exp | 3 +++
tests/usr.bin/xlint/lint1/msg_190.c | 8 +++++---
tests/usr.bin/xlint/lint1/msg_190.exp | 2 +-
9 files changed, 74 insertions(+), 7 deletions(-)
diffs (148 lines):
diff -r 97b4bc5aa2da -r dda956f58a70 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sat Jul 10 09:14:38 2021 +0000
+++ b/distrib/sets/lists/tests/mi Sat Jul 10 09:24:26 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1081 2021/07/09 20:20:03 rillig Exp $
+# $NetBSD: mi,v 1.1082 2021/07/10 09:24:26 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6244,6 +6244,10 @@
./usr/tests/usr.bin/xlint/lint1/gcc_init_compound_literal.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_typeof_after_statement.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/gcc_typeof_after_statement.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/init.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/init.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/init_c90.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/init_c90.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/lex_char.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/lex_char.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/lex_char_uchar.c tests-usr.bin-tests compattestfile,atf
diff -r 97b4bc5aa2da -r dda956f58a70 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile Sat Jul 10 09:14:38 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile Sat Jul 10 09:24:26 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.82 2021/07/09 20:20:03 rillig Exp $
+# $NetBSD: Makefile,v 1.83 2021/07/10 09:24:26 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 345 # see lint1/err.c
@@ -141,6 +141,10 @@
FILES+= gcc_init_compound_literal.exp
FILES+= gcc_typeof_after_statement.c
FILES+= gcc_typeof_after_statement.exp
+FILES+= init.c
+FILES+= init.exp
+FILES+= init_c90.c
+FILES+= init_c90.exp
FILES+= lex_char.c
FILES+= lex_char.exp
FILES+= lex_char_uchar.c
diff -r 97b4bc5aa2da -r dda956f58a70 tests/usr.bin/xlint/lint1/decl_arg.c
--- a/tests/usr.bin/xlint/lint1/decl_arg.c Sat Jul 10 09:14:38 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/decl_arg.c Sat Jul 10 09:24:26 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl_arg.c,v 1.4 2021/07/10 08:40:36 rillig Exp $ */
+/* $NetBSD: decl_arg.c,v 1.5 2021/07/10 09:24:27 rillig Exp $ */
# 3 "decl_arg.c"
/*
@@ -123,3 +123,9 @@
double *const, /* 6 */
...
);
+
+void cover_asm_or_symbolrename_asm(void)
+ __asm("assembly code");
+
+void cover_asm_or_symbolrename_symbolrename(void)
+ __symbolrename(alternate_name);
diff -r 97b4bc5aa2da -r dda956f58a70 tests/usr.bin/xlint/lint1/init.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/init.c Sat Jul 10 09:24:26 2021 +0000
@@ -0,0 +1,24 @@
+/* $NetBSD: init.c,v 1.1 2021/07/10 09:24:27 rillig Exp $ */
+# 3 "init.c"
+
+/*
+ * Tests for initialization.
+ *
+ * C99 6.7.8
+ */
+
+/*
+ * C99 does not allow empty initializer braces syntactically.
+ * Lint allows this syntactically, it just complains if the resulting
+ * object is empty.
+ */
+/* expect+1: error: empty array declaration: empty_array_with_initializer [190] */
+double empty_array_with_initializer[] = {};
+double array_with_empty_initializer[3] = {};
+
+/*
+ * C99 does not allow empty initializer braces syntactically.
+ */
+struct {
+ int member;
+} empty_struct_initializer = {};
diff -r 97b4bc5aa2da -r dda956f58a70 tests/usr.bin/xlint/lint1/init.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/init.exp Sat Jul 10 09:24:26 2021 +0000
@@ -0,0 +1,1 @@
+init.c(16): error: empty array declaration: empty_array_with_initializer [190]
diff -r 97b4bc5aa2da -r dda956f58a70 tests/usr.bin/xlint/lint1/init_c90.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/init_c90.c Sat Jul 10 09:24:26 2021 +0000
@@ -0,0 +1,23 @@
+/* $NetBSD: init_c90.c,v 1.1 2021/07/10 09:24:27 rillig Exp $ */
+# 3 "init_c90.c"
+
+/*
+ * Test initialization before C99.
+ *
+ * C90 3.5.7
+ */
+
+/* lint1-flags: -sw */
+
+struct point {
+ int x, y;
+};
+
+struct point point_c90 = { 0, 0 };
+/* expect+2: warning: struct or union member name in initializer is a C9X feature [313] */
+/* expect+1: warning: struct or union member name in initializer is a C9X feature [313] */
+struct point point_c99 = { .x = 0, .y = 0 };
+
+struct point points_c90[] = {{ 0, 0 }};
+/* expect+1: warning: array initializer with designators is a C9X feature [321] */
+struct point points_c99[] = {[3] = { 0, 0 }};
diff -r 97b4bc5aa2da -r dda956f58a70 tests/usr.bin/xlint/lint1/init_c90.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/init_c90.exp Sat Jul 10 09:24:26 2021 +0000
@@ -0,0 +1,3 @@
+init_c90.c(19): warning: struct or union member name in initializer is a C9X feature [313]
+init_c90.c(19): warning: struct or union member name in initializer is a C9X feature [313]
+init_c90.c(23): warning: array initializer with designators is a C9X feature [321]
diff -r 97b4bc5aa2da -r dda956f58a70 tests/usr.bin/xlint/lint1/msg_190.c
--- a/tests/usr.bin/xlint/lint1/msg_190.c Sat Jul 10 09:14:38 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_190.c Sat Jul 10 09:24:26 2021 +0000
@@ -1,7 +1,9 @@
-/* $NetBSD: msg_190.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_190.c,v 1.3 2021/07/10 09:24:27 rillig Exp $ */
# 3 "msg_190.c"
// Test for message: empty array declaration: %s [190]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: error: empty array declaration: empty_array [190] */
+double empty_array[] = {};
+
+double array[] = { 1 };
diff -r 97b4bc5aa2da -r dda956f58a70 tests/usr.bin/xlint/lint1/msg_190.exp
--- a/tests/usr.bin/xlint/lint1/msg_190.exp Sat Jul 10 09:14:38 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_190.exp Sat Jul 10 09:24:26 2021 +0000
@@ -1,1 +1,1 @@
-msg_190.c(6): error: syntax error ':' [249]
+msg_190.c(7): error: empty array declaration: empty_array [190]
Home |
Main Index |
Thread Index |
Old Index