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 lint: add test for rvalue ++ after...



details:   https://anonhg.NetBSD.org/src/rev/a1ed3492192b
branches:  trunk
changeset: 958718:a1ed3492192b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 17 16:16:09 2021 +0000

description:
lint: add test for rvalue ++ after cast

diffstat:

 tests/usr.bin/xlint/lint1/msg_163.c   |  12 +++++++++---
 tests/usr.bin/xlint/lint1/msg_163.exp |   3 ++-
 2 files changed, 11 insertions(+), 4 deletions(-)

diffs (27 lines):

diff -r 26be618aed65 -r a1ed3492192b tests/usr.bin/xlint/lint1/msg_163.c
--- a/tests/usr.bin/xlint/lint1/msg_163.c       Sun Jan 17 16:01:19 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_163.c       Sun Jan 17 16:16:09 2021 +0000
@@ -1,7 +1,13 @@
-/*     $NetBSD: msg_163.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_163.c,v 1.2 2021/01/17 16:16:09 rillig Exp $       */
 # 3 "msg_163.c"
 
 // Test for message: a cast does not yield an lvalue [163]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void
+example(char *p, int i)
+{
+       p++;
+       ((char *)p)++;          /* XXX: why is this ok? */
+       i++;
+       ((int)i)++;             /* expect: 163, 114 */
+}
diff -r 26be618aed65 -r a1ed3492192b tests/usr.bin/xlint/lint1/msg_163.exp
--- a/tests/usr.bin/xlint/lint1/msg_163.exp     Sun Jan 17 16:01:19 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_163.exp     Sun Jan 17 16:16:09 2021 +0000
@@ -1,1 +1,2 @@
-msg_163.c(6): syntax error ':' [249]
+msg_163.c(12): a cast does not yield an lvalue [163]
+msg_163.c(12): operand of 'x++' must be lvalue [114]



Home | Main Index | Thread Index | Old Index