Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: add test for newly added message a...



details:   https://anonhg.NetBSD.org/src/rev/4ee646454192
branches:  trunk
changeset: 1020517:4ee646454192
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Apr 14 18:27:11 2021 +0000

description:
lint: add test for newly added message about static array size

diffstat:

 distrib/sets/lists/tests/mi                |   4 ++-
 tests/usr.bin/xlint/lint1/Makefile         |   4 +-
 tests/usr.bin/xlint/lint1/msg_343.c        |  39 ++++++++++++++++++++++++++++++
 tests/usr.bin/xlint/lint1/msg_343.exp      |   6 ++++
 tests/usr.bin/xlint/lint1/t_integration.sh |   4 +-
 usr.bin/xlint/lint1/cgram.y                |   7 +++--
 6 files changed, 56 insertions(+), 8 deletions(-)

diffs (133 lines):

diff -r 0e39467410f0 -r 4ee646454192 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Wed Apr 14 17:39:11 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Wed Apr 14 18:27:11 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1039 2021/04/09 21:07:39 rillig Exp $
+# $NetBSD: mi,v 1.1040 2021/04/14 18:27:11 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6870,6 +6870,8 @@
 ./usr/tests/usr.bin/xlint/lint1/msg_341.exp                    tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_342.c                      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_342.exp                    tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_343.c                      tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_343.exp                    tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/op_colon.c                     tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/op_colon.exp                   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/t_integration                  tests-usr.bin-tests     compattestfile,atf
diff -r 0e39467410f0 -r 4ee646454192 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Wed Apr 14 17:39:11 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Wed Apr 14 18:27:11 2021 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.41 2021/04/09 21:07:39 rillig Exp $
+# $NetBSD: Makefile,v 1.42 2021/04/14 18:27:11 rillig Exp $
 
 NOMAN=         # defined
-MAX_MESSAGE=   342             # see lint1/err.c
+MAX_MESSAGE=   343             # see lint1/err.c
 
 .include <bsd.own.mk>
 
diff -r 0e39467410f0 -r 4ee646454192 tests/usr.bin/xlint/lint1/msg_343.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_343.c       Wed Apr 14 18:27:11 2021 +0000
@@ -0,0 +1,39 @@
+/*     $NetBSD: msg_343.c,v 1.1 2021/04/14 18:27:11 rillig Exp $       */
+# 3 "msg_343.c"
+
+/* Test for message: static array size is a C99 extension [343] */
+
+/* lint1-flags: -sw */
+
+void takes_int_pointer(int []);
+void takes_int_pointer_with_ignored_size(int [3]);
+void takes_int_array(int[static 3]);   /* expect: 343 */
+/* expect+1: syntax error 'volatile' */
+void takes_volatile_int_array(int[volatile 3]);
+
+int
+returns_int_pointer(int a[])
+{
+       return a[0];
+}
+
+int
+returns_int_pointer_with_ignored_size(int a[3])
+{
+       return a[0];
+}
+
+int
+returns_int_array(int a[static 3])     /* expect: 343 */
+{
+       return a[0];
+}
+
+int
+/* expect+1: syntax error 'volatile' */
+returns_volatile_int_array(int a[volatile 3])
+{
+       /* expect+2: cannot dereference non-pointer type */
+       /* expect+1: expects to return value */
+       return a[0];
+}
diff -r 0e39467410f0 -r 4ee646454192 tests/usr.bin/xlint/lint1/msg_343.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_343.exp     Wed Apr 14 18:27:11 2021 +0000
@@ -0,0 +1,6 @@
+msg_343.c(10): error: static array size is a C99 extension [343]
+msg_343.c(12): error: syntax error 'volatile' [249]
+msg_343.c(27): error: static array size is a C99 extension [343]
+msg_343.c(34): error: syntax error 'volatile' [249]
+msg_343.c(38): error: cannot dereference non-pointer type [96]
+msg_343.c(38): warning: function returns_volatile_int_array expects to return value [214]
diff -r 0e39467410f0 -r 4ee646454192 tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh        Wed Apr 14 17:39:11 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh        Wed Apr 14 18:27:11 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.40 2021/04/08 22:18:27 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.41 2021/04/14 18:27:11 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -177,7 +177,7 @@
 
        failed=""
 
-       for msg in $(seq 0 342); do
+       for msg in $(seq 0 343); do
                name="$(printf 'msg_%03d.c' "${msg}")"
                check_lint1 "${name}" \
                || failed="$failed${failed:+ }$name"
diff -r 0e39467410f0 -r 4ee646454192 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Wed Apr 14 17:39:11 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Wed Apr 14 18:27:11 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.214 2021/04/14 13:34:08 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.215 2021/04/14 18:27:11 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.214 2021/04/14 13:34:08 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.215 2021/04/14 18:27:11 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -1137,9 +1137,10 @@
                /* C99 6.7.6.3 */
                if ($1 != STATIC)
                        yyerror("Bad attribute");
+               /* static array size is a C99 extension */
                c99ism(343);
                $$ = $2;
-         } 
+         }
        | constant_expr {
                $$ = $1;
        }



Home | Main Index | Thread Index | Old Index