tests/lint: add test for unrealistic edge cases in declarations The example code for triggering these grammar rules looks completely contrived. Even if lint had not implemented these cases, hopefully nobody would have ever noticed.diff -r1.1080 -r1.1081 src/distrib/sets/lists/tests/mi
(rillig)
--- src/distrib/sets/lists/tests/mi 2021/07/09 05:54:11 1.1080
+++ src/distrib/sets/lists/tests/mi 2021/07/09 20:20:03 1.1081
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: mi,v 1.1080 2021/07/09 05:54:11 yamaguchi Exp $ | 1 | # $NetBSD: mi,v 1.1081 2021/07/09 20:20:03 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_arg.c tests-usr.bin-tests compattestfile,atf | |||
6214 | ./usr/tests/usr.bin/xlint/lint1/decl_arg.exp tests-usr.bin-tests compattestfile,atf | |||
6213 | ./usr/tests/usr.bin/xlint/lint1/decl_struct_member.c tests-usr.bin-tests compattestfile,atf | 6215 | ./usr/tests/usr.bin/xlint/lint1/decl_struct_member.c tests-usr.bin-tests compattestfile,atf | |
6214 | ./usr/tests/usr.bin/xlint/lint1/decl_struct_member.exp tests-usr.bin-tests compattestfile,atf | 6216 | ./usr/tests/usr.bin/xlint/lint1/decl_struct_member.exp tests-usr.bin-tests compattestfile,atf | |
6215 | ./usr/tests/usr.bin/xlint/lint1/emit.c tests-usr.bin-tests compattestfile,atf | 6217 | ./usr/tests/usr.bin/xlint/lint1/emit.c tests-usr.bin-tests compattestfile,atf | |
6216 | ./usr/tests/usr.bin/xlint/lint1/emit.exp tests-usr.bin-tests compattestfile,atf | 6218 | ./usr/tests/usr.bin/xlint/lint1/emit.exp tests-usr.bin-tests compattestfile,atf | |
6217 | ./usr/tests/usr.bin/xlint/lint1/emit.exp-ln tests-usr.bin-tests compattestfile,atf | 6219 | ./usr/tests/usr.bin/xlint/lint1/emit.exp-ln tests-usr.bin-tests compattestfile,atf | |
6218 | ./usr/tests/usr.bin/xlint/lint1/emit.ln tests-obsolete obsolete | 6220 | ./usr/tests/usr.bin/xlint/lint1/emit.ln tests-obsolete obsolete | |
6219 | ./usr/tests/usr.bin/xlint/lint1/expr_range.c tests-usr.bin-tests compattestfile,atf | 6221 | ./usr/tests/usr.bin/xlint/lint1/expr_range.c tests-usr.bin-tests compattestfile,atf | |
6220 | ./usr/tests/usr.bin/xlint/lint1/expr_range.exp tests-usr.bin-tests compattestfile,atf | 6222 | ./usr/tests/usr.bin/xlint/lint1/expr_range.exp tests-usr.bin-tests compattestfile,atf | |
6221 | ./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.c tests-usr.bin-tests compattestfile,atf | 6223 | ./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.c tests-usr.bin-tests compattestfile,atf | |
6222 | ./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.exp tests-usr.bin-tests compattestfile,atf | 6224 | ./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.exp tests-usr.bin-tests compattestfile,atf | |
6223 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute.c tests-usr.bin-tests compattestfile,atf | 6225 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute.c tests-usr.bin-tests compattestfile,atf | |
6224 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute.exp tests-usr.bin-tests compattestfile,atf | 6226 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute.exp tests-usr.bin-tests compattestfile,atf | |
6225 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c tests-usr.bin-tests compattestfile,atf | 6227 | ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c tests-usr.bin-tests compattestfile,atf |
--- src/tests/usr.bin/xlint/lint1/Makefile 2021/07/08 05:18:49 1.81
+++ src/tests/usr.bin/xlint/lint1/Makefile 2021/07/09 20:20:03 1.82
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: Makefile,v 1.81 2021/07/08 05:18:49 rillig Exp $ | 1 | # $NetBSD: Makefile,v 1.82 2021/07/09 20:20:03 rillig Exp $ | |
2 | 2 | |||
3 | NOMAN= # defined | 3 | NOMAN= # defined | |
4 | MAX_MESSAGE= 345 # see lint1/err.c | 4 | MAX_MESSAGE= 345 # see lint1/err.c | |
5 | 5 | |||
6 | .include <bsd.own.mk> | 6 | .include <bsd.own.mk> | |
7 | 7 | |||
8 | TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1 | 8 | TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1 | |
9 | 9 | |||
10 | TESTS_SH= t_integration | 10 | TESTS_SH= t_integration | |
11 | 11 | |||
12 | FILESDIR= ${TESTSDIR} | 12 | FILESDIR= ${TESTSDIR} | |
13 | FILES+= c11_generic_expression.c | 13 | FILES+= c11_generic_expression.c | |
14 | FILES+= c11_generic_expression.exp | 14 | FILES+= c11_generic_expression.exp | |
@@ -98,26 +98,28 @@ FILES+= d_return_type.exp | @@ -98,26 +98,28 @@ FILES+= d_return_type.exp | |||
98 | FILES+= d_shift_to_narrower_type.c | 98 | FILES+= d_shift_to_narrower_type.c | |
99 | FILES+= d_struct_init_nested.c | 99 | FILES+= d_struct_init_nested.c | |
100 | FILES+= d_struct_init_nested.exp | 100 | FILES+= d_struct_init_nested.exp | |
101 | FILES+= d_type_conv1.c | 101 | FILES+= d_type_conv1.c | |
102 | FILES+= d_type_conv1.exp | 102 | FILES+= d_type_conv1.exp | |
103 | FILES+= d_type_conv2.c | 103 | FILES+= d_type_conv2.c | |
104 | FILES+= d_type_conv2.exp | 104 | FILES+= d_type_conv2.exp | |
105 | FILES+= d_type_conv3.c | 105 | FILES+= d_type_conv3.c | |
106 | FILES+= d_type_conv3.exp | 106 | FILES+= d_type_conv3.exp | |
107 | FILES+= d_type_question_colon.c | 107 | FILES+= d_type_question_colon.c | |
108 | FILES+= d_typefun.c | 108 | FILES+= d_typefun.c | |
109 | FILES+= d_typename_as_var.c | 109 | FILES+= d_typename_as_var.c | |
110 | FILES+= d_zero_sized_arrays.c | 110 | FILES+= d_zero_sized_arrays.c | |
111 | FILES+= decl_arg.c | |||
112 | FILES+= decl_arg.exp | |||
111 | FILES+= decl_struct_member.c | 113 | FILES+= decl_struct_member.c | |
112 | FILES+= decl_struct_member.exp | 114 | FILES+= decl_struct_member.exp | |
113 | FILES+= emit.c | 115 | FILES+= emit.c | |
114 | FILES+= emit.exp | 116 | FILES+= emit.exp | |
115 | FILES+= emit.exp-ln | 117 | FILES+= emit.exp-ln | |
116 | FILES+= expr_range.c | 118 | FILES+= expr_range.c | |
117 | FILES+= expr_range.exp | 119 | FILES+= expr_range.exp | |
118 | FILES+= feat_stacktrace.c | 120 | FILES+= feat_stacktrace.c | |
119 | FILES+= feat_stacktrace.exp | 121 | FILES+= feat_stacktrace.exp | |
120 | FILES+= gcc_attribute.c | 122 | FILES+= gcc_attribute.c | |
121 | FILES+= gcc_attribute.exp | 123 | FILES+= gcc_attribute.exp | |
122 | FILES+= gcc_attribute_aligned.c | 124 | FILES+= gcc_attribute_aligned.c | |
123 | FILES+= gcc_attribute_aligned.exp | 125 | FILES+= gcc_attribute_aligned.exp |
/* $NetBSD: decl_arg.c,v 1.1 2021/07/09 20:20:03 rillig Exp $ */
# 3 "decl_arg.c"
/*
* Tests for declarations of function arguments.
*
* See arg_declaration in cgram.y.
*/
typedef double number;
void no_args(void);
void type_unnamed(double );
void type_named(double arg);
void typedef_unnamed_prototype(number);
void typedef_named(number arg);
void type_qualifier(const number);
void type_qualifier_pointer(const number *const);
/*
* Just some unrealistic coverage for the grammar rule 'arg_declaration'.
*/
/* expect+6: warning: argument 'an_int' unused in function 'old_style' [231] */
/* expect+5: warning: argument 'a_const_int' unused in function 'old_style' [231] */
/* expect+4: warning: argument 'a_number' unused in function 'old_style' [231] */
/* expect+3: warning: argument 'a_function' unused in function 'old_style' [231] */
/* expect+2: warning: argument 'a_struct' unused in function 'old_style' [231] */
extern void
old_style(an_int, a_const_int, a_number, a_function, a_struct)
/* expect+2: warning: empty declaration [2] */
/* expect+1: error: only register valid as formal parameter storage class [9] */
static;
/* expect+1: error: syntax error '"' [249] */
static "error";
/* expect+1: warning: empty declaration [2] */
const;
/* expect+1: error: declared argument undeclared is missing [53] */
const undeclared;
/* expect+2: error: declared argument undeclared_initialized is missing [53] */
/* expect+1: error: cannot initialize parameter: undeclared_initialized [52] */
const undeclared_initialized = 12345;
/* expect+1: warning: empty declaration [2] */
int;
/* expect+1: warning: 'struct arg_struct' declared in argument declaration list [3] */
struct arg_struct { int member; };
/* expect+1: error: cannot initialize parameter: an_int [52] */
int an_int = 12345;
const int a_const_int;
number a_number;
void (a_function) (number);
/* expect+1: warning: 'struct a_struct' declared in argument declaration list [3] */
struct a_struct { int member; } a_struct;
{
}
/*
* Just some unrealistic coverage for the grammar rule 'notype_direct_decl'.
*/
extern int
cover_notype_direct_decl(arg)
int arg;
/* expect+1: error: declared argument name is missing [53] */
const name;
/* expect+1: error: declared argument parenthesized_name is missing [53] */
const (parenthesized_name);
/* expect+1: error: declared argument array is missing [53] */
const array[];
/* expect+1: error: declared argument array_size is missing [53] */
const array_size[1+1+1];
/* expect+2: error: declared argument multi_array is missing [53] */
/* expect+1: error: null dimension [17] */
const multi_array[][][][][][];
/* expect+1: error: declared argument function is missing [53] */
const function(void);
/* expect+1: error: declared argument prefix_attribute is missing [53] */
const __attribute__((deprecated)) prefix_attribute;
/* expect+1: error: declared argument postfix_attribute is missing [53] */
const postfix_attribute __attribute__((deprecated));
/* expect+1: error: declared argument infix_attribute is missing [53] */
const __attribute__((deprecated)) infix_attribute __attribute__((deprecated));
/* The __attribute__ before the '*' is consumed by some other grammar rule. */
/* expect+7: error: declared argument pointer_prefix_attribute is missing [53] */
const
__attribute__((deprecated))
*
__attribute__((deprecated))
__attribute__((deprecated))
__attribute__((deprecated))
pointer_prefix_attribute;
{
return arg;
}
decl_arg.c(33): error: only register valid as formal parameter storage class [9]
decl_arg.c(33): warning: empty declaration [2]
decl_arg.c(35): error: syntax error '"' [249]
decl_arg.c(37): warning: empty declaration [2]
decl_arg.c(39): error: declared argument undeclared is missing [53]
decl_arg.c(42): error: declared argument undeclared_initialized is missing [53]
decl_arg.c(42): error: cannot initialize parameter: undeclared_initialized [52]
decl_arg.c(44): warning: empty declaration [2]
decl_arg.c(46): warning: 'struct arg_struct' declared in argument declaration list [3]
decl_arg.c(48): error: cannot initialize parameter: an_int [52]
decl_arg.c(53): warning: 'struct a_struct' declared in argument declaration list [3]
decl_arg.c(30): warning: argument 'an_int' unused in function 'old_style' [231]
decl_arg.c(30): warning: argument 'a_const_int' unused in function 'old_style' [231]
decl_arg.c(30): warning: argument 'a_number' unused in function 'old_style' [231]
decl_arg.c(30): warning: argument 'a_function' unused in function 'old_style' [231]
decl_arg.c(30): warning: argument 'a_struct' unused in function 'old_style' [231]
decl_arg.c(64): error: declared argument name is missing [53]
decl_arg.c(66): error: declared argument parenthesized_name is missing [53]
decl_arg.c(68): error: declared argument array is missing [53]
decl_arg.c(70): error: declared argument array_size is missing [53]
decl_arg.c(73): error: null dimension [17]
decl_arg.c(73): error: declared argument multi_array is missing [53]
decl_arg.c(75): error: declared argument function is missing [53]
decl_arg.c(77): error: declared argument prefix_attribute is missing [53]
decl_arg.c(79): error: declared argument postfix_attribute is missing [53]
decl_arg.c(81): error: declared argument infix_attribute is missing [53]
decl_arg.c(90): error: declared argument pointer_prefix_attribute is missing [53]