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: test function types an...



details:   https://anonhg.NetBSD.org/src/rev/c6589d57e2a7
branches:  trunk
changeset: 984837:c6589d57e2a7
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 25 10:26:46 2021 +0000

description:
tests/lint: test function types and pointer arithmetic

diffstat:

 tests/usr.bin/xlint/lint1/msg_110.c   |  14 +++++++++++---
 tests/usr.bin/xlint/lint1/msg_110.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_147.c   |  15 ++++++++++++---
 tests/usr.bin/xlint/lint1/msg_147.exp |   2 +-
 4 files changed, 26 insertions(+), 8 deletions(-)

diffs (58 lines):

diff -r 22e8b9a6786e -r c6589d57e2a7 tests/usr.bin/xlint/lint1/msg_110.c
--- a/tests/usr.bin/xlint/lint1/msg_110.c       Sun Jul 25 10:21:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_110.c       Sun Jul 25 10:26:46 2021 +0000
@@ -1,7 +1,15 @@
-/*     $NetBSD: msg_110.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_110.c,v 1.3 2021/07/25 10:26:46 rillig Exp $       */
 # 3 "msg_110.c"
 
 // Test for message: pointer to function is not allowed here [110]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* ARGSUSED */
+void
+call_take(int (*ptr)(int))
+{
+       /* expect+1: error: pointer to function is not allowed here [110] */
+       ptr++;
+
+       /* expect+1: error: pointer to function is not allowed here [110] */
+       ptr + 1;
+}
diff -r 22e8b9a6786e -r c6589d57e2a7 tests/usr.bin/xlint/lint1/msg_110.exp
--- a/tests/usr.bin/xlint/lint1/msg_110.exp     Sun Jul 25 10:21:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_110.exp     Sun Jul 25 10:26:46 2021 +0000
@@ -1,1 +1,2 @@
-msg_110.c(6): error: syntax error ':' [249]
+msg_110.c(11): error: pointer to function is not allowed here [110]
+msg_110.c(14): error: pointer to function is not allowed here [110]
diff -r 22e8b9a6786e -r c6589d57e2a7 tests/usr.bin/xlint/lint1/msg_147.c
--- a/tests/usr.bin/xlint/lint1/msg_147.c       Sun Jul 25 10:21:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_147.c       Sun Jul 25 10:26:46 2021 +0000
@@ -1,7 +1,16 @@
-/*     $NetBSD: msg_147.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_147.c,v 1.3 2021/07/25 10:26:46 rillig Exp $       */
 # 3 "msg_147.c"
 
 // Test for message: invalid cast expression [147]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+// The type name 'int(int)' is a 'function(int) returning int'.
+void take(int(int));
+
+/* ARGSUSED */
+void
+call_take(int (*ptr)(int))
+{
+       /* XXX: That's a little too unspecific. */
+       /* expect+1: error: invalid cast expression [147] */
+       take((int(int))ptr);
+}
diff -r 22e8b9a6786e -r c6589d57e2a7 tests/usr.bin/xlint/lint1/msg_147.exp
--- a/tests/usr.bin/xlint/lint1/msg_147.exp     Sun Jul 25 10:21:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_147.exp     Sun Jul 25 10:26:46 2021 +0000
@@ -1,1 +1,1 @@
-msg_147.c(6): error: syntax error ':' [249]
+msg_147.c(15): error: invalid cast expression [147]



Home | Main Index | Thread Index | Old Index