lint: add test for old style function arguments

This commit is contained in:
rillig 2020-12-30 13:15:07 +00:00
parent 47bf7e655e
commit f4b4e8b893
5 changed files with 43 additions and 3 deletions

View File

@ -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

View File

@ -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_constant_conv2.exp
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_typefun.c
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>

View File

@ -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;
{
}

View File

@ -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]

View File

@ -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_cast
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