Sat Jul 10 18:25:57 2021 UTC ()
tests/lint: test declarations


(rillig)
diff -r1.1082 -r1.1083 src/distrib/sets/lists/tests/mi
diff -r1.83 -r1.84 src/tests/usr.bin/xlint/lint1/Makefile
diff -r0 -r1.1 src/tests/usr.bin/xlint/lint1/decl.c
diff -r0 -r1.1 src/tests/usr.bin/xlint/lint1/decl.exp

cvs diff -r1.1082 -r1.1083 src/distrib/sets/lists/tests/mi (expand / switch to unified diff)

--- src/distrib/sets/lists/tests/mi 2021/07/10 09:24:26 1.1082
+++ src/distrib/sets/lists/tests/mi 2021/07/10 18:25:57 1.1083
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: mi,v 1.1082 2021/07/10 09:24:26 rillig Exp $ 1# $NetBSD: mi,v 1.1083 2021/07/10 18:25:57 rillig Exp $
2# 2#
3# Note: don't delete entries from here - mark them as "obsolete" instead. 3# Note: don't delete entries from here - mark them as "obsolete" instead.
4# 4#
5./etc/mtree/set.tests tests-sys-root 5./etc/mtree/set.tests tests-sys-root
6./usr/libdata/debug/usr/tests tests-base-debug compattestdir 6./usr/libdata/debug/usr/tests tests-base-debug compattestdir
7./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf 7./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf
8./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf 8./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf
9./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf 9./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf
10./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf 10./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf
11./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf 11./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf
12./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete 12./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete
13./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete 13./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete
14./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete 14./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete
@@ -6200,26 +6200,28 @@ @@ -6200,26 +6200,28 @@
6200./usr/tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c tests-usr.bin-tests compattestfile,atf 6200./usr/tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c tests-usr.bin-tests compattestfile,atf
6201./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.c tests-usr.bin-tests compattestfile,atf 6201./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.c tests-usr.bin-tests compattestfile,atf
6202./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp tests-usr.bin-tests compattestfile,atf 6202./usr/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp tests-usr.bin-tests compattestfile,atf
6203./usr/tests/usr.bin/xlint/lint1/d_type_conv1.c tests-usr.bin-tests compattestfile,atf 6203./usr/tests/usr.bin/xlint/lint1/d_type_conv1.c tests-usr.bin-tests compattestfile,atf
6204./usr/tests/usr.bin/xlint/lint1/d_type_conv1.exp tests-usr.bin-tests compattestfile,atf 6204./usr/tests/usr.bin/xlint/lint1/d_type_conv1.exp tests-usr.bin-tests compattestfile,atf
6205./usr/tests/usr.bin/xlint/lint1/d_type_conv2.c tests-usr.bin-tests compattestfile,atf 6205./usr/tests/usr.bin/xlint/lint1/d_type_conv2.c tests-usr.bin-tests compattestfile,atf
6206./usr/tests/usr.bin/xlint/lint1/d_type_conv2.exp tests-usr.bin-tests compattestfile,atf 6206./usr/tests/usr.bin/xlint/lint1/d_type_conv2.exp tests-usr.bin-tests compattestfile,atf
6207./usr/tests/usr.bin/xlint/lint1/d_type_conv3.c tests-usr.bin-tests compattestfile,atf 6207./usr/tests/usr.bin/xlint/lint1/d_type_conv3.c tests-usr.bin-tests compattestfile,atf
6208./usr/tests/usr.bin/xlint/lint1/d_type_conv3.exp tests-usr.bin-tests compattestfile,atf 6208./usr/tests/usr.bin/xlint/lint1/d_type_conv3.exp tests-usr.bin-tests compattestfile,atf
6209./usr/tests/usr.bin/xlint/lint1/d_type_question_colon.c tests-usr.bin-tests compattestfile,atf 6209./usr/tests/usr.bin/xlint/lint1/d_type_question_colon.c tests-usr.bin-tests compattestfile,atf
6210./usr/tests/usr.bin/xlint/lint1/d_typefun.c tests-usr.bin-tests compattestfile,atf 6210./usr/tests/usr.bin/xlint/lint1/d_typefun.c tests-usr.bin-tests compattestfile,atf
6211./usr/tests/usr.bin/xlint/lint1/d_typename_as_var.c tests-usr.bin-tests compattestfile,atf 6211./usr/tests/usr.bin/xlint/lint1/d_typename_as_var.c tests-usr.bin-tests compattestfile,atf
6212./usr/tests/usr.bin/xlint/lint1/d_zero_sized_arrays.c tests-usr.bin-tests compattestfile,atf 6212./usr/tests/usr.bin/xlint/lint1/d_zero_sized_arrays.c tests-usr.bin-tests compattestfile,atf
 6213./usr/tests/usr.bin/xlint/lint1/decl.c tests-usr.bin-tests compattestfile,atf
 6214./usr/tests/usr.bin/xlint/lint1/decl.exp tests-usr.bin-tests compattestfile,atf
