Sun Jul 11 12:12:30 2021 UTC ()
tests/lint: parse error for unused variable (since 2021-07-10)

Since cgram.y 1.294 from 2021-07-10.


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

cvs diff -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/decl.c (switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/decl.c 2021/07/10 19:30:19 1.2
+++ src/tests/usr.bin/xlint/lint1/decl.c 2021/07/11 12:12:30 1.3
@@ -1,88 +1,100 @@ @@ -1,88 +1,100 @@
1/* $NetBSD: decl.c,v 1.2 2021/07/10 19:30:19 rillig Exp $ */ 1/* $NetBSD: decl.c,v 1.3 2021/07/11 12:12:30 rillig Exp $ */
2# 3 "decl.c" 2# 3 "decl.c"
3 3
4/* 4/*
5 * Tests for declarations, especially the distinction between the 5 * Tests for declarations, especially the distinction between the
6 * declaration-specifiers and the declarators. 6 * declaration-specifiers and the declarators.
7 */ 7 */
8 8
9/* 9/*
10 * Even though 'const' comes after 'char' and is therefore quite close to the 10 * Even though 'const' comes after 'char' and is therefore quite close to the
11 * first identifier, it applies to both identifiers. 11 * first identifier, it applies to both identifiers.
12 */ 12 */
13void 13void
14specifier_qualifier(void) 14specifier_qualifier(void)
15{ 15{
16 char const a = 1, b = 2; 16 char const a = 1, b = 2;
17 17
18 /* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */ 18 /* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
19 a = 1; 19 a = 1;
20 /* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */ 20 /* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
21 b = 2; 21 b = 2;
22} 22}
23 23
24/* 24/*
25 * Since 'const' comes before 'char', there is no ambiguity whether the 25 * Since 'const' comes before 'char', there is no ambiguity whether the
26 * 'const' applies to all variables or just to the first. 26 * 'const' applies to all variables or just to the first.
27 */ 27 */
28void 28void
29qualifier_specifier(void) 29qualifier_specifier(void)
30{ 30{
31 const char a = 1, b = 2; 31 const char a = 1, b = 2;
32 32
33 /* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */ 33 /* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
34 a = 3; 34 a = 3;
35 /* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */ 35 /* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
36 b = 5; 36 b = 5;
37} 37}
38 38
39void 39void
40declarator_with_prefix_qualifier(void) 40declarator_with_prefix_qualifier(void)
41{ 41{
42 /* expect+1: syntax error 'const' [249] */ 42 /* expect+1: syntax error 'const' [249] */
43 char a = 1, const b = 2; 43 char a = 1, const b = 2;
44 44
45 a = 1; 45 a = 1;
46 /* expect+1: error: 'b' undefined [99] */ 46 /* expect+1: error: 'b' undefined [99] */
47 b = 2; 47 b = 2;
48} 48}
49 49
50void 50void
51declarator_with_postfix_qualifier(void) 51declarator_with_postfix_qualifier(void)
52{ 52{
53 /* expect+1: syntax error 'const' [249] */ 53 /* expect+1: syntax error 'const' [249] */
54 char a = 1, b const = 2; 54 char a = 1, b const = 2;
55 55
56 a = 1; 56 a = 1;
57 b = 2; 57 b = 2;
58} 58}
59 59
60void sink(double *); 60void sink(double *);
61 61
62void 62void
63declarators(void) 63declarators(void)
64{ 64{
65 char *pc = 0, c = 0, **ppc = 0; 65 char *pc = 0, c = 0, **ppc = 0;
66 66
67 /* expect+1: warning: converting 'pointer to char' to incompatible 'pointer to double' */ 67 /* expect+1: warning: converting 'pointer to char' to incompatible 'pointer to double' */
68 sink(pc); 68 sink(pc);
69 /* expect+1: warning: illegal combination of pointer (pointer to double) and integer (char) */ 69 /* expect+1: warning: illegal combination of pointer (pointer to double) and integer (char) */
70 sink(c); 70 sink(c);
71 /* expect+1: converting 'pointer to pointer to char' to incompatible 'pointer to double' */ 71 /* expect+1: converting 'pointer to pointer to char' to incompatible 'pointer to double' */
72 sink(ppc); 72 sink(ppc);
73} 73}
74 74
75_Bool 75_Bool
76enum_error_handling(void) 76enum_error_handling(void)
77{ 77{
78 enum { 78 enum {
79 /* expect+1: syntax error '"' [249] */ 79 /* expect+1: syntax error '"' [249] */
80 "error 1" 80 "error 1"
81 : /* still the same error */ 81 : /* still the same error */
82 , /* back on track */ 82 , /* back on track */
83 A, 83 A,
84 B 84 B
85 } x = A; 85 } x = A;
86 86
87 return x == B; 87 return x == B;
88} 88}
 89
 90void
 91unused_local_variable(void)
 92{
 93 /*FIXME*//* expect+1: syntax error '_Bool' [249] */
 94 __attribute__((unused)) _Bool unused_var;
 95
 96 __attribute__((unused))
 97 /*FIXME*//* expect+2: syntax error '__attribute__' [249] */
 98 /*FIXME*//* expect+1: cannot recover from previous errors [224] */
 99 __attribute__((unused)) _Bool unused_twice;
 100}

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

--- src/tests/usr.bin/xlint/lint1/Attic/decl.exp 2021/07/10 19:30:19 1.2
+++ src/tests/usr.bin/xlint/lint1/Attic/decl.exp 2021/07/11 12:12:30 1.3
@@ -1,11 +1,14 @@ @@ -1,11 +1,14 @@
1decl.c(19): warning: left operand of '=' must be modifiable lvalue [115] 1decl.c(19): warning: left operand of '=' must be modifiable lvalue [115]
2decl.c(21): warning: left operand of '=' must be modifiable lvalue [115] 2decl.c(21): warning: left operand of '=' must be modifiable lvalue [115]
3decl.c(34): warning: left operand of '=' must be modifiable lvalue [115] 3decl.c(34): warning: left operand of '=' must be modifiable lvalue [115]
4decl.c(36): warning: left operand of '=' must be modifiable lvalue [115] 4decl.c(36): warning: left operand of '=' must be modifiable lvalue [115]
5decl.c(43): error: syntax error 'const' [249] 5decl.c(43): error: syntax error 'const' [249]
6decl.c(47): error: 'b' undefined [99] 6decl.c(47): error: 'b' undefined [99]
7decl.c(54): error: syntax error 'const' [249] 7decl.c(54): error: syntax error 'const' [249]
8decl.c(68): warning: converting 'pointer to char' to incompatible 'pointer to double' for argument 1 [153] 8decl.c(68): warning: converting 'pointer to char' to incompatible 'pointer to double' for argument 1 [153]
9decl.c(70): warning: illegal combination of pointer (pointer to double) and integer (char), arg #1 [154] 9decl.c(70): warning: illegal combination of pointer (pointer to double) and integer (char), arg #1 [154]
10decl.c(72): warning: converting 'pointer to pointer to char' to incompatible 'pointer to double' for argument 1 [153] 10decl.c(72): warning: converting 'pointer to pointer to char' to incompatible 'pointer to double' for argument 1 [153]
11decl.c(80): error: syntax error '"' [249] 11decl.c(80): error: syntax error '"' [249]
 12decl.c(94): error: syntax error '_Bool' [249]
 13decl.c(99): error: syntax error '__attribute__' [249]
 14decl.c(99): error: cannot recover from previous errors [224]