Module Name: src
Committed By: rillig
Date: Sat Jun 8 06:37:06 UTC 2024
Modified Files:
src/tests/usr.bin/xlint/lint1: d_constant_conv1.c expr_fold.c msg_011.c
msg_164.c msg_166.c msg_221.c msg_222.c msg_296.c platform_ilp32.c
platform_schar.c platform_uchar.c
src/usr.bin/xlint/lint1: err.c tree.c
Log Message:
lint: add details to warnings about negative constant to unsigned
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/d_constant_conv1.c \
src/tests/usr.bin/xlint/lint1/msg_166.c \
src/tests/usr.bin/xlint/lint1/msg_222.c \
src/tests/usr.bin/xlint/lint1/platform_ilp32.c \
src/tests/usr.bin/xlint/lint1/platform_schar.c
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/xlint/lint1/expr_fold.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_011.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_164.c \
src/tests/usr.bin/xlint/lint1/msg_221.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_296.c \
src/tests/usr.bin/xlint/lint1/platform_uchar.c
cvs rdiff -u -r1.244 -r1.245 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.643 -r1.644 src/usr.bin/xlint/lint1/tree.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/d_constant_conv1.c
diff -u src/tests/usr.bin/xlint/lint1/d_constant_conv1.c:1.5 src/tests/usr.bin/xlint/lint1/d_constant_conv1.c:1.6
--- src/tests/usr.bin/xlint/lint1/d_constant_conv1.c:1.5 Tue Mar 28 14:44:34 2023
+++ src/tests/usr.bin/xlint/lint1/d_constant_conv1.c Sat Jun 8 06:37:06 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: d_constant_conv1.c,v 1.5 2023/03/28 14:44:34 rillig Exp $ */
+/* $NetBSD: d_constant_conv1.c,v 1.6 2024/06/08 06:37:06 rillig Exp $ */
# 3 "d_constant_conv1.c"
/* Flag information-losing constant conversion in argument lists */
@@ -10,6 +10,6 @@ int f(unsigned int);
void
should_fail()
{
- /* expect+1: warning: conversion of negative constant to unsigned type, arg #1 [296] */
+ /* expect+1: warning: conversion of negative constant -1 to unsigned type 'unsigned int', arg #1 [296] */
f(-1);
}
Index: src/tests/usr.bin/xlint/lint1/msg_166.c
diff -u src/tests/usr.bin/xlint/lint1/msg_166.c:1.5 src/tests/usr.bin/xlint/lint1/msg_166.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_166.c:1.5 Fri Jul 7 19:45:22 2023
+++ src/tests/usr.bin/xlint/lint1/msg_166.c Sat Jun 8 06:37:06 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_166.c,v 1.5 2023/07/07 19:45:22 rillig Exp $ */
+/* $NetBSD: msg_166.c,v 1.6 2024/06/08 06:37:06 rillig Exp $ */
# 3 "msg_166.c"
// Test for message: precision lost in bit-field assignment [166]
@@ -51,9 +51,9 @@ void example(void) {
bits.minus_8_to_7 = 8;
/* Clang doesn't warn about the -1. */
- /* expect+1: warning: assignment of negative constant to unsigned type [164] */
+ /* expect+1: warning: assignment of negative constant -2 to unsigned type 'unsigned int:1' [164] */
bits.zero_to_1 = -2;
- /* expect+1: warning: assignment of negative constant to unsigned type [164] */
+ /* expect+1: warning: assignment of negative constant -1 to unsigned type 'unsigned int:1' [164] */
bits.zero_to_1 = -1;
bits.zero_to_1 = 0;
bits.zero_to_1 = 1;
@@ -61,9 +61,9 @@ void example(void) {
bits.zero_to_1 = 2;
/* Clang doesn't warn about the -8. */
- /* expect+1: warning: assignment of negative constant to unsigned type [164] */
+ /* expect+1: warning: assignment of negative constant -9 to unsigned type 'unsigned int:4' [164] */
bits.zero_to_15 = -9;
- /* expect+1: warning: assignment of negative constant to unsigned type [164] */
+ /* expect+1: warning: assignment of negative constant -8 to unsigned type 'unsigned int:4' [164] */
bits.zero_to_15 = -8;
bits.zero_to_15 = 0;
bits.zero_to_15 = 15;
Index: src/tests/usr.bin/xlint/lint1/msg_222.c
diff -u src/tests/usr.bin/xlint/lint1/msg_222.c:1.5 src/tests/usr.bin/xlint/lint1/msg_222.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_222.c:1.5 Tue Mar 28 14:44:35 2023
+++ src/tests/usr.bin/xlint/lint1/msg_222.c Sat Jun 8 06:37:06 2024
@@ -1,11 +1,11 @@
-/* $NetBSD: msg_222.c,v 1.5 2023/03/28 14:44:35 rillig Exp $ */
+/* $NetBSD: msg_222.c,v 1.6 2024/06/08 06:37:06 rillig Exp $ */
# 3 "msg_222.c"
-// Test for message: conversion of negative constant to unsigned type [222]
+// Test for message: conversion of negative constant %lld to unsigned type '%s' [222]
/* lint1-extra-flags: -X 351 */
-/* expect+1: warning: initialization of unsigned with negative constant [221] */
+/* expect+1: warning: initialization of unsigned type 'unsigned int' with negative constant -1 [221] */
unsigned int global = -1;
void take_unsigned_int(unsigned int);
@@ -13,10 +13,10 @@ void take_unsigned_int(unsigned int);
void
function(void)
{
- /* expect+1: warning: initialization of unsigned with negative constant [221] */
+ /* expect+1: warning: initialization of unsigned type 'unsigned int' with negative constant -1 [221] */
unsigned int local = -1;
- /* expect+1: warning: conversion of negative constant to unsigned type, arg #1 [296] */
+ /* expect+1: warning: conversion of negative constant -1 to unsigned type 'unsigned int', arg #1 [296] */
take_unsigned_int(-1);
if (local & -1)
@@ -28,6 +28,6 @@ function(void)
local &= -1;
- /* expect+1: warning: conversion of negative constant to unsigned type [222] */
+ /* expect+1: warning: conversion of negative constant -1 to unsigned type 'unsigned int' [222] */
local += -1;
}
Index: src/tests/usr.bin/xlint/lint1/platform_ilp32.c
diff -u src/tests/usr.bin/xlint/lint1/platform_ilp32.c:1.5 src/tests/usr.bin/xlint/lint1/platform_ilp32.c:1.6
--- src/tests/usr.bin/xlint/lint1/platform_ilp32.c:1.5 Wed Mar 27 19:28:20 2024
+++ src/tests/usr.bin/xlint/lint1/platform_ilp32.c Sat Jun 8 06:37:06 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: platform_ilp32.c,v 1.5 2024/03/27 19:28:20 rillig Exp $ */
+/* $NetBSD: platform_ilp32.c,v 1.6 2024/06/08 06:37:06 rillig Exp $ */
# 3 "platform_ilp32.c"
/*
@@ -36,9 +36,9 @@ switch_u64(unsigned long long x)
case 0x333300000001:
/* expect+1: error: duplicate case '37529424232449' in switch [200] */
case 0x222200000001:
- /* expect+1: warning: conversion of negative constant to unsigned type [222] */
+ /* expect+1: warning: conversion of negative constant -9223372036854775807 to unsigned type 'unsigned long long' [222] */
case -0x7fffffffffffffff:
- /* expect+2: warning: conversion of negative constant to unsigned type [222] */
+ /* expect+2: warning: conversion of negative constant -9223372036854775807 to unsigned type 'unsigned long long' [222] */
/* expect+1: error: duplicate case '9223372036854775809' in switch [200] */
case -0x7fffffffffffffff:
break;
Index: src/tests/usr.bin/xlint/lint1/platform_schar.c
diff -u src/tests/usr.bin/xlint/lint1/platform_schar.c:1.5 src/tests/usr.bin/xlint/lint1/platform_schar.c:1.6
--- src/tests/usr.bin/xlint/lint1/platform_schar.c:1.5 Sat Dec 2 23:54:49 2023
+++ src/tests/usr.bin/xlint/lint1/platform_schar.c Sat Jun 8 06:37:06 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: platform_schar.c,v 1.5 2023/12/02 23:54:49 rillig Exp $ */
+/* $NetBSD: platform_schar.c,v 1.6 2024/06/08 06:37:06 rillig Exp $ */
# 3 "platform_schar.c"
/*
@@ -6,7 +6,7 @@
* representation as signed char.
*/
-/* lint1-extra-flags: -c -h -a -p -b -r -z -X 161 */
+/* lint1-extra-flags: -c -h -a -p -b -r -z -X 161,351 */
/* lint1-only-if: schar */
/* expect+1: warning: nonportable character comparison '-128 < ?' [230] */
@@ -17,3 +17,10 @@ typedef int char_int[(char)'\200' < (cha
typedef int int_char[(char)-128 < (char)'\177' ? 1 : -1];
/* expect+1: warning: nonportable character comparison '-128 < ?' [230] */
typedef int int_int[(char)-128 < (char)127 ? 1 : -1];
+
+
+void
+first_to_upper(char *p)
+{
+ *p += 'A' - 'a';
+}
Index: src/tests/usr.bin/xlint/lint1/expr_fold.c
diff -u src/tests/usr.bin/xlint/lint1/expr_fold.c:1.15 src/tests/usr.bin/xlint/lint1/expr_fold.c:1.16
--- src/tests/usr.bin/xlint/lint1/expr_fold.c:1.15 Sun Mar 10 19:45:14 2024
+++ src/tests/usr.bin/xlint/lint1/expr_fold.c Sat Jun 8 06:37:06 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: expr_fold.c,v 1.15 2024/03/10 19:45:14 rillig Exp $ */
+/* $NetBSD: expr_fold.c,v 1.16 2024/06/08 06:37:06 rillig Exp $ */
# 3 "expr_fold.c"
/*
@@ -67,11 +67,11 @@ fold_uminus(void)
take_int(-(4294967295));
take_uint(-(0));
- /* expect+1: warning: conversion of negative constant to unsigned type, arg #1 [296] */
+ /* expect+1: warning: conversion of negative constant -2147483647 to unsigned type 'unsigned int', arg #1 [296] */
take_uint(-(2147483647));
- /* expect+1: warning: conversion of negative constant to unsigned type, arg #1 [296] */
+ /* expect+1: warning: conversion of negative constant -2147483648 to unsigned type 'unsigned int', arg #1 [296] */
take_uint(-(2147483648));
- /* expect+1: warning: conversion of negative constant to unsigned type, arg #1 [296] */
+ /* expect+1: warning: conversion of negative constant -4294967295 to unsigned type 'unsigned int', arg #1 [296] */
take_uint(-(4294967295));
}
@@ -85,13 +85,13 @@ fold_compl(void)
/* expect+1: warning: conversion of 'long' to 'int' is out of range, arg #1 [295] */
take_int(~(4294967295));
- /* expect+1: warning: conversion of negative constant to unsigned type, arg #1 [296] */
+ /* expect+1: warning: conversion of negative constant -1 to unsigned type 'unsigned int', arg #1 [296] */
take_uint(~(0));
- /* expect+1: warning: conversion of negative constant to unsigned type, arg #1 [296] */
+ /* expect+1: warning: conversion of negative constant -2147483648 to unsigned type 'unsigned int', arg #1 [296] */
take_uint(~(2147483647));
- /* expect+1: warning: conversion of negative constant to unsigned type, arg #1 [296] */
+ /* expect+1: warning: conversion of negative constant -2147483649 to unsigned type 'unsigned int', arg #1 [296] */
take_uint(~(2147483648));
- /* expect+1: warning: conversion of negative constant to unsigned type, arg #1 [296] */
+ /* expect+1: warning: conversion of negative constant -4294967296 to unsigned type 'unsigned int', arg #1 [296] */
take_uint(~(4294967295));
}
Index: src/tests/usr.bin/xlint/lint1/msg_011.c
diff -u src/tests/usr.bin/xlint/lint1/msg_011.c:1.7 src/tests/usr.bin/xlint/lint1/msg_011.c:1.8
--- src/tests/usr.bin/xlint/lint1/msg_011.c:1.7 Fri Jul 7 19:45:22 2023
+++ src/tests/usr.bin/xlint/lint1/msg_011.c Sat Jun 8 06:37:06 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_011.c,v 1.7 2023/07/07 19:45:22 rillig Exp $ */
+/* $NetBSD: msg_011.c,v 1.8 2024/06/08 06:37:06 rillig Exp $ */
# 3 "msg_011.c"
// Test for message: bit-field initializer out of range [11]
@@ -14,17 +14,17 @@ example(void)
/* expect+1: warning: 's' set but not used in function 'example' [191] */
} s[] = {
/* expect+2: warning: bit-field initializer out of range [11] */
- /* expect+1: warning: initialization of unsigned with negative constant [221] */
+ /* expect+1: warning: initialization of unsigned type 'unsigned int:3' with negative constant -8 [221] */
{ -8, -8 },
/* expect+2: warning: bit-field initializer out of range [11] */
- /* expect+1: warning: initialization of unsigned with negative constant [221] */
+ /* expect+1: warning: initialization of unsigned type 'unsigned int:3' with negative constant -7 [221] */
{ -7, -7 },
- /* expect+1: warning: initialization of unsigned with negative constant [221] */
+ /* expect+1: warning: initialization of unsigned type 'unsigned int:3' with negative constant -4 [221] */
{ -4, -4 },
- /* expect+1: warning: initialization of unsigned with negative constant [221] */
+ /* expect+1: warning: initialization of unsigned type 'unsigned int:3' with negative constant -3 [221] */
{ -3, -3 },
{ 3, 3 },
Index: src/tests/usr.bin/xlint/lint1/msg_164.c
diff -u src/tests/usr.bin/xlint/lint1/msg_164.c:1.6 src/tests/usr.bin/xlint/lint1/msg_164.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_164.c:1.6 Fri Jul 7 19:45:22 2023
+++ src/tests/usr.bin/xlint/lint1/msg_164.c Sat Jun 8 06:37:06 2024
@@ -1,20 +1,20 @@
-/* $NetBSD: msg_164.c,v 1.6 2023/07/07 19:45:22 rillig Exp $ */
+/* $NetBSD: msg_164.c,v 1.7 2024/06/08 06:37:06 rillig Exp $ */
# 3 "msg_164.c"
-// Test for message: assignment of negative constant to unsigned type [164]
+// Test for message: assignment of negative constant %lld to unsigned type '%s' [164]
/* lint1-extra-flags: -X 351 */
void
example(void)
{
- /* expect+1: warning: initialization of unsigned with negative constant [221] */
+ /* expect+1: warning: initialization of unsigned type 'unsigned char' with negative constant -3 [221] */
unsigned char uch = -3;
- /* expect+1: warning: assignment of negative constant to unsigned type [164] */
+ /* expect+1: warning: assignment of negative constant -5 to unsigned type 'unsigned char' [164] */
uch = -5;
- /* expect+1: warning: conversion of negative constant to unsigned type [222] */
+ /* expect+1: warning: conversion of negative constant -7 to unsigned type 'unsigned char' [222] */
uch += -7;
- /* expect+1: warning: conversion of negative constant to unsigned type [222] */
+ /* expect+1: warning: conversion of negative constant -1 to unsigned type 'unsigned char' [222] */
uch *= -1;
}
Index: src/tests/usr.bin/xlint/lint1/msg_221.c
diff -u src/tests/usr.bin/xlint/lint1/msg_221.c:1.6 src/tests/usr.bin/xlint/lint1/msg_221.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_221.c:1.6 Tue Mar 28 14:44:35 2023
+++ src/tests/usr.bin/xlint/lint1/msg_221.c Sat Jun 8 06:37:06 2024
@@ -1,7 +1,7 @@
-/* $NetBSD: msg_221.c,v 1.6 2023/03/28 14:44:35 rillig Exp $ */
+/* $NetBSD: msg_221.c,v 1.7 2024/06/08 06:37:06 rillig Exp $ */
# 3 "msg_221.c"
-// Test for message: initialization of unsigned with negative constant [221]
+// Test for message: initialization of unsigned type '%s' with negative constant %lld [221]
/* lint1-extra-flags: -X 351 */
@@ -9,7 +9,7 @@ struct example {
unsigned int a: 5;
unsigned int b: 5;
} example_var = {
- /* expect+1: warning: initialization of unsigned with negative constant [221] */
+ /* expect+1: warning: initialization of unsigned type 'unsigned int:5' with negative constant -1 [221] */
-1,
31
};
Index: src/tests/usr.bin/xlint/lint1/msg_296.c
diff -u src/tests/usr.bin/xlint/lint1/msg_296.c:1.4 src/tests/usr.bin/xlint/lint1/msg_296.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_296.c:1.4 Tue Mar 28 14:44:35 2023
+++ src/tests/usr.bin/xlint/lint1/msg_296.c Sat Jun 8 06:37:06 2024
@@ -1,7 +1,7 @@
-/* $NetBSD: msg_296.c,v 1.4 2023/03/28 14:44:35 rillig Exp $ */
+/* $NetBSD: msg_296.c,v 1.5 2024/06/08 06:37:06 rillig Exp $ */
# 3 "msg_296.c"
-// Test for message: conversion of negative constant to unsigned type, arg #%d [296]
+// Test for message: conversion of negative constant %lld to unsigned type '%s', arg #%d [296]
/* lint1-extra-flags: -X 351 */
@@ -10,6 +10,6 @@ void take_unsigned_int(unsigned int);
void
example(void)
{
- /* expect+1: warning: conversion of negative constant to unsigned type, arg #1 [296] */
+ /* expect+1: warning: conversion of negative constant -3 to unsigned type 'unsigned int', arg #1 [296] */
take_unsigned_int(-3);
}
Index: src/tests/usr.bin/xlint/lint1/platform_uchar.c
diff -u src/tests/usr.bin/xlint/lint1/platform_uchar.c:1.4 src/tests/usr.bin/xlint/lint1/platform_uchar.c:1.5
--- src/tests/usr.bin/xlint/lint1/platform_uchar.c:1.4 Sat Dec 2 23:54:49 2023
+++ src/tests/usr.bin/xlint/lint1/platform_uchar.c Sat Jun 8 06:37:06 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: platform_uchar.c,v 1.4 2023/12/02 23:54:49 rillig Exp $ */
+/* $NetBSD: platform_uchar.c,v 1.5 2024/06/08 06:37:06 rillig Exp $ */
# 3 "platform_uchar.c"
/*
@@ -6,7 +6,7 @@
* representation as unsigned char.
*/
-/* lint1-extra-flags: -c -h -a -p -b -r -z -X 161 */
+/* lint1-extra-flags: -c -h -a -p -b -r -z -X 161,351 */
/* lint1-only-if: uchar */
/* expect+1: warning: nonportable character comparison '< 128' [230] */
@@ -17,3 +17,11 @@ typedef int int_char[(char)127 < (char)'
typedef int char_int[(char)'\177' < (char)128 ? 1 : -1];
/* expect+1: warning: nonportable character comparison '< 128' [230] */
typedef int int_int[(char)127 < (char)128 ? 1 : -1];
+
+
+void
+first_to_upper(char *p)
+{
+ /* expect+1: warning: conversion of negative constant -32 to unsigned type 'char' [222] */
+ *p += 'A' - 'a';
+}
Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.244 src/usr.bin/xlint/lint1/err.c:1.245
--- src/usr.bin/xlint/lint1/err.c:1.244 Sun May 12 18:49:36 2024
+++ src/usr.bin/xlint/lint1/err.c Sat Jun 8 06:37:06 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.244 2024/05/12 18:49:36 rillig Exp $ */
+/* $NetBSD: err.c,v 1.245 2024/06/08 06:37:06 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: err.c,v 1.244 2024/05/12 18:49:36 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.245 2024/06/08 06:37:06 rillig Exp $");
#endif
#include <limits.h>
@@ -219,7 +219,7 @@ static const char *const msgs[] = {
"constant in conditional context", // 161
"operator '%s' compares '%s' with '%s'", // 162
"a cast does not yield an lvalue", // 163
- "assignment of negative constant to unsigned type", // 164
+ "assignment of negative constant %lld to unsigned type '%s'", // 164
"constant truncated by assignment", // 165
"precision lost in bit-field assignment", // 166
"array subscript %jd cannot be negative", // 167
@@ -276,8 +276,8 @@ static const char *const msgs[] = {
"C90 treats constant as unsigned, op '%s'", // 218
"concatenated strings are illegal in traditional C", // 219
"fallthrough on case statement", // 220
- "initialization of unsigned with negative constant", // 221
- "conversion of negative constant to unsigned type", // 222
+ "initialization of unsigned type '%s' with negative constant %lld", // 221
+ "conversion of negative constant %lld to unsigned type '%s'", // 222
"end-of-loop code not reached", // 223
"cannot recover from previous errors", // 224
"static function '%s' called but not defined", // 225
@@ -351,7 +351,7 @@ static const char *const msgs[] = {
"parameter %d must be 'char *' for PRINTFLIKE/SCANFLIKE", // 293
"multi-character character constant", // 294
"conversion of '%s' to '%s' is out of range, arg #%d", // 295
- "conversion of negative constant to unsigned type, arg #%d", // 296
+ "conversion of negative constant %lld to unsigned type '%s', arg #%d", // 296
"conversion to '%s' may sign-extend incorrectly, arg #%d", // 297
"conversion from '%s' to '%s' may lose accuracy, arg #%d", // 298
"prototype does not match old-style definition, arg #%d", // 299
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.643 src/usr.bin/xlint/lint1/tree.c:1.644
--- src/usr.bin/xlint/lint1/tree.c:1.643 Sun May 12 09:07:41 2024
+++ src/usr.bin/xlint/lint1/tree.c Sat Jun 8 06:37:06 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.643 2024/05/12 09:07:41 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.644 2024/06/08 06:37: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.643 2024/05/12 09:07:41 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.644 2024/06/08 06:37:06 rillig Exp $");
#endif
#include <float.h>
@@ -3804,22 +3804,23 @@ convert_constant_check_range_bitand(size
}
static void
-convert_constant_check_range_signed(op_t op, int arg)
+convert_constant_check_range_signed(op_t op, int arg,
+ const type_t *ntp, int64_t ov)
{
if (op == ASSIGN)
- /* assignment of negative constant to unsigned type */
- warning(164);
+ /* assignment of negative constant %lld to unsigned ... */
+ warning(164, (long long)ov, type_name(ntp));
else if (op == INIT)
- /* initialization of unsigned with negative constant */
- warning(221);
+ /* initialization of unsigned type '%s' with negative ... */
+ warning(221, type_name(ntp), (long long)ov);
else if (op == FARG)
- /* conversion of negative constant to unsigned type, ... */
- warning(296, arg);
+ /* conversion of negative constant %lld to unsigned ... */
+ warning(296, (long long)ov, type_name(ntp), arg);
else if (modtab[op].m_comparison) {
/* handled by check_integer_comparison() */
} else
- /* conversion of negative constant to unsigned type */
- warning(222);
+ /* conversion of negative constant %lld to unsigned ... */
+ warning(222, (long long)ov, type_name(ntp));
}
/*
@@ -3902,7 +3903,8 @@ convert_constant_check_range(tspec_t ot,
} else if (nt != PTR && is_uinteger(nt) &&
ot != PTR && !is_uinteger(ot) &&
v->u.integer < 0)
- convert_constant_check_range_signed(op, arg);
+ convert_constant_check_range_signed(op, arg,
+ tp, v->u.integer);
else if (nv->u.integer != v->u.integer && nbitsz <= obitsz &&
(v->u.integer & xmask) != 0 &&
(is_uinteger(ot) || (v->u.integer & xmsk1) != xmsk1))