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: add tests for function...
details: https://anonhg.NetBSD.org/src/rev/684b707b8f09
branches: trunk
changeset: 953159:684b707b8f09
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Feb 28 00:52:16 2021 +0000
description:
tests/lint: add tests for function pointers
diffstat:
tests/usr.bin/xlint/lint1/msg_153.c | 14 +++++++++++---
tests/usr.bin/xlint/lint1/msg_153.exp | 2 +-
tests/usr.bin/xlint/lint1/msg_229.c | 11 ++++++++---
tests/usr.bin/xlint/lint1/msg_229.exp | 2 +-
4 files changed, 21 insertions(+), 8 deletions(-)
diffs (53 lines):
diff -r c175747a20dc -r 684b707b8f09 tests/usr.bin/xlint/lint1/msg_153.c
--- a/tests/usr.bin/xlint/lint1/msg_153.c Sun Feb 28 00:44:58 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_153.c Sun Feb 28 00:52:16 2021 +0000
@@ -1,7 +1,15 @@
-/* $NetBSD: msg_153.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_153.c,v 1.3 2021/02/28 00:52:16 rillig Exp $ */
# 3 "msg_153.c"
// Test for message: argument has incompatible pointer type, arg #%d (%s != %s) [153]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+
+typedef double (*unary_operator)(double);
+
+void sink_unary_operator(unary_operator);
+
+void
+example(int x)
+{
+ sink_unary_operator(&x);
+}
diff -r c175747a20dc -r 684b707b8f09 tests/usr.bin/xlint/lint1/msg_153.exp
--- a/tests/usr.bin/xlint/lint1/msg_153.exp Sun Feb 28 00:44:58 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_153.exp Sun Feb 28 00:52:16 2021 +0000
@@ -1,1 +1,1 @@
-msg_153.c(6): syntax error ':' [249]
+msg_153.c(14): warning: argument has incompatible pointer type, arg #1 (pointer to function(double) returning double != pointer to int) [153]
diff -r c175747a20dc -r 684b707b8f09 tests/usr.bin/xlint/lint1/msg_229.c
--- a/tests/usr.bin/xlint/lint1/msg_229.c Sun Feb 28 00:44:58 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_229.c Sun Feb 28 00:52:16 2021 +0000
@@ -1,7 +1,12 @@
-/* $NetBSD: msg_229.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_229.c,v 1.3 2021/02/28 00:52:16 rillig Exp $ */
# 3 "msg_229.c"
// Test for message: questionable conversion of function pointer [229]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+typedef double (*unary_operator)(double);
+
+int *
+example(unary_operator op)
+{
+ return (int *)op;
+}
diff -r c175747a20dc -r 684b707b8f09 tests/usr.bin/xlint/lint1/msg_229.exp
--- a/tests/usr.bin/xlint/lint1/msg_229.exp Sun Feb 28 00:44:58 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_229.exp Sun Feb 28 00:52:16 2021 +0000
@@ -1,1 +1,1 @@
-msg_229.c(6): syntax error ':' [249]
+msg_229.c(11): warning: questionable conversion of function pointer [229]
Home |
Main Index |
Thread Index |
Old Index