6213./usr/tests/usr.bin/xlint/lint1/decl_arg.c tests-usr.bin-tests compattestfile,atf 6215./usr/tests/usr.bin/xlint/lint1/decl_arg.c tests-usr.bin-tests compattestfile,atf
6214./usr/tests/usr.bin/xlint/lint1/decl_arg.exp tests-usr.bin-tests compattestfile,atf 6216./usr/tests/usr.bin/xlint/lint1/decl_arg.exp tests-usr.bin-tests compattestfile,atf
6215./usr/tests/usr.bin/xlint/lint1/decl_struct_member.c tests-usr.bin-tests compattestfile,atf 6217./usr/tests/usr.bin/xlint/lint1/decl_struct_member.c tests-usr.bin-tests compattestfile,atf
6216./usr/tests/usr.bin/xlint/lint1/decl_struct_member.exp tests-usr.bin-tests compattestfile,atf 6218./usr/tests/usr.bin/xlint/lint1/decl_struct_member.exp tests-usr.bin-tests compattestfile,atf
6217./usr/tests/usr.bin/xlint/lint1/emit.c tests-usr.bin-tests compattestfile,atf 6219./usr/tests/usr.bin/xlint/lint1/emit.c tests-usr.bin-tests compattestfile,atf
6218./usr/tests/usr.bin/xlint/lint1/emit.exp tests-usr.bin-tests compattestfile,atf 6220./usr/tests/usr.bin/xlint/lint1/emit.exp tests-usr.bin-tests compattestfile,atf
6219./usr/tests/usr.bin/xlint/lint1/emit.exp-ln tests-usr.bin-tests compattestfile,atf 6221./usr/tests/usr.bin/xlint/lint1/emit.exp-ln tests-usr.bin-tests compattestfile,atf
6220./usr/tests/usr.bin/xlint/lint1/emit.ln tests-obsolete obsolete 6222./usr/tests/usr.bin/xlint/lint1/emit.ln tests-obsolete obsolete
6221./usr/tests/usr.bin/xlint/lint1/expr_range.c tests-usr.bin-tests compattestfile,atf 6223./usr/tests/usr.bin/xlint/lint1/expr_range.c tests-usr.bin-tests compattestfile,atf
6222./usr/tests/usr.bin/xlint/lint1/expr_range.exp tests-usr.bin-tests compattestfile,atf 6224./usr/tests/usr.bin/xlint/lint1/expr_range.exp tests-usr.bin-tests compattestfile,atf
6223./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.c tests-usr.bin-tests compattestfile,atf 6225./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.c tests-usr.bin-tests compattestfile,atf
6224./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.exp tests-usr.bin-tests compattestfile,atf 6226./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.exp tests-usr.bin-tests compattestfile,atf
6225./usr/tests/usr.bin/xlint/lint1/gcc_attribute.c tests-usr.bin-tests compattestfile,atf 6227./usr/tests/usr.bin/xlint/lint1/gcc_attribute.c tests-usr.bin-tests compattestfile,atf

