Skip to content

Commit 5685e47

Browse files
committed
tests/lint: move a platform-specific test
The test failed on i386, as ptrdiff_t fits in a uint32_t after conversion, thus not generating a warning.
1 parent c951ea2 commit 5685e47

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

tests/usr.bin/xlint/lint1/msg_132.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: msg_132.c,v 1.52 2025/01/02 20:02:59 rillig Exp $ */
1+
/* $NetBSD: msg_132.c,v 1.53 2025/01/03 01:27:35 rillig Exp $ */
22
# 3 "msg_132.c"
33

44
// Test for message: conversion from '%s' to '%s' may lose accuracy [132]
@@ -424,8 +424,6 @@ test_ic_minus(void)
424424

425425
ptr = ptr - 3;
426426
s64 = ptr + 3 - ptr;
427-
/* expect+1: warning: conversion from 'long' to 'unsigned int' may lose accuracy [132] */
428-
u32 = ptr + 3 - ptr;
429427
}
430428

431429
void
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1-
/* $NetBSD: msg_132_lp64.c,v 1.2 2023/07/07 19:45:22 rillig Exp $ */
1+
/* $NetBSD: msg_132_lp64.c,v 1.3 2025/01/03 01:27:35 rillig Exp $ */
22
# 3 "msg_132_lp64.c"
33

44
// Test for message: conversion from '%s' to '%s' may lose accuracy [132]
55

66
/* lint1-extra-flags: -a -X 351 */
77
/* lint1-only-if: lp64 */
88

9+
typedef unsigned int u32_t;
10+
11+
u32_t u32;
12+
const char *ptr;
13+
914
unsigned int
10-
convert_pointer_to_smaller_integer(void *ptr)
15+
convert_pointer_to_smaller_integer(void)
1116
{
1217
/* expect+1: warning: conversion from 'unsigned long' to 'unsigned int' may lose accuracy [132] */
1318
return (unsigned long)(ptr) >> 12;
1419
}
20+
21+
void
22+
test_ic_minus(void)
23+
{
24+
/* expect+1: warning: conversion from 'long' to 'unsigned int' may lose accuracy [132] */
25+
u32 = ptr + 3 - ptr;
26+
}

0 commit comments

Comments
 (0)