Source-Changes-HG archive

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

[src/trunk]: src tests/lint: move platform-specific query tests to separate f...



details:   https://anonhg.NetBSD.org/src/rev/e80df486eae5
branches:  trunk
changeset: 377252:e80df486eae5
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jul 03 15:29:42 2023 +0000

description:
tests/lint: move platform-specific query tests to separate files

This fixes the tests on 'unsigned char' platforms.

Thanks martin@ for the notification.

diffstat:

 distrib/sets/lists/tests/mi               |   4 ++-
 tests/usr.bin/xlint/lint1/queries.c       |  22 ++++++++++++------
 tests/usr.bin/xlint/lint1/queries_schar.c |  32 +++++++++++++++++++++++++++
 tests/usr.bin/xlint/lint1/queries_uchar.c |  36 +++++++++++++++++++++++++++++++
 4 files changed, 85 insertions(+), 9 deletions(-)

diffs (153 lines):

diff -r 6dfa77ef90e8 -r e80df486eae5 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Mon Jul 03 11:16:32 2023 +0000
+++ b/distrib/sets/lists/tests/mi       Mon Jul 03 15:29:42 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1272 2023/07/02 23:40:23 rillig Exp $
+# $NetBSD: mi,v 1.1273 2023/07/03 15:29:42 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -7467,6 +7467,8 @@
 ./usr/tests/usr.bin/xlint/lint1/platform_uchar.c               tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/platform_uchar.exp             tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/xlint/lint1/queries.c                      tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/queries_schar.c                        tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/queries_uchar.c                        tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/stmt_for.c                     tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/stmt_for.exp                   tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/xlint/lint1/stmt_goto.c                    tests-usr.bin-tests     compattestfile,atf
diff -r 6dfa77ef90e8 -r e80df486eae5 tests/usr.bin/xlint/lint1/queries.c
--- a/tests/usr.bin/xlint/lint1/queries.c       Mon Jul 03 11:16:32 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/queries.c       Mon Jul 03 15:29:42 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: queries.c,v 1.18 2023/06/30 08:45:22 rillig Exp $      */
+/*     $NetBSD: queries.c,v 1.19 2023/07/03 15:29:42 rillig Exp $      */
 # 3 "queries.c"
 
 /*
@@ -82,6 +82,7 @@ Q2(double dbl)
        return (int)dbl;
 }
 
+// The Q3 query triggers so often that it also occurs outside this function.
 void
 Q3(int i, unsigned u)
 {
@@ -90,6 +91,13 @@ Q3(int i, unsigned u)
 
        /* expect+1: implicit conversion changes sign from 'unsigned int' to 'int' [Q3] */
        i = u;
+
+       /* expect+2: implicit conversion changes sign from 'unsigned char' to 'int' [Q3] */
+       /* expect+1: implicit conversion changes sign from 'int' to 'unsigned short' [Q3] */
+       u16 += u8;
+       /* expect+2: implicit conversion changes sign from 'unsigned short' to 'int' [Q3] */
+       /* expect+1: implicit conversion changes sign from 'int' to 'unsigned int' [Q3] */
+       u32 += u16;
 }
 
 unsigned long long
@@ -343,9 +351,9 @@ Q9(int x)
                return (0.0);
        case 9:
                return
-# 347 "queries.c" 3 4
+# 355 "queries.c" 3 4
                ((void *)0)
-# 349 "queries.c"
+# 357 "queries.c"
                /* expect+1: warning: illegal combination of integer 'int' and pointer 'pointer to void' [183] */
                ;
        case 10:
@@ -404,12 +412,10 @@ void extern_Q13(void);
 extern void extern_Q13(void), *extern_ptr;
 
 int
-Q14(char c, signed char sc, unsigned char uc, int wc)
+Q14(signed char sc, unsigned char uc, int wc)
 {
-       /* expect+2: comparison '==' of 'char' with plain integer 92 [Q14] */
-       /* expect+1: comparison '==' of 'char' with plain integer 0 [Q14] */
-       if (c == 'c' || c == L'w' || c == 92 || c == 0)
-               return 1;
+       // Plain 'char' is platform-dependent, see queries-{schar,uchar}.c.
+
        if (sc == 'c' || sc == L'w' || sc == 92 || sc == 0)
                return 2;
        /* expect+4: implicit conversion changes sign from 'unsigned char' to 'int' [Q3] */
diff -r 6dfa77ef90e8 -r e80df486eae5 tests/usr.bin/xlint/lint1/queries_schar.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/queries_schar.c Mon Jul 03 15:29:42 2023 +0000
@@ -0,0 +1,32 @@
+/*     $NetBSD: queries_schar.c,v 1.1 2023/07/03 15:29:42 rillig Exp $ */
+# 3 "queries_schar.c"
+
+/*
+ * Tests for queries that are specific to platforms where 'char' has the same
+ * representation as 'signed char'.
+ *
+ * See also:
+ *     queries.c               platform-independent tests
+ *     queries_uchar.c         for platforms where 'char' is unsigned
+ */
+
+/* lint1-only-if: schar */
+/* lint1-extra-flags: -q 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 -X 351 */
+
+int
+Q14(char c)
+{
+       /* expect+2: comparison '==' of 'char' with plain integer 92 [Q14] */
+       /* expect+1: comparison '==' of 'char' with plain integer 0 [Q14] */
+       if (c == 'c' || c == L'w' || c == 92 || c == 0)
+               return 1;
+       return 5;
+}
+
+/*
+ * Since queries do not affect the exit status, force a warning to make this
+ * test conform to the general expectation that a test that produces output
+ * exits non-successfully.
+ */
+/* expect+1: warning: static variable 'unused' unused [226] */
+static int unused;
diff -r 6dfa77ef90e8 -r e80df486eae5 tests/usr.bin/xlint/lint1/queries_uchar.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/queries_uchar.c Mon Jul 03 15:29:42 2023 +0000
@@ -0,0 +1,36 @@
+/*     $NetBSD: queries_uchar.c,v 1.1 2023/07/03 15:29:42 rillig Exp $ */
+# 3 "queries_uchar.c"
+
+/*
+ * Tests for queries that are specific to platforms where 'char' has the same
+ * representation as 'unsigned char'.
+ *
+ * See also:
+ *     queries.c               platform-independent tests
+ *     queries_schar.c         for platforms where 'char' is signed
+ */
+
+/* lint1-only-if: uchar */
+/* lint1-extra-flags: -q 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 -X 351 */
+
+int
+Q14(char c)
+{
+       /* expect+6: implicit conversion changes sign from 'char' to 'int' [Q3] */
+       /* expect+5: implicit conversion changes sign from 'char' to 'int' [Q3] */
+       /* expect+4: implicit conversion changes sign from 'char' to 'int' [Q3] */
+       /* expect+3: comparison '==' of 'char' with plain integer 92 [Q14] */
+       /* expect+2: implicit conversion changes sign from 'char' to 'int' [Q3] */
+       /* expect+1: comparison '==' of 'char' with plain integer 0 [Q14] */
+       if (c == 'c' || c == L'w' || c == 92 || c == 0)
+               return 1;
+       return 5;
+}
+
+/*
+ * Since queries do not affect the exit status, force a warning to make this
+ * test conform to the general expectation that a test that produces output
+ * exits non-successfully.
+ */
+/* expect+1: warning: static variable 'unused' unused [226] */
+static int unused;



Home | Main Index | Thread Index | Old Index