Module Name: src Committed By: rillig Date: Sun Aug 1 13:31:49 UTC 2021
Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/xlint/lint1: Makefile Added Files: src/tests/usr.bin/xlint/lint1: expr_binary.c expr_binary.exp Log Message: tests/lint: test the usual arithmetic conversions The function 'balance' does not mention __uint128_t and nevertheless works as expected. Need to investigate further. To generate a diff of this commit: cvs rdiff -u -r1.1098 -r1.1099 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.97 -r1.98 src/tests/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/expr_binary.c \ src/tests/usr.bin/xlint/lint1/expr_binary.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.1098 src/distrib/sets/lists/tests/mi:1.1099 --- src/distrib/sets/lists/tests/mi:1.1098 Sat Jul 31 20:55:45 2021 +++ src/distrib/sets/lists/tests/mi Sun Aug 1 13:31:48 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1098 2021/07/31 20:55:45 rillig Exp $ +# $NetBSD: mi,v 1.1099 2021/08/01 13:31:48 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -6236,6 +6236,8 @@ ./usr/tests/usr.bin/xlint/lint1/emit.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/emit.exp-ln tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/emit.ln tests-obsolete obsolete +./usr/tests/usr.bin/xlint/lint1/expr_binary.c tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/expr_binary.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/expr_precedence.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/expr_precedence.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/expr_range.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.97 src/tests/usr.bin/xlint/lint1/Makefile:1.98 --- src/tests/usr.bin/xlint/lint1/Makefile:1.97 Sun Jul 25 22:03:42 2021 +++ src/tests/usr.bin/xlint/lint1/Makefile Sun Aug 1 13:31:49 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.97 2021/07/25 22:03:42 rillig Exp $ +# $NetBSD: Makefile,v 1.98 2021/08/01 13:31:49 rillig Exp $ NOMAN= # defined MAX_MESSAGE= 345 # see lint1/err.c @@ -131,6 +131,8 @@ FILES+= decl_struct_member.exp FILES+= emit.c FILES+= emit.exp FILES+= emit.exp-ln +FILES+= expr_binary.c +FILES+= expr_binary.exp FILES+= expr_precedence.c FILES+= expr_precedence.exp FILES+= expr_range.c Added files: Index: src/tests/usr.bin/xlint/lint1/expr_binary.c diff -u /dev/null src/tests/usr.bin/xlint/lint1/expr_binary.c:1.1 --- /dev/null Sun Aug 1 13:31:49 2021 +++ src/tests/usr.bin/xlint/lint1/expr_binary.c Sun Aug 1 13:31:49 2021 @@ -0,0 +1,47 @@ +/* $NetBSD: expr_binary.c,v 1.1 2021/08/01 13:31:49 rillig Exp $ */ +# 3 "expr_binary.c" + +/* + * Test binary operators, in particular the usual arithmetic conversions. + * + * C99 6.3.1.8 "Usual arithmetic conversions" + */ + +/* lint1-extra-flags: -Ac11 */ +/* lint1-only-if: lp64 */ + +struct incompatible { /* just to generate the error message */ + int member; +}; +void sink(struct incompatible); + +void +cover_balance(void) +{ + /* expect+1: 'int' */ + sink(1 + '\0'); + + /* expect+1: 'int' */ + sink((char)'\0' + (char)'\0'); + + /* expect+1: 'float' */ + sink(1 + 1.0f); + + /* expect+1: 'double' */ + sink(1 + 1.0); + + /* expect+1: 'float' */ + sink((long long)1 + 1.0f); + + /* expect+1: 'float' */ + sink((long long)1 + 1.0f); + + /* expect+1: 'float' */ + sink((__uint128_t)1 + 1.0f); + + /* expect+1: '__uint128_t' */ + sink((__uint128_t)1 + 1); + + /* expect+1: '__int128_t' */ + sink((__int128_t)1 + 1); +} Index: src/tests/usr.bin/xlint/lint1/expr_binary.exp diff -u /dev/null src/tests/usr.bin/xlint/lint1/expr_binary.exp:1.1 --- /dev/null Sun Aug 1 13:31:49 2021 +++ src/tests/usr.bin/xlint/lint1/expr_binary.exp Sun Aug 1 13:31:49 2021 @@ -0,0 +1,9 @@ +expr_binary.c(22): warning: passing 'int' to incompatible 'struct incompatible', arg #1 [155] +expr_binary.c(25): warning: passing 'int' to incompatible 'struct incompatible', arg #1 [155] +expr_binary.c(28): warning: passing 'float' to incompatible 'struct incompatible', arg #1 [155] +expr_binary.c(31): warning: passing 'double' to incompatible 'struct incompatible', arg #1 [155] +expr_binary.c(34): warning: passing 'float' to incompatible 'struct incompatible', arg #1 [155] +expr_binary.c(37): warning: passing 'float' to incompatible 'struct incompatible', arg #1 [155] +expr_binary.c(40): warning: passing 'float' to incompatible 'struct incompatible', arg #1 [155] +expr_binary.c(43): warning: passing '__uint128_t' to incompatible 'struct incompatible', arg #1 [155] +expr_binary.c(46): warning: passing '__int128_t' to incompatible 'struct incompatible', arg #1 [155]