cvs diff -r1.83 -r1.84 src/tests/usr.bin/xlint/lint1/Makefile (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Makefile 2021/07/10 09:24:26 1.83
+++ src/tests/usr.bin/xlint/lint1/Makefile 2021/07/10 18:25:57 1.84
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.83 2021/07/10 09:24:26 rillig Exp $ 1# $NetBSD: Makefile,v 1.84 2021/07/10 18:25:57 rillig Exp $
2 2
3NOMAN= # defined 3NOMAN= # defined
4MAX_MESSAGE= 345 # see lint1/err.c 4MAX_MESSAGE= 345 # see lint1/err.c
5 5
6.include <bsd.own.mk> 6.include <bsd.own.mk>
7 7
8TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1 8TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1
9 9
10TESTS_SH= t_integration 10TESTS_SH= t_integration
11 11
12FILESDIR= ${TESTSDIR} 12FILESDIR= ${TESTSDIR}
13FILES+= c11_generic_expression.c 13FILES+= c11_generic_expression.c
14FILES+= c11_generic_expression.exp 14FILES+= c11_generic_expression.exp
@@ -98,26 +98,28 @@ FILES+= d_return_type.exp @@ -98,26 +98,28 @@ FILES+= d_return_type.exp
98FILES+= d_shift_to_narrower_type.c 98FILES+= d_shift_to_narrower_type.c
99FILES+= d_struct_init_nested.c 99FILES+= d_struct_init_nested.c
100FILES+= d_struct_init_nested.exp 100FILES+= d_struct_init_nested.exp
101FILES+= d_type_conv1.c 101FILES+= d_type_conv1.c
102FILES+= d_type_conv1.exp 102FILES+= d_type_conv1.exp
103FILES+= d_type_conv2.c 103FILES+= d_type_conv2.c
104FILES+= d_type_conv2.exp 104FILES+= d_type_conv2.exp
105FILES+= d_type_conv3.c 105FILES+= d_type_conv3.c
106FILES+= d_type_conv3.exp 106FILES+= d_type_conv3.exp
107FILES+= d_type_question_colon.c 107FILES+= d_type_question_colon.c
108FILES+= d_typefun.c 108FILES+= d_typefun.c
109FILES+= d_typename_as_var.c 109FILES+= d_typename_as_var.c
110FILES+= d_zero_sized_arrays.c 110FILES+= d_zero_sized_arrays.c
 111FILES+= decl.c
 112FILES+= decl.exp
111FILES+= decl_arg.c 113FILES+= decl_arg.c
112FILES+= decl_arg.exp 114FILES+= decl_arg.exp
113FILES+= decl_struct_member.c 115FILES+= decl_struct_member.c
114FILES+= decl_struct_member.exp 116FILES+= decl_struct_member.exp
115FILES+= emit.c 117FILES+= emit.c
116FILES+= emit.exp 118FILES+= emit.exp
117FILES+= emit.exp-ln 119FILES+= emit.exp-ln
118FILES+= expr_range.c 120FILES+= expr_range.c
119FILES+= expr_range.exp 121FILES+= expr_range.exp
120FILES+= feat_stacktrace.c 122FILES+= feat_stacktrace.c
121FILES+= feat_stacktrace.exp 123FILES+= feat_stacktrace.exp
122FILES+= gcc_attribute.c 124FILES+= gcc_attribute.c
123FILES+= gcc_attribute.exp 125FILES+= gcc_attribute.exp

File Added: src/tests/usr.bin/xlint/lint1/decl.c
/*	$NetBSD: decl.c,v 1.1 2021/07/10 18:25:57 rillig Exp $	*/
# 3 "decl.c"

/*
 * Tests for declarations, especially the distinction between the
 * declaration-specifiers and the declarators.
 */

/*
 * Even though 'const' comes after 'char' and is therefore quite close to the
 * first identifier, it applies to both identifiers.
 */
void
specifier_qualifier(void)
{
	char const a = 1, b = 2;

	/* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
	a = 1;
	/* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
	b = 2;
}

/*
 * Since 'const' comes before 'char', there is no ambiguity whether the
 * 'const' applies to all variables or just to the first.
 */
void
qualifier_specifier(void)
{
	const char a = 1, b = 2;

	/* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
	a = 3;
	/* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
	b = 5;
}

void
declarator_with_prefix_qualifier(void)
{
	/* expect+1: syntax error 'const' [249] */
	char a = 1, const b = 2;

	a = 1;
	/* expect+1: error: 'b' undefined [99] */
	b = 2;
}

void
declarator_with_postfix_qualifier(void)
{
	/* expect+1: syntax error 'const' [249] */
	char a = 1, b const = 2;

	a = 1;
	b = 2;
}

void sink(double *);

void
declarators(void)
{
	char *pc = 0, c = 0, **ppc = 0;

	/* expect+1: warning: converting 'pointer to char' to incompatible 'pointer to double' */
	sink(pc);
	/* expect+1: warning: illegal combination of pointer (pointer to double) and integer (char) */
	sink(c);
	/* expect+1: converting 'pointer to pointer to char' to incompatible 'pointer to double' */
	sink(ppc);
}

File Added: src/tests/usr.bin/xlint/lint1/Attic/decl.exp
decl.c(19): warning: left operand of '=' must be modifiable lvalue [115]
decl.c(21): warning: left operand of '=' must be modifiable lvalue [115]
decl.c(34): warning: left operand of '=' must be modifiable lvalue [115]
decl.c(36): warning: left operand of '=' must be modifiable lvalue [115]
decl.c(43): error: syntax error 'const' [249]
decl.c(47): error: 'b' undefined [99]
decl.c(54): error: syntax error 'const' [249]
decl.c(68): warning: converting 'pointer to char' to incompatible 'pointer to double' for argument 1 [153]
decl.c(70): warning: illegal combination of pointer (pointer to double) and integer (char), arg #1 [154]
decl.c(72): warning: converting 'pointer to pointer to char' to incompatible 'pointer to double' for argument 1 [153]