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 tests/lint: add platform-specific ...



details:   https://anonhg.NetBSD.org/src/rev/c16e68d323e1
branches:  trunk
changeset: 373644:c16e68d323e1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Feb 22 22:12:35 2023 +0000

description:
tests/lint: add platform-specific tests

diffstat:

 tests/usr.bin/xlint/lint1/platform_ilp32.c   |  21 +++++++++++++++++----
 tests/usr.bin/xlint/lint1/platform_ldbl128.c |   9 ++++-----
 tests/usr.bin/xlint/lint1/platform_ldbl64.c  |   9 ++++-----
 tests/usr.bin/xlint/lint1/platform_ldbl96.c  |   9 ++++-----
 tests/usr.bin/xlint/lint1/platform_lp64.c    |  21 +++++++++++++++++----
 tests/usr.bin/xlint/lint1/platform_schar.c   |  10 +++++-----
 tests/usr.bin/xlint/lint1/platform_uchar.c   |   9 ++++-----
 7 files changed, 55 insertions(+), 33 deletions(-)

diffs (173 lines):

diff -r 6df4a34d1d33 -r c16e68d323e1 tests/usr.bin/xlint/lint1/platform_ilp32.c
--- a/tests/usr.bin/xlint/lint1/platform_ilp32.c        Wed Feb 22 21:49:45 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_ilp32.c        Wed Feb 22 22:12:35 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: platform_ilp32.c,v 1.2 2021/09/26 14:28:22 rillig Exp $        */
+/*     $NetBSD: platform_ilp32.c,v 1.3 2023/02/22 22:12:35 rillig Exp $        */
 # 3 "platform_ilp32.c"
 
 /*
@@ -9,7 +9,20 @@
 /* lint1-extra-flags: -c -h -a -p -b -r -z */
 /* lint1-only-if: ilp32 */
 
-// TODO: Add some code that passes.
-// TODO: Add some code that fails.
+int s32;
+unsigned int u32;
+long sl32;
+unsigned long ul32;
 
-/* expect+1: warning: empty translation unit [272] */
+void
+convert_between_int_and_long(void)
+{
+       /*
+        * No warning about possible loss of accuracy, as the types have the
+        * same size.
+        */
+       s32 = sl32;
+       sl32 = s32;
+       u32 = ul32;
+       ul32 = u32;
+}
diff -r 6df4a34d1d33 -r c16e68d323e1 tests/usr.bin/xlint/lint1/platform_ldbl128.c
--- a/tests/usr.bin/xlint/lint1/platform_ldbl128.c      Wed Feb 22 21:49:45 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_ldbl128.c      Wed Feb 22 22:12:35 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: platform_ldbl128.c,v 1.2 2021/09/26 14:28:22 rillig Exp $      */
+/*     $NetBSD: platform_ldbl128.c,v 1.3 2023/02/22 22:12:35 rillig Exp $      */
 # 3 "platform_ldbl128.c"
 
 /*
@@ -8,7 +8,6 @@
 /* lint1-extra-flags: -c -h -a -p -b -r -z */
 /* lint1-only-if: ldbl-128 */
 
-// TODO: Add some code that passes.
-// TODO: Add some code that fails.
-
-/* expect+1: warning: empty translation unit [272] */
+/* CONSTCOND */
+typedef int bits_per_byte[((unsigned char)-1) == 255 ? 1 : -1];
+typedef int bytes_per_long_double[sizeof(long double) == 16 ? 1 : -1];
diff -r 6df4a34d1d33 -r c16e68d323e1 tests/usr.bin/xlint/lint1/platform_ldbl64.c
--- a/tests/usr.bin/xlint/lint1/platform_ldbl64.c       Wed Feb 22 21:49:45 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_ldbl64.c       Wed Feb 22 22:12:35 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: platform_ldbl64.c,v 1.2 2021/09/26 14:28:22 rillig Exp $       */
+/*     $NetBSD: platform_ldbl64.c,v 1.3 2023/02/22 22:12:35 rillig Exp $       */
 # 3 "platform_ldbl64.c"
 
 /*
@@ -8,7 +8,6 @@
 /* lint1-extra-flags: -c -h -a -p -b -r -z */
 /* lint1-only-if: ldbl-64 */
 
