Source-Changes-HG archive

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

[src/trunk]: src lint: add test for old style function arguments



details:   https://anonhg.NetBSD.org/src/rev/78e9699f0216
branches:  trunk
changeset: 948746:78e9699f0216
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Dec 30 13:15:07 2020 +0000

description:
lint: add test for old style function arguments

diffstat:

 distrib/sets/lists/tests/mi                              |   4 ++-
 tests/usr.bin/xlint/lint1/Makefile                       |  18 +++++++++++++++-
 tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.c   |  15 +++++++++++++
 tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.exp |   6 +++++
 tests/usr.bin/xlint/lint1/t_integration.sh               |   3 +-
 5 files changed, 43 insertions(+), 3 deletions(-)

diffs (101 lines):

diff -r 364d102a3b21 -r 78e9699f0216 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Wed Dec 30 12:22:51 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Wed Dec 30 13:15:07 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1000 2020/12/29 01:45:06 rillig Exp $
+# $NetBSD: mi,v 1.1001 2020/12/30 13:15:07 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5773,6 +5773,8 @@
 ./usr/tests/usr.bin/xlint/lint1/d_cvt_constant.c               tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/d_cvt_constant.exp             tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/d_cvt_in_ternary.c             tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.c   tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.exp tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/d_ellipsis_in_switch.c         tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c   tests-usr.bin-tests     compattestfile,atf
diff -r 364d102a3b21 -r 78e9699f0216 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Wed Dec 30 12:22:51 2020 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Wed Dec 30 13:15:07 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.20 2020/12/28 12:47:39 rillig Exp $
+# $NetBSD: Makefile,v 1.21 2020/12/30 13:15:07 rillig Exp $
 
 NOMAN=         # defined
 
@@ -47,6 +47,8 @@
 FILES+=                d_cvt_constant.c
 FILES+=                d_cvt_constant.exp
 FILES+=                d_cvt_in_ternary.c
+FILES+=                d_decl_old_style_arguments.c
+FILES+=                d_decl_old_style_arguments.exp
 FILES+=                d_ellipsis_in_switch.c
 FILES+=                d_gcc_compound_statements1.c
 FILES+=                d_gcc_compound_statements2.c
@@ -76,4 +78,18 @@
 FILES+=                d_typename_as_var.c
 FILES+=                d_zero_sized_arrays.c
 
+# Note: only works for adding tests.
+# To remove a test, the $$mi file must be edited manually.
+sync-mi: .PHONY
+       @set -eu;                                                       \
+       cd "${MAKEFILE:tA:H}/../../../..";                              \
+       mi="distrib/sets/lists/tests/mi";                               \
+       cvs update "$$mi";                                              \
+       fmt="./usr/tests/usr.bin/xlint/lint1/%s\ttests-usr.bin-tests\tcompattestfile,atf\n"; \
+       cat "$$mi" > "$$mi.tmp";                                        \
+       printf "$$fmt" ${FILES:M*.c} ${FILES:M*.exp} >> "$$mi.tmp";     \
+       distrib/sets/fmt-list "$$mi.tmp";                               \
+       mv "$$mi.tmp" "$$mi";                                           \
+       cvs diff "$$mi" || true
+
 .include <bsd.test.mk>
diff -r 364d102a3b21 -r 78e9699f0216 tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.c    Wed Dec 30 13:15:07 2020 +0000
@@ -0,0 +1,15 @@
+# 2 "d_decl_old_style_arguments.c"
+
+/*
+ * A function is declared with a prototype, followed by an old style definition
+ * that is completely different.
+ */
+
+void func(int a, int b, int c);
+
+void func(num, ptr, dbl, def)
+    int num;
+    char *ptr;
+    double dbl;
+{
+}
diff -r 364d102a3b21 -r 78e9699f0216 tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/d_decl_old_style_arguments.exp  Wed Dec 30 13:15:07 2020 +0000
@@ -0,0 +1,6 @@
+d_decl_old_style_arguments.c(14): warning: argument type defaults to 'int': def [32]
+d_decl_old_style_arguments.c(14): parameter mismatch: 3 declared, 4 defined [51]
+d_decl_old_style_arguments.c(10): warning: argument num unused in function func [231]
+d_decl_old_style_arguments.c(10): warning: argument ptr unused in function func [231]
+d_decl_old_style_arguments.c(10): warning: argument dbl unused in function func [231]
+d_decl_old_style_arguments.c(10): warning: argument def unused in function func [231]
diff -r 364d102a3b21 -r 78e9699f0216 tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh        Wed Dec 30 12:22:51 2020 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh        Wed Dec 30 13:15:07 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.12 2020/12/28 17:00:37 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.13 2020/12/30 13:15:07 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -73,6 +73,7 @@
 test_case c99_union_init4
 test_case cast_fun_array_param
 test_case cast_typeof
+test_case decl_old_style_arguments
 test_case gcc_extension
 test_case type_question_colon
 test_case typefun



Home | Main Index | Thread Index | Old Index