Module Name: src Committed By: rillig Date: Wed Aug 25 22:04:52 UTC 2021
Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/xlint/lint1: Makefile decl_struct_member.c decl_struct_member.exp msg_132.c msg_132.exp Added Files: src/tests/usr.bin/xlint/lint1: msg_132_ilp32.c msg_132_ilp32.exp Log Message: tests/lint: test conversion from long long to intptr_t on ilp32 Seen in usr.bin/make/var.c:1608. To generate a diff of this commit: cvs rdiff -u -r1.1116 -r1.1117 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.106 -r1.107 src/tests/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/xlint/lint1/decl_struct_member.c cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/decl_struct_member.exp cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_132.c cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_132.exp cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/msg_132_ilp32.c \ src/tests/usr.bin/xlint/lint1/msg_132_ilp32.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1116 src/distrib/sets/lists/tests/mi:1.1117 --- src/distrib/sets/lists/tests/mi:1.1116 Tue Aug 24 21:30:52 2021 +++ src/distrib/sets/lists/tests/mi Wed Aug 25 22:04:51 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1116 2021/08/24 21:30:52 rillig Exp $ +# $NetBSD: mi,v 1.1117 2021/08/25 22:04:51 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -6583,6 +6583,8 @@ ./usr/tests/usr.bin/xlint/lint1/msg_131.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/msg_132.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/msg_132.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/msg_132_ilp32.c tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/msg_132_ilp32.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/msg_133.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/msg_133.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/msg_134.c tests-usr.bin-tests compattestfile,atf Index: src/tests/usr.bin/xlint/lint1/Makefile diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.106 src/tests/usr.bin/xlint/lint1/Makefile:1.107 --- src/tests/usr.bin/xlint/lint1/Makefile:1.106 Sun Aug 22 20:56:51 2021 +++ src/tests/usr.bin/xlint/lint1/Makefile Wed Aug 25 22:04:52 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.106 2021/08/22 20:56:51 rillig Exp $ +# $NetBSD: Makefile,v 1.107 2021/08/25 22:04:52 rillig Exp $ NOMAN= # defined MAX_MESSAGE= 346 # see lint1/err.c @@ -208,6 +208,8 @@ FILES+= msg_001_c90.c FILES+= msg_001_c90.exp FILES+= msg_000_c90.c FILES+= msg_000_c90.exp +FILES+= msg_132_ilp32.c +FILES+= msg_132_ilp32.exp FILES+= msg_230_uchar.c FILES+= msg_230_uchar.exp FILES+= msg_259_ilp32.c Index: src/tests/usr.bin/xlint/lint1/decl_struct_member.c diff -u src/tests/usr.bin/xlint/lint1/decl_struct_member.c:1.10 src/tests/usr.bin/xlint/lint1/decl_struct_member.c:1.11 --- src/tests/usr.bin/xlint/lint1/decl_struct_member.c:1.10 Wed Jul 21 21:17:57 2021 +++ src/tests/usr.bin/xlint/lint1/decl_struct_member.c Wed Aug 25 22:04:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl_struct_member.c,v 1.10 2021/07/21 21:17:57 rillig Exp $ */ +/* $NetBSD: decl_struct_member.c,v 1.11 2021/08/25 22:04:52 rillig Exp $ */ # 3 "decl_struct_member.c" struct multi_attributes { @@ -57,6 +57,22 @@ struct cover_notype_struct_declarator_bi }; /* + * An array of bit-fields sounds like a strange idea since a bit-field member + * is not addressable, while an array needs to be addressable. Due to this + * contradiction, this combination may have gone without mention in the C + * standards. + * + * GCC 10.3.0 complains that the bit-field has invalid type. + * + * Clang 12.0.1 complains that the bit-field has non-integral type 'unsigned + * int [8]'. + */ +struct array_of_bit_fields { + /* expect+1: warning: illegal bit-field type 'array[8] of unsigned int' [35] */ + unsigned int bits[8]: 1; +}; + +/* * Before decl.c 1.188 from 2021-06-20, lint ran into a segmentation fault. */ struct { Index: src/tests/usr.bin/xlint/lint1/decl_struct_member.exp diff -u src/tests/usr.bin/xlint/lint1/decl_struct_member.exp:1.8 src/tests/usr.bin/xlint/lint1/decl_struct_member.exp:1.9 --- src/tests/usr.bin/xlint/lint1/decl_struct_member.exp:1.8 Thu Jul 15 21:00:05 2021 +++ src/tests/usr.bin/xlint/lint1/decl_struct_member.exp Wed Aug 25 22:04:52 2021 @@ -3,5 +3,6 @@ decl_struct_member.c(36): error: illegal decl_struct_member.c(38): error: syntax error '}' [249] decl_struct_member.c(38): warning: empty declaration [0] decl_struct_member.c(47): error: syntax error 'unnamed member' [249] -decl_struct_member.c(63): error: syntax error '0' [249] -decl_struct_member.c(71): error: cannot recover from previous errors [224] +decl_struct_member.c(72): warning: illegal bit-field type 'array[8] of unsigned int' [35] +decl_struct_member.c(79): error: syntax error '0' [249] +decl_struct_member.c(87): error: cannot recover from previous errors [224] Index: src/tests/usr.bin/xlint/lint1/msg_132.c diff -u src/tests/usr.bin/xlint/lint1/msg_132.c:1.5 src/tests/usr.bin/xlint/lint1/msg_132.c:1.6 --- src/tests/usr.bin/xlint/lint1/msg_132.c:1.5 Tue Apr 6 21:17:28 2021 +++ src/tests/usr.bin/xlint/lint1/msg_132.c Wed Aug 25 22:04:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_132.c,v 1.5 2021/04/06 21:17:28 rillig Exp $ */ +/* $NetBSD: msg_132.c,v 1.6 2021/08/25 22:04:52 rillig Exp $ */ # 3 "msg_132.c" // Test for message: conversion from '%s' to '%s' may lose accuracy [132] @@ -74,3 +74,14 @@ to_bool(long a, long b) /* seen in fp_lib.h, function wideRightShiftWithSticky */ return a | b; } + +/* ARGSUSED */ +const char * +cover_build_plus_minus(const char *arr, double idx) +{ + /* expect+3: error: operands of '+' have incompatible types (pointer != double) [107] */ + /* expect+2: warning: function 'cover_build_plus_minus' expects to return value [214] */ + if (idx > 0.0) + return arr + idx; + return arr + (unsigned int)idx; +} Index: src/tests/usr.bin/xlint/lint1/msg_132.exp diff -u src/tests/usr.bin/xlint/lint1/msg_132.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_132.exp:1.5 --- src/tests/usr.bin/xlint/lint1/msg_132.exp:1.4 Tue Apr 6 21:17:28 2021 +++ src/tests/usr.bin/xlint/lint1/msg_132.exp Wed Aug 25 22:04:52 2021 @@ -10,3 +10,5 @@ msg_132.c(51): warning: conversion from msg_132.c(54): warning: conversion from 'int' to 'short' may lose accuracy [132] msg_132.c(55): warning: conversion from 'long long' to 'short' may lose accuracy [132] msg_132.c(59): warning: conversion from 'long long' to 'int' may lose accuracy [132] +msg_132.c(85): error: operands of '+' have incompatible types (pointer != double) [107] +msg_132.c(85): warning: function 'cover_build_plus_minus' expects to return value [214] Added files: Index: src/tests/usr.bin/xlint/lint1/msg_132_ilp32.c diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_132_ilp32.c:1.1 --- /dev/null Wed Aug 25 22:04:52 2021 +++ src/tests/usr.bin/xlint/lint1/msg_132_ilp32.c Wed Aug 25 22:04:52 2021 @@ -0,0 +1,32 @@ +/* $NetBSD: msg_132_ilp32.c,v 1.1 2021/08/25 22:04:52 rillig Exp $ */ +# 3 "msg_132_ilp32.c" + +// Test for message: conversion from '%s' to '%s' may lose accuracy [132] + +/* + * On 32-bit platforms, it is possible to add a 64-bit integer to a 32-bit + * pointer. The 64-bit integer is then converted to the ptrdiff_t of the + * target platform, which results in the non-obvious conversion from + * 'long long' to either 'long' or 'int', depending on the platform's + * ptrdiff_t. + */ + +/* lint1-extra-flags: -a */ +/* lint1-only-if: ilp32 int */ + +/* + * Seen in usr.bin/make/var.c, function RegexReplace, in the function call + * SepBuf_AddBytesBetween(buf, wp + m[0].rm_so, wp + m[0].rm_eo). The + * offsets of regular expression matches have type off_t, which is a 64-bit + * integer. + * + * C11 6.5.6p8 does not explicitly define the meaning of a pointer + an + * overly long integer, it just says "undefined behavior" if the resulting + * pointer would be outside the object. + */ +const char * +array_subscript(const char *p, long long idx) +{ + /* expect+1: warning: conversion from 'long long' to 'int' may lose accuracy [132] */ + return p + idx; +} Index: src/tests/usr.bin/xlint/lint1/msg_132_ilp32.exp diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_132_ilp32.exp:1.1 --- /dev/null Wed Aug 25 22:04:52 2021 +++ src/tests/usr.bin/xlint/lint1/msg_132_ilp32.exp Wed Aug 25 22:04:52 2021 @@ -0,0 +1 @@ +msg_132_ilp32.c(31): warning: conversion from 'long long' to 'int' may lose accuracy [132]