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: demonstrate another wa...
details: https://anonhg.NetBSD.org/src/rev/0b0c6cf9eab9
branches: trunk
changeset: 368117:0b0c6cf9eab9
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Jun 24 21:02:10 2022 +0000
description:
tests/lint: demonstrate another warning about pointer casts
diffstat:
tests/usr.bin/xlint/lint1/msg_247.c | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diffs (33 lines):
diff -r b8aaa45ff743 -r 0b0c6cf9eab9 tests/usr.bin/xlint/lint1/msg_247.c
--- a/tests/usr.bin/xlint/lint1/msg_247.c Fri Jun 24 20:44:53 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_247.c Fri Jun 24 21:02:10 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_247.c,v 1.24 2022/06/24 20:44:53 rillig Exp $ */
+/* $NetBSD: msg_247.c,v 1.25 2022/06/24 21:02:10 rillig Exp $ */
# 3 "msg_247.c"
// Test for message: pointer cast from '%s' to '%s' may be troublesome [247]
@@ -305,3 +305,23 @@
return t2;
}
+
+double *
+unnecessary_cast_from_array_to_pointer(int dim)
+{
+ static double storage_1d[10];
+ static double storage_2d[10][5];
+
+ if (dim == 1)
+ return (double *)storage_1d;
+
+ if (dim == -1)
+ return storage_1d;
+
+ if (dim == 2)
+ /* expect+1: warning: illegal combination of 'pointer to double' and 'pointer to array[5] of double' [184] */
+ return storage_2d;
+
+ /* expect+1: warning: pointer cast from 'pointer to array[5] of double' to 'pointer to double' may be troublesome [247] */
+ return (double *)storage_2d;
+}
Home |
Main Index |
Thread Index |
Old Index