Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: remove remaining support for lvalu...
details: https://anonhg.NetBSD.org/src/rev/139e73ec36c9
branches: trunk
changeset: 984351:139e73ec36c9
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jul 04 13:14:53 2021 +0000
description:
lint: remove remaining support for lvalue casts
These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.
diffstat:
distrib/sets/lists/tests/mi | 3 ++-
tests/usr.bin/xlint/lint1/Makefile | 3 ++-
tests/usr.bin/xlint/lint1/d_cast_lhs.c | 27 +++++++++++++++++++--------
tests/usr.bin/xlint/lint1/d_cast_lhs.exp | 4 ++++
usr.bin/xlint/lint1/tree.c | 8 ++------
5 files changed, 29 insertions(+), 16 deletions(-)
diffs (119 lines):
diff -r 74a83461688c -r 139e73ec36c9 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun Jul 04 12:57:48 2021 +0000
+++ b/distrib/sets/lists/tests/mi Sun Jul 04 13:14:53 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1074 2021/07/04 08:19:05 rillig Exp $
+# $NetBSD: mi,v 1.1075 2021/07/04 13:14:53 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6151,6 +6151,7 @@
./usr/tests/usr.bin/xlint/lint1/d_cast_init.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_cast_init2.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_cast_lhs.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_cast_lhs.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_cast_typeof.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_compound_literals1.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_compound_literals2.c tests-usr.bin-tests compattestfile,atf
diff -r 74a83461688c -r 139e73ec36c9 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile Sun Jul 04 12:57:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile Sun Jul 04 13:14:53 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.77 2021/07/04 08:50:26 rillig Exp $
+# $NetBSD: Makefile,v 1.78 2021/07/04 13:14:54 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 345 # see lint1/err.c
@@ -55,6 +55,7 @@
FILES+= d_cast_init.c
FILES+= d_cast_init2.c
FILES+= d_cast_lhs.c
+FILES+= d_cast_lhs.exp
FILES+= d_cast_typeof.c
FILES+= d_compound_literals1.c
FILES+= d_compound_literals2.c
diff -r 74a83461688c -r 139e73ec36c9 tests/usr.bin/xlint/lint1/d_cast_lhs.c
--- a/tests/usr.bin/xlint/lint1/d_cast_lhs.c Sun Jul 04 12:57:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_cast_lhs.c Sun Jul 04 13:14:53 2021 +0000
@@ -1,18 +1,29 @@
-/* $NetBSD: d_cast_lhs.c,v 1.4 2021/03/27 13:59:18 rillig Exp $ */
+/* $NetBSD: d_cast_lhs.c,v 1.5 2021/07/04 13:14:54 rillig Exp $ */
# 3 "d_cast_lhs.c"
/*
- * pointer casts are valid lhs lvalues
+ * Pointer casts had been valid lvalues in GCC before 4.0.
+ *
+ * https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Lvalues.html#Lvalues
*
- * XXX: C99 6.5.4 "Cast operators" footnote 85 says "A cast does not yield an
- * lvalue". It does not mention any exceptional rule for pointers.
+ * C99 6.5.4 "Cast operators" footnote 85 says "A cast does not yield an
+ * lvalue".
*/
-struct sockaddr {
+struct str {
+ int member;
};
+void sink(const void *);
+
+/* ARGSUSED */
void
-foo()
+foo(void *p)
{
- unsigned long p = 6;
- ((struct sockaddr *)p) = 0;
+ /* expect+2: error: a cast does not yield an lvalue [163] */
+ /* expect+1: error: left operand of '=' must be lvalue [114] */
+ ((struct str *)p) = 0;
+
+ /* expect+2: error: a cast does not yield an lvalue [163] */
+ /* expect+1: error: operand of '&' must be lvalue [114] */
+ sink(&(const void *)p);
}
diff -r 74a83461688c -r 139e73ec36c9 tests/usr.bin/xlint/lint1/d_cast_lhs.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/d_cast_lhs.exp Sun Jul 04 13:14:53 2021 +0000
@@ -0,0 +1,4 @@
+d_cast_lhs.c(24): error: a cast does not yield an lvalue [163]
+d_cast_lhs.c(24): error: left operand of '=' must be lvalue [114]
+d_cast_lhs.c(28): error: a cast does not yield an lvalue [163]
+d_cast_lhs.c(28): error: operand of '&' must be lvalue [114]
diff -r 74a83461688c -r 139e73ec36c9 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sun Jul 04 12:57:48 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sun Jul 04 13:14:53 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.307 2021/07/04 12:24:38 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.308 2021/07/04 13:14:54 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.307 2021/07/04 12:24:38 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.308 2021/07/04 13:14:54 rillig Exp $");
#endif
#include <float.h>
@@ -783,8 +783,6 @@
} else if (!tn->tn_lvalue) {
if (tn->tn_op == CVT && tn->tn_cast &&
tn->tn_left->tn_op == LOAD) {
- if (tn->tn_type->t_tspec == PTR)
- return true;
/* a cast does not yield an lvalue */
error(163);
}
@@ -1073,8 +1071,6 @@
if (!ln->tn_lvalue) {
if (ln->tn_op == CVT && ln->tn_cast &&
ln->tn_left->tn_op == LOAD) {
- if (ln->tn_type->t_tspec == PTR)
- return true;
/* a cast does not yield an lvalue */
error(163);
}
Home |
Main Index |
Thread Index |
Old Index