-// TODO: Add some code that passes.
-// TODO: Add some code that fails.
-
-/* expect+1: warning: empty translation unit [272] */
+/* CONSTCOND */
+typedef int bits_per_byte[((unsigned char)-1) == 255 ? 1 : -1];
+typedef int bytes_per_long_double[sizeof(long double) == 8 ? 1 : -1];
diff -r 6df4a34d1d33 -r c16e68d323e1 tests/usr.bin/xlint/lint1/platform_ldbl96.c
--- a/tests/usr.bin/xlint/lint1/platform_ldbl96.c       Wed Feb 22 21:49:45 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_ldbl96.c       Wed Feb 22 22:12:35 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: platform_ldbl96.c,v 1.2 2021/09/26 14:28:22 rillig Exp $       */
+/*     $NetBSD: platform_ldbl96.c,v 1.3 2023/02/22 22:12:35 rillig Exp $       */
 # 3 "platform_ldbl96.c"
 
 /*
@@ -8,7 +8,6 @@
 /* lint1-extra-flags: -c -h -a -p -b -r -z */
 /* lint1-only-if: ldbl-96 */
 
-// TODO: Add some code that passes.
-// TODO: Add some code that fails.
-
-/* expect+1: warning: empty translation unit [272] */
+/* CONSTCOND */
+typedef int bits_per_byte[((unsigned char)-1) == 255 ? 1 : -1];
+typedef int bytes_per_long_double[sizeof(long double) == 12 ? 1 : -1];
diff -r 6df4a34d1d33 -r c16e68d323e1 tests/usr.bin/xlint/lint1/platform_lp64.c
--- a/tests/usr.bin/xlint/lint1/platform_lp64.c Wed Feb 22 21:49:45 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_lp64.c Wed Feb 22 22:12:35 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: platform_lp64.c,v 1.3 2022/06/11 11:52:13 rillig Exp $ */
+/*     $NetBSD: platform_lp64.c,v 1.4 2023/02/22 22:12:35 rillig Exp $ */
 # 3 "platform_lp64.c"
 
 /*
@@ -9,6 +9,22 @@
 /* lint1-extra-flags: -c -h -a -p -b -r -z */
 /* lint1-only-if: lp64 */
 
+int s32;
+unsigned int u32;
+long sl32;
+unsigned long ul32;
+
+void
+convert_between_int_and_long(void)
+{
+       /* expect+1: warning: conversion from 'long' to 'int' may lose accuracy [132] */
+       s32 = sl32;
+       sl32 = s32;
+       /* expect+1: warning: conversion from 'unsigned long' to 'unsigned int' may lose accuracy [132] */
+       u32 = ul32;
+       ul32 = u32;
+}
+
 void to_size_t(typeof(sizeof(int)));
 
 void
@@ -17,6 +33,3 @@
        /* no warning, unlike platform_int */
        to_size_t(uc);
 }
-
-/* expect+1: warning: static variable 'unused_variable' unused [226] */
-static int unused_variable;
diff -r 6df4a34d1d33 -r c16e68d323e1 tests/usr.bin/xlint/lint1/platform_schar.c
--- a/tests/usr.bin/xlint/lint1/platform_schar.c        Wed Feb 22 21:49:45 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_schar.c        Wed Feb 22 22:12:35 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: platform_schar.c,v 1.2 2021/09/26 14:28:22 rillig Exp $        */
+/*     $NetBSD: platform_schar.c,v 1.3 2023/02/22 22:12:35 rillig Exp $        */
 # 3 "platform_schar.c"
 
 /*
@@ -9,7 +9,7 @@
 /* lint1-extra-flags: -c -h -a -p -b -r -z */
 /* lint1-only-if: schar */
 
-// TODO: Add some code that passes.
-// TODO: Add some code that fails.
-
-/* expect+1: warning: empty translation unit [272] */
+/* CONSTCOND */
+/* FIXME: Wrong order in the diagnostic, should be '-128 <' instead. */
+/* expect+1: warning: nonportable character comparison '< -128' [230] */
+typedef int is_signed[(char)'\200' < (char)'\177' ? 1 : -1];
diff -r 6df4a34d1d33 -r c16e68d323e1 tests/usr.bin/xlint/lint1/platform_uchar.c
--- a/tests/usr.bin/xlint/lint1/platform_uchar.c        Wed Feb 22 21:49:45 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/platform_uchar.c        Wed Feb 22 22:12:35 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: platform_uchar.c,v 1.2 2021/09/26 14:28:22 rillig Exp $        */
+/*     $NetBSD: platform_uchar.c,v 1.3 2023/02/22 22:12:35 rillig Exp $        */
 # 3 "platform_uchar.c"
 
 /*
@@ -9,7 +9,6 @@
 /* lint1-extra-flags: -c -h -a -p -b -r -z */
 /* lint1-only-if: uchar */
 
-// TODO: Add some code that passes.
-// TODO: Add some code that fails.
-
-/* expect+1: warning: empty translation unit [272] */
+/* CONSTCOND */
+/* expect+1: warning: nonportable character comparison '< 128' [230] */
+typedef int is_unsigned[(char)'\177' < (char)'\200' ? 1 : -1];



Home | Main Index | Thread Index | Old Index