lint: preserve integer constraints on cast
This commit is contained in:
parent
836e5e938d
commit
872d56a969
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: msg_132.c,v 1.28 2023/05/09 15:37:29 rillig Exp $ */
|
||||
/* $NetBSD: msg_132.c,v 1.29 2023/05/09 15:45:06 rillig Exp $ */
|
||||
# 3 "msg_132.c"
|
||||
|
||||
// Test for message: conversion from '%s' to '%s' may lose accuracy [132]
|
||||
|
@ -372,8 +372,6 @@ void
|
|||
test_ic_cvt(void)
|
||||
{
|
||||
u16 = (u32 & 0x0000ff00);
|
||||
/* FIXME: Don't throw away the constraint. */
|
||||
/* expect+1: warning: conversion from 'unsigned int' to 'unsigned short' may lose accuracy [132] */
|
||||
u16 = (u32_t)(u32 & 0x0000ff00);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tree.c,v 1.519 2023/04/22 20:54:28 rillig Exp $ */
|
||||
/* $NetBSD: tree.c,v 1.520 2023/05/09 15:45:06 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID)
|
||||
__RCSID("$NetBSD: tree.c,v 1.519 2023/04/22 20:54:28 rillig Exp $");
|
||||
__RCSID("$NetBSD: tree.c,v 1.520 2023/05/09 15:45:06 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <float.h>
|
||||
|
@ -147,9 +147,14 @@ ic_con(const type_t *tp, const val_t *v)
|
|||
static integer_constraints
|
||||
ic_cvt(const type_t *ntp, const type_t *otp, integer_constraints a)
|
||||
{
|
||||
unsigned nw = width_in_bits(ntp);
|
||||
unsigned ow = width_in_bits(otp);
|
||||
bool nu = is_uinteger(ntp->t_tspec);
|
||||
bool ou = is_uinteger(otp->t_tspec);
|
||||
|
||||
if (width_in_bits(ntp) > width_in_bits(otp) &&
|
||||
is_uinteger(otp->t_tspec))
|
||||
if (nw >= ow && nu == ou)
|
||||
return a;
|
||||
if (nw > ow && ou)
|
||||
return a;
|
||||
return ic_any(ntp);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue