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 support for obsolete GCC-st...
details: https://anonhg.NetBSD.org/src/rev/f343c10f6c7e
branches: trunk
changeset: 1022100:f343c10f6c7e
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jul 04 12:24:38 2021 +0000
description:
lint: remove support for obsolete GCC-style lvalue casts
Since GCC 4.0, a cast results in an rvalue.
diffstat:
tests/usr.bin/xlint/lint1/msg_163.c | 20 +++++++++++++++++---
tests/usr.bin/xlint/lint1/msg_163.exp | 6 ++++--
usr.bin/xlint/lint1/tree.c | 6 ++----
3 files changed, 23 insertions(+), 9 deletions(-)
diffs (70 lines):
diff -r 9733b8e9d493 -r f343c10f6c7e tests/usr.bin/xlint/lint1/msg_163.c
--- a/tests/usr.bin/xlint/lint1/msg_163.c Sun Jul 04 11:25:07 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_163.c Sun Jul 04 12:24:38 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_163.c,v 1.3 2021/04/05 01:35:34 rillig Exp $ */
+/* $NetBSD: msg_163.c,v 1.4 2021/07/04 12:24:39 rillig Exp $ */
# 3 "msg_163.c"
// Test for message: a cast does not yield an lvalue [163]
@@ -7,7 +7,21 @@
example(char *p, int i)
{
p++;
- ((char *)p)++; /* XXX: why is this ok? */
+
+ /*
+ * Using a cast as an lvalue had been a GCC extension until 3.4.
+ * It was removed in GCC 4.0.
+ *
+ * https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Lvalues.html#Lvalues
+ * https://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/index.html#toc_C-Extensions
+ */
+ /* expect+2: error: a cast does not yield an lvalue [163] */
+ /* expect+1: error: operand of 'x++' must be lvalue [114] */
+ ((char *)p)++;
+
i++;
- ((int)i)++; /* expect: 163 *//* expect: 114 */
+
+ /* expect+2: error: a cast does not yield an lvalue [163] */
+ /* expect+1: error: operand of 'x++' must be lvalue [114] */
+ ((int)i)++;
}
diff -r 9733b8e9d493 -r f343c10f6c7e tests/usr.bin/xlint/lint1/msg_163.exp
--- a/tests/usr.bin/xlint/lint1/msg_163.exp Sun Jul 04 11:25:07 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_163.exp Sun Jul 04 12:24:38 2021 +0000
@@ -1,2 +1,4 @@
-msg_163.c(12): error: a cast does not yield an lvalue [163]
-msg_163.c(12): error: operand of 'x++' must be lvalue [114]
+msg_163.c(20): error: a cast does not yield an lvalue [163]
+msg_163.c(20): error: operand of 'x++' must be lvalue [114]
+msg_163.c(26): error: a cast does not yield an lvalue [163]
+msg_163.c(26): error: operand of 'x++' must be lvalue [114]
diff -r 9733b8e9d493 -r f343c10f6c7e usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sun Jul 04 11:25:07 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sun Jul 04 12:24:38 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.306 2021/07/04 09:13:59 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.307 2021/07/04 12:24:38 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.306 2021/07/04 09:13:59 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.307 2021/07/04 12:24:38 rillig Exp $");
#endif
#include <float.h>
@@ -760,8 +760,6 @@
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);
}
Home |
Main Index |
Thread Index |
Old Index