Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src tests/lint: test the usual arithmetic conversions



details:   https://anonhg.NetBSD.org/src/rev/9065542d6d47
branches:  trunk
changeset: 984941:9065542d6d47
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 01 13:31:48 2021 +0000

description:
tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected.  Need to investigate further.

diffstat:

 distrib/sets/lists/tests/mi               |   4 +-
 tests/usr.bin/xlint/lint1/Makefile        |   4 +-
 tests/usr.bin/xlint/lint1/expr_binary.c   |  47 +++++++++++++++++++++++++++++++
 tests/usr.bin/xlint/lint1/expr_binary.exp |   9 +++++
 4 files changed, 62 insertions(+), 2 deletions(-)

diffs (100 lines):

diff -r f49abb86aad9 -r 9065542d6d47 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun Aug 01 13:09:38 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Aug 01 13:31:48 2021 +0000
@@ -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
diff -r f49abb86aad9 -r 9065542d6d47 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Sun Aug 01 13:09:38 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Sun Aug 01 13:31:48 2021 +0000
@@ -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+=                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
diff -r f49abb86aad9 -r 9065542d6d47 tests/usr.bin/xlint/lint1/expr_binary.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/expr_binary.c   Sun Aug 01 13:31:48 2021 +0000
@@ -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);
+}
diff -r f49abb86aad9 -r 9065542d6d47 tests/usr.bin/xlint/lint1/expr_binary.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/expr_binary.exp Sun Aug 01 13:31:48 2021 +0000
@@ -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]



Home | Main Index | Thread Index | Old Index