Sat Jul 10 08:40:36 2021 UTC ()
tests/lint: add code coverage for grammar rule parameter_declaration


(rillig)
diff -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/decl_arg.c
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/decl_arg.exp

cvs diff -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/decl_arg.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/decl_arg.c 2021/07/10 08:01:11 1.3
+++ src/tests/usr.bin/xlint/lint1/decl_arg.c 2021/07/10 08:40:36 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: decl_arg.c,v 1.3 2021/07/10 08:01:11 rillig Exp $ */ 1/* $NetBSD: decl_arg.c,v 1.4 2021/07/10 08:40:36 rillig Exp $ */
2# 3 "decl_arg.c" 2# 3 "decl_arg.c"
3 3
4/* 4/*
5 * Tests for declarations of function arguments. 5 * Tests for declarations of function arguments.
6 * 6 *
7 * See arg_declaration in cgram.y. 7 * See arg_declaration in cgram.y.
8 */ 8 */
9 9
10typedef double number; 10typedef double number;
11 11
12void no_args(void); 12void no_args(void);
13void type_unnamed(double ); 13void type_unnamed(double );
14void type_named(double arg); 14void type_named(double arg);
@@ -92,19 +92,34 @@ const @@ -92,19 +92,34 @@ const
92 return arg; 92 return arg;
93} 93}
94 94
95void test_varargs_attribute( 95void test_varargs_attribute(
96 void (*pr)(const char *, ...) 96 void (*pr)(const char *, ...)
97 __attribute__((__format__(__printf__, 1, 2))) 97 __attribute__((__format__(__printf__, 1, 2)))
98); 98);
99 99
100/* 100/*
101 * XXX: To cover the grammar rule 'direct_notype_param_decl', the parameters 101 * XXX: To cover the grammar rule 'direct_notype_param_decl', the parameters
102 * need to be enclosed by one more pair of parentheses than usual. 102 * need to be enclosed by one more pair of parentheses than usual.
103 */ 103 */
104void cover_direct_notype_param_decl( 104void cover_direct_notype_param_decl(
105 double (f1), 105 double (identifier),
106 double ((parenthesized)), 106 double ((parenthesized)),
107 double (array[]), 107 double (array[]),
108 double (array_size[3]), 108 double (array_size[3]),
109 double (*)(void (function())) 109 double (*)(void (function()))
110); 110);
 111
 112/*
 113 * Just some unrealistic code to cover the grammar rule parameter_declaration.
 114 */
 115/* expect+4: error: only register valid as formal parameter storage class [9] */
 116void cover_parameter_declaration(
 117 volatile, /* 1 */
 118 double, /* 2 */
 119 static storage_class, /* 3.1 */
 120 const type_qualifier, /* 3.2 */
 121 double (identifier), /* 4 */
 122 const (*), /* 5 */
 123 double *const, /* 6 */
 124 ...
 125);

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/Attic/decl_arg.exp (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/decl_arg.exp 2021/07/09 20:20:03 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/decl_arg.exp 2021/07/10 08:40:36 1.2
@@ -15,13 +15,14 @@ decl_arg.c(30): warning: argument 'a_num @@ -15,13 +15,14 @@ decl_arg.c(30): warning: argument 'a_num
15decl_arg.c(30): warning: argument 'a_function' unused in function 'old_style' [231] 15decl_arg.c(30): warning: argument 'a_function' unused in function 'old_style' [231]
16decl_arg.c(30): warning: argument 'a_struct' unused in function 'old_style' [231] 16decl_arg.c(30): warning: argument 'a_struct' unused in function 'old_style' [231]
17decl_arg.c(64): error: declared argument name is missing [53] 17decl_arg.c(64): error: declared argument name is missing [53]
18decl_arg.c(66): error: declared argument parenthesized_name is missing [53] 18decl_arg.c(66): error: declared argument parenthesized_name is missing [53]
19decl_arg.c(68): error: declared argument array is missing [53] 19decl_arg.c(68): error: declared argument array is missing [53]
20decl_arg.c(70): error: declared argument array_size is missing [53] 20decl_arg.c(70): error: declared argument array_size is missing [53]
21decl_arg.c(73): error: null dimension [17] 21decl_arg.c(73): error: null dimension [17]
22decl_arg.c(73): error: declared argument multi_array is missing [53] 22decl_arg.c(73): error: declared argument multi_array is missing [53]
23decl_arg.c(75): error: declared argument function is missing [53] 23decl_arg.c(75): error: declared argument function is missing [53]
24decl_arg.c(77): error: declared argument prefix_attribute is missing [53] 24decl_arg.c(77): error: declared argument prefix_attribute is missing [53]
25decl_arg.c(79): error: declared argument postfix_attribute is missing [53] 25decl_arg.c(79): error: declared argument postfix_attribute is missing [53]
26decl_arg.c(81): error: declared argument infix_attribute is missing [53] 26decl_arg.c(81): error: declared argument infix_attribute is missing [53]
27decl_arg.c(90): error: declared argument pointer_prefix_attribute is missing [53] 27decl_arg.c(90): error: declared argument pointer_prefix_attribute is missing [53]
 28decl_arg.c(119): error: only register valid as formal parameter storage class [9]