Source-Changes-HG archive

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

[src/trunk]: src/tests/usr.bin/xlint/lint1 lint: test what happens for 'int <...



details:   https://anonhg.NetBSD.org/src/rev/ec42245f808e
branches:  trunk
changeset: 954387:ec42245f808e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Apr 06 21:44:12 2021 +0000

description:
lint: test what happens for 'int << double'

I just wanted to see whether typeok_shift would be reached in this case,
to ensure that is_uinteger applies as expected.  It does.

diffstat:

 tests/usr.bin/xlint/lint1/msg_121.c   |  12 +++++++++++-
 tests/usr.bin/xlint/lint1/msg_121.exp |   1 +
 2 files changed, 12 insertions(+), 1 deletions(-)

diffs (29 lines):

diff -r a2b6ec9fcbd6 -r ec42245f808e tests/usr.bin/xlint/lint1/msg_121.c
--- a/tests/usr.bin/xlint/lint1/msg_121.c       Tue Apr 06 21:35:25 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_121.c       Tue Apr 06 21:44:12 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_121.c,v 1.3 2021/01/31 11:12:07 rillig Exp $       */
+/*     $NetBSD: msg_121.c,v 1.4 2021/04/06 21:44:12 rillig Exp $       */
 # 3 "msg_121.c"
 
 // Test for message: negative shift [121]
@@ -8,3 +8,13 @@
 {
        return x << (3 - 5);            /* expect: 121 */
 }
+
+void /*ARGSUSED*/
+shift_by_double(int x, double amount)
+{
+       /*
+        * This is already caught by typeok_scalar, so it doesn't reach
+        * typeok_shift via typeok_op.
+        */
+       return x << amount;             /* expect: incompatible types */
+}
diff -r a2b6ec9fcbd6 -r ec42245f808e tests/usr.bin/xlint/lint1/msg_121.exp
--- a/tests/usr.bin/xlint/lint1/msg_121.exp     Tue Apr 06 21:35:25 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_121.exp     Tue Apr 06 21:44:12 2021 +0000
@@ -1,1 +1,2 @@
 msg_121.c(9): warning: negative shift [121]
+msg_121.c(19): error: operands of '<<' have incompatible types (int != double) [107]



Home | Main Index | Thread Index | Old Index