Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: fix assertion failure in '(unsigne...
details: https://anonhg.NetBSD.org/src/rev/fb20c67faeb2
branches: trunk
changeset: 366541:fb20c67faeb2
user: rillig <rillig%NetBSD.org@localhost>
date: Mon May 30 07:19:28 2022 +0000
description:
lint: fix assertion failure in '(unsigned long)(ptr) >> 12'
Since tree.c 1.449 from 2022-05-26.
diffstat:
tests/usr.bin/xlint/lint1/msg_132.c | 10 +++++++++-
tests/usr.bin/xlint/lint1/msg_132.exp | 1 +
usr.bin/xlint/lint1/tree.c | 8 ++++++--
3 files changed, 16 insertions(+), 3 deletions(-)
diffs (62 lines):
diff -r b0ac37cf6c21 -r fb20c67faeb2 tests/usr.bin/xlint/lint1/msg_132.c
--- a/tests/usr.bin/xlint/lint1/msg_132.c Mon May 30 05:08:17 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_132.c Mon May 30 07:19:28 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_132.c,v 1.15 2022/05/29 23:24:09 rillig Exp $ */
+/* $NetBSD: msg_132.c,v 1.16 2022/05/30 07:19:28 rillig Exp $ */
# 3 "msg_132.c"
// Test for message: conversion from '%s' to '%s' may lose accuracy [132]
@@ -214,3 +214,11 @@
/* expect+1: warning: conversion from 'unsigned long' to 'unsigned char' may lose accuracy [132] */
return s.bits_32 & m;
}
+
+
+unsigned int
+convert_pointer_to_smaller_integer(void *ptr)
+{
+ /* expect+1: warning: conversion from 'unsigned long' to 'unsigned int' may lose accuracy [132] */
+ return (unsigned long)(ptr) >> 12;
+}
diff -r b0ac37cf6c21 -r fb20c67faeb2 tests/usr.bin/xlint/lint1/msg_132.exp
--- a/tests/usr.bin/xlint/lint1/msg_132.exp Mon May 30 05:08:17 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_132.exp Mon May 30 07:19:28 2022 +0000
@@ -29,3 +29,4 @@
msg_132.c(195): warning: conversion from 'unsigned long long' to 'unsigned int' may lose accuracy [132]
msg_132.c(209): warning: conversion from 'unsigned long' to 'unsigned int' may lose accuracy [132]
msg_132.c(215): warning: conversion from 'unsigned long' to 'unsigned char' may lose accuracy [132]
+msg_132.c(223): warning: conversion from 'unsigned long' to 'unsigned int' may lose accuracy [132]
diff -r b0ac37cf6c21 -r fb20c67faeb2 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Mon May 30 05:08:17 2022 +0000
+++ b/usr.bin/xlint/lint1/tree.c Mon May 30 07:19:28 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.450 2022/05/29 23:24:09 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.451 2022/05/30 07:19:28 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.450 2022/05/29 23:24:09 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.451 2022/05/30 07:19:28 rillig Exp $");
#endif
#include <float.h>
@@ -255,10 +255,14 @@
{
integer_constraints lc, rc;
+ lint_assert(is_integer(tn->tn_type->t_tspec));
+
switch (tn->tn_op) {
case CON:
return ic_con(tn->tn_type, tn->tn_val);
case CVT:
+ if (!is_integer(tn->tn_left->tn_type->t_tspec))
+ return ic_any(tn->tn_type);
lc = ic_expr(tn->tn_left);
return ic_cvt(tn->tn_type, tn->tn_left->tn_type, lc);
case SHL:
Home |
Main Index |
Thread Index |
Old Index