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: explain failing test case in...



details:   https://anonhg.NetBSD.org/src/rev/9f40e84a1a3a
branches:  trunk
changeset: 958702:9f40e84a1a3a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 17 13:15:03 2021 +0000

description:
lint: explain failing test case in strict bool mode

diffstat:

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

diffs (46 lines):

diff -r 10d0b55d21c4 -r 9f40e84a1a3a tests/usr.bin/xlint/lint1/d_c99_bool_strict.c
--- a/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c     Sun Jan 17 12:23:01 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c     Sun Jan 17 13:15:03 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_c99_bool_strict.c,v 1.13 2021/01/17 11:32:06 rillig Exp $    */
+/*     $NetBSD: d_c99_bool_strict.c,v 1.14 2021/01/17 13:15:03 rillig Exp $    */
 # 3 "d_c99_bool_strict.c"
 
 /*
@@ -716,6 +716,27 @@
        (void)(strict_bool_conversion_return_false() == 0); /* expect: 107 */
 }
 
+/*
+ * When building the NE node, the following steps happen:
+ *
+ * ln is promoted from BOOL:1 to INT:1 since it is a bit field and C90 says
+ * that bit fields must always be promoted to int.
+ *
+ * rn is promoted from BOOL.  promote() does not handle BOOL explicitly,
+ * therefore it is kept as-is.  That may or may not have been an oversight
+ * in the initial implementation of supporting BOOL.
+ *
+ * After that, the two nodes are balanced.  At this point, their types are
+ * INT:1 and BOOL.  INT is considered the larger of the two types, even
+ * though it is a bit field in this case.  Therefore BOOL is converted to
+ * INT now, and since it is a constant, the converted node loses all
+ * information about its previous type.
+ *
+ * During these conversions and promotions, the code asks whether BOOL
+ * is an arithmetic type.  If that isn't the case, no conversion or
+ * promotion takes place.  Since strict bool mode explicitly treats BOOL
+ * as non-arithmetic, changing is_arithmetic sounds like the way to go.
+ */
 void
 strict_bool_assign_bit_field_then_compare(void)
 {
diff -r 10d0b55d21c4 -r 9f40e84a1a3a tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp
--- a/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp   Sun Jan 17 12:23:01 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp   Sun Jan 17 13:15:03 2021 +0000
@@ -142,4 +142,4 @@
 d_c99_bool_strict.c(677): operands of '=' have incompatible types (_Bool != int) [107]
 d_c99_bool_strict.c(652): warning: argument flags unused in function strict_bool_bitwise_and_enum [231]
 d_c99_bool_strict.c(716): operands of '==' have incompatible types (_Bool != int) [107]
-d_c99_bool_strict.c(729): operands of '!=' have incompatible types (_Bool != int) [107]
+d_c99_bool_strict.c(750): operands of '!=' have incompatible types (_Bool != int) [107]



Home | Main Index | Thread Index | Old Index