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: add test for incrementing const va...



details:   https://anonhg.NetBSD.org/src/rev/4adb61cd0dd3
branches:  trunk
changeset: 958719:4adb61cd0dd3
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 17 16:19:54 2021 +0000

description:
lint: add test for incrementing const variable

diffstat:

 tests/usr.bin/xlint/lint1/msg_115.c   |  3 ++-
 tests/usr.bin/xlint/lint1/msg_115.exp |  1 +
 usr.bin/xlint/lint1/tree.c            |  6 +++---
 3 files changed, 6 insertions(+), 4 deletions(-)

diffs (50 lines):

diff -r a1ed3492192b -r 4adb61cd0dd3 tests/usr.bin/xlint/lint1/msg_115.c
--- a/tests/usr.bin/xlint/lint1/msg_115.c       Sun Jan 17 16:16:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_115.c       Sun Jan 17 16:19:54 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_115.c,v 1.2 2021/01/08 21:25:03 rillig Exp $       */
+/*     $NetBSD: msg_115.c,v 1.3 2021/01/17 16:19:54 rillig Exp $       */
 # 3 "msg_115.c"
 
 // Test for message: %soperand of '%s' must be modifiable lvalue [115]
@@ -13,4 +13,5 @@
        *const_ptr *= 1;
        *const_ptr /= 5;
        *const_ptr %= 9;
+       (*const_ptr)++;
 }
diff -r a1ed3492192b -r 4adb61cd0dd3 tests/usr.bin/xlint/lint1/msg_115.exp
--- a/tests/usr.bin/xlint/lint1/msg_115.exp     Sun Jan 17 16:16:09 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_115.exp     Sun Jan 17 16:19:54 2021 +0000
@@ -4,3 +4,4 @@
 msg_115.c(13): warning: left operand of '*=' must be modifiable lvalue [115]
 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]
diff -r a1ed3492192b -r 4adb61cd0dd3 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sun Jan 17 16:16:09 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sun Jan 17 16:19:54 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.175 2021/01/17 16:01:19 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.176 2021/01/17 16:19: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.175 2021/01/17 16:01:19 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.176 2021/01/17 16:19:54 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -769,7 +769,7 @@
                return false;
        } else if (tp->t_const) {
                if (!tflag)
-                       /* %soperand of '%s' must be modifiable ... */
+                       /* %soperand of '%s' must be modifiable lvalue */
                        warning(115, "", mp->m_name);
        }
        return true;



Home | Main Index | Thread Index | Old Index