lint: remove support for obsolete GCC-style lvalue casts
Since GCC 4.0, a cast results in an rvalue.
This commit is contained in:
parent
6a7ac80c8d
commit
eb81ba228f
|
@ -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 @@ void
|
|||
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)++;
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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 @@ typeok_incdec(op_t op, const tnode_t *tn, const type_t *tp)
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue