Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: document history of in...
details: https://anonhg.NetBSD.org/src/rev/518367a4ee15
branches: trunk
changeset: 1022966:518367a4ee15
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Aug 16 16:19:47 2021 +0000
description:
tests/lint: document history of initialization of const members
diffstat:
tests/usr.bin/xlint/lint1/msg_115.c | 16 ++++++++++++++--
tests/usr.bin/xlint/lint1/msg_115.exp | 1 +
2 files changed, 15 insertions(+), 2 deletions(-)
diffs (45 lines):
diff -r 98fce8427a1e -r 518367a4ee15 tests/usr.bin/xlint/lint1/msg_115.c
--- a/tests/usr.bin/xlint/lint1/msg_115.c Mon Aug 16 06:56:20 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_115.c Mon Aug 16 16:19:47 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_115.c,v 1.8 2021/08/14 12:46:24 rillig Exp $ */
+/* $NetBSD: msg_115.c,v 1.9 2021/08/16 16:19:47 rillig Exp $ */
# 3 "msg_115.c"
// Test for message: %soperand of '%s' must be modifiable lvalue [115]
@@ -14,6 +14,10 @@
*const_ptr /= 5; /* expect: 115 */
*const_ptr %= 9; /* expect: 115 */
(*const_ptr)++; /* expect: 115 */
+
+ /* In the next example, the left operand is not an lvalue at all. */
+ /* expect+1: error: left operand of '=' must be lvalue [114] */
+ (const_ptr + 3) = const_ptr;
}
typedef struct {
@@ -22,7 +26,15 @@
void take_const_member(const_member);
-/* see typeok_assign, has_constant_member */
+/*
+ * Before init.c 1.208 from 2021-08-14 and decl.c 1.221 from 2021-08-10,
+ * lint issued a wrong "warning: left operand of '%s' must be modifiable
+ * lvalue", even in cases where the left operand was being initialized
+ * instead of overwritten.
+ *
+ * See initialization_expr_using_op, typeok_assign, has_constant_member.
+ * See C99 6.2.5p25.
+ */
const_member
initialize_const_struct_member(void)
{
diff -r 98fce8427a1e -r 518367a4ee15 tests/usr.bin/xlint/lint1/msg_115.exp
--- a/tests/usr.bin/xlint/lint1/msg_115.exp Mon Aug 16 06:56:20 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_115.exp Mon Aug 16 16:19:47 2021 +0000
@@ -5,3 +5,4 @@
msg_115.c(14): warning: left operand of '/=' must be modifiable lvalue [115]
msg_115.c(15): warning: left operand of '%=' must be modifiable lvalue [115]
msg_115.c(16): warning: operand of 'x++' must be modifiable lvalue [115]
+msg_115.c(20): error: left operand of '=' must be lvalue [114]
Home |
Main Index |
Thread Index |
Old Index