diff options
| author | rillig <rillig@NetBSD.org> | 2023-07-08 15:26:25 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2023-07-08 15:26:25 +0000 |
| commit | 65989024f874330227db7d9793fa78cab7c0ee2f (patch) | |
| tree | 74bc338956dbc13d05596e6fdabb684576902ce9 /tests | |
| parent | 06c86f587bc97ca18607602ed3345db07a0dacd8 (diff) | |
lint: do not use portable type sizes in integer constraints
This reverts the change from tree.c 1.547 from 2023-07-03. Back then, I
didn't know that the actual value from a type's 'portable size in bits'
was not supposed to be used.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/usr.bin/xlint/lint1/msg_247_portable.c | 3 | ||||
| -rw-r--r-- | tests/usr.bin/xlint/lint1/platform_ilp32_long.c | 16 |
2 files changed, 11 insertions, 8 deletions
diff --git a/tests/usr.bin/xlint/lint1/msg_247_portable.c b/tests/usr.bin/xlint/lint1/msg_247_portable.c index 29025f56fc3..028a41b5131 100644 --- a/tests/usr.bin/xlint/lint1/msg_247_portable.c +++ b/tests/usr.bin/xlint/lint1/msg_247_portable.c @@ -1,4 +1,4 @@ -/* $NetBSD: msg_247_portable.c,v 1.2 2023/07/05 11:42:14 rillig Exp $ */ +/* $NetBSD: msg_247_portable.c,v 1.3 2023/07/08 15:26:25 rillig Exp $ */ # 3 "msg_247_portable.c" // Test for message: pointer cast from '%s' to '%s' may be troublesome [247] @@ -11,6 +11,7 @@ // msg_247_ilp32_ldbl64.c // msg_247_lp64_ldbl128.c +/* lint1-only-if: long */ /* lint1-extra-flags: -c -p -X 351 */ typedef double double_array[5]; diff --git a/tests/usr.bin/xlint/lint1/platform_ilp32_long.c b/tests/usr.bin/xlint/lint1/platform_ilp32_long.c index 5a1fb977719..c2c46d9f5fe 100644 --- a/tests/usr.bin/xlint/lint1/platform_ilp32_long.c +++ b/tests/usr.bin/xlint/lint1/platform_ilp32_long.c @@ -1,4 +1,4 @@ -/* $NetBSD: platform_ilp32_long.c,v 1.3 2023/07/03 21:36:16 rillig Exp $ */ +/* $NetBSD: platform_ilp32_long.c,v 1.4 2023/07/08 15:26:25 rillig Exp $ */ # 3 "platform_ilp32_long.c" /* @@ -22,15 +22,17 @@ void convert_between_int_and_long(void) { /* - * Even though 'long' and 'int' have the same size on this platform, - * the option '-p' enables additional portability checks that assume - * a 24-bit int and a 32-bit long type, to proactively detect loss of - * accuracy on potential other platforms. + * The '-p' option enables checks that apply independently of the + * current platform, assuming that 'long' is always wider than 'int'. + * This assumption, when applied on its own, leads to wrong warnings + * that a 32-bit 'long' may lose accuracy when converted to a 32-bit + * 'int'. + * + * To avoid these, take a look at the actually possible values of the + * right-hand side, and if they fit in the left-hand side, don't warn. */ - /* expect+1: warning: conversion from 'long' to 'int' may lose accuracy [132] */ s32 = sl32; sl32 = s32; - /* expect+1: warning: conversion from 'unsigned long' to 'unsigned int' may lose accuracy [132] */ u32 = ul32; ul32 = u32; } |
