Sun Jul 4 17:28:06 2021 UTC ()
lint: replace wrong assumption with citation from C99

No functional change.


(rillig)
diff -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_101.c
diff -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_101.exp
diff -r1.311 -r1.312 src/usr.bin/xlint/lint1/tree.c

cvs diff -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_101.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/msg_101.c 2021/07/04 17:16:09 1.8
+++ src/tests/usr.bin/xlint/lint1/msg_101.c 2021/07/04 17:28:06 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: msg_101.c,v 1.8 2021/07/04 17:16:09 rillig Exp $ */ 1/* $NetBSD: msg_101.c,v 1.9 2021/07/04 17:28:06 rillig Exp $ */
2# 3 "msg_101.c" 2# 3 "msg_101.c"
3 3
4// Test for message: type '%s' does not have member '%s' [101] 4// Test for message: type '%s' does not have member '%s' [101]
5 5
6struct point { 6struct point {
7 int x, y; 7 int x, y;
8}; 8};
9 9
10void sink(int); 10void sink(int);
11 11
12void 12void
13test(const struct point *ptr, const struct point pt) 13test(const struct point *ptr, const struct point pt)
14{ 14{
@@ -21,17 +21,16 @@ test(const struct point *ptr, const stru @@ -21,17 +21,16 @@ test(const struct point *ptr, const stru
21 sink(ptr->z); 21 sink(ptr->z);
22 /* expect+1: error: type 'const struct point' does not have member 'z' [101] */ 22 /* expect+1: error: type 'const struct point' does not have member 'z' [101] */
23 sink(pt.z); 23 sink(pt.z);
24 24
25 /* mixed up '.' and '->' */ 25 /* mixed up '.' and '->' */
26 /* expect+1: error: left operand of '.' must be struct or union, not 'pointer to const struct point' [103] */ 26 /* expect+1: error: left operand of '.' must be struct or union, not 'pointer to const struct point' [103] */
27 sink(ptr.x); 27 sink(ptr.x);
28 /* expect+1: error: left operand of '->' must be pointer to struct or union, not 'struct point' [104] */ 28 /* expect+1: error: left operand of '->' must be pointer to struct or union, not 'struct point' [104] */
29 sink(pt->x); 29 sink(pt->x);
30 30
31 /* accessing a nonexistent member via the wrong operator */ 31 /* accessing a nonexistent member via the wrong operator */
32 /* expect+1: error: type 'pointer to const struct point' does not have member 'z' [101] */ 32 /* expect+1: error: type 'pointer to const struct point' does not have member 'z' [101] */
33 sink(ptr.z); 33 sink(ptr.z);
34 /* FIXME: In cconv, don't set t_const unconditionally to false. */ 
35 /* expect+1: error: type 'struct point' does not have member 'z' [101] */ 34 /* expect+1: error: type 'struct point' does not have member 'z' [101] */
36 sink(pt->z); 35 sink(pt->z);
37} 36}

cvs diff -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/Attic/msg_101.exp (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/msg_101.exp 2021/07/04 17:01:58 1.7
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_101.exp 2021/07/04 17:28:06 1.8
@@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
1msg_101.c(21): error: type 'pointer to const struct point' does not have member 'z' [101] 1msg_101.c(21): error: type 'pointer to const struct point' does not have member 'z' [101]
2msg_101.c(23): error: type 'const struct point' does not have member 'z' [101] 2msg_101.c(23): error: type 'const struct point' does not have member 'z' [101]
3msg_101.c(27): error: left operand of '.' must be struct or union, not 'pointer to const struct point' [103] 3msg_101.c(27): error: left operand of '.' must be struct or union, not 'pointer to const struct point' [103]
4msg_101.c(29): error: left operand of '->' must be pointer to struct or union, not 'struct point' [104] 4msg_101.c(29): error: left operand of '->' must be pointer to struct or union, not 'struct point' [104]
5msg_101.c(33): error: type 'pointer to const struct point' does not have member 'z' [101] 5msg_101.c(33): error: type 'pointer to const struct point' does not have member 'z' [101]
6msg_101.c(36): error: type 'struct point' does not have member 'z' [101] 6msg_101.c(35): error: type 'struct point' does not have member 'z' [101]

cvs diff -r1.311 -r1.312 src/usr.bin/xlint/lint1/tree.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/tree.c 2021/07/04 17:16:09 1.311
+++ src/usr.bin/xlint/lint1/tree.c 2021/07/04 17:28:05 1.312
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tree.c,v 1.311 2021/07/04 17:16:09 rillig Exp $ */ 1/* $NetBSD: tree.c,v 1.312 2021/07/04 17:28:05 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Jochen Pohl 4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#if HAVE_NBTOOL_CONFIG_H 34#if HAVE_NBTOOL_CONFIG_H
35#include "nbtool_config.h" 35#include "nbtool_config.h"
36#endif 36#endif
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39#if defined(__RCSID) && !defined(lint) 39#if defined(__RCSID) && !defined(lint)
40__RCSID("$NetBSD: tree.c,v 1.311 2021/07/04 17:16:09 rillig Exp $"); 40__RCSID("$NetBSD: tree.c,v 1.312 2021/07/04 17:28:05 rillig Exp $");
41#endif 41#endif
42 42
43#include <float.h> 43#include <float.h>
44#include <limits.h> 44#include <limits.h>
45#include <math.h> 45#include <math.h>
46#include <signal.h> 46#include <signal.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <string.h> 48#include <string.h>
49 49
50#include "lint1.h" 50#include "lint1.h"
51#include "cgram.h" 51#include "cgram.h"
52 52
53static tnode_t *expr_new_integer_constant(tspec_t, int64_t); 53static tnode_t *expr_new_integer_constant(tspec_t, int64_t);
@@ -718,27 +718,27 @@ cconv(tnode_t *tn) @@ -718,27 +718,27 @@ cconv(tnode_t *tn)
718 } 718 }
719 719
720 /* 720 /*
721 * Expression of type function (function with return value of type T) 721 * Expression of type function (function with return value of type T)
722 * in rvalue-expression (pointer to function with return value 722 * in rvalue-expression (pointer to function with return value
723 * of type T) 723 * of type T)
724 */ 724 */
725 if (tn->tn_type->t_tspec == FUNC) 725 if (tn->tn_type->t_tspec == FUNC)
726 tn = build_address(tn, true); 726 tn = build_address(tn, true);
727 727
728 /* lvalue to rvalue */ 728 /* lvalue to rvalue */
729 if (tn->tn_lvalue) { 729 if (tn->tn_lvalue) {
730 tp = expr_dup_type(tn->tn_type); 730 tp = expr_dup_type(tn->tn_type);
731 /* FIXME: even rvalues can be const/volatile, see msg_101 */ 731 /* C99 6.3.2.1p2 sentence 2 says to remove the qualifiers. */
732 tp->t_const = tp->t_volatile = false; 732 tp->t_const = tp->t_volatile = false;
733 tn = new_tnode(LOAD, tp, tn, NULL); 733 tn = new_tnode(LOAD, tp, tn, NULL);
734 } 734 }
735 735
736 return tn; 736 return tn;
737} 737}
738 738
739const tnode_t * 739const tnode_t *
740before_conversion(const tnode_t *tn) 740before_conversion(const tnode_t *tn)
741{ 741{
742 while (tn->tn_op == CVT && !tn->tn_cast) 742 while (tn->tn_op == CVT && !tn->tn_cast)
743 tn = tn->tn_left; 743 tn = tn->tn_left;
744 return tn; 744 return tn;