Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 lint: only warn about traditional/C90 di...



details:   https://anonhg.NetBSD.org/src/rev/3b87aa7ea6fe
branches:  trunk
changeset: 377340:3b87aa7ea6fe
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jul 07 20:19:08 2023 +0000

description:
lint: only warn about traditional/C90 differences in migration mode

In C99 mode, there is no point warning about traditional C.

No change in the tests, as a complete test suite would require several
new test files, and migration mode is not used intensively.

diffstat:

 usr.bin/xlint/lint1/tree.c |  30 +++++++++++++-----------------
 1 files changed, 13 insertions(+), 17 deletions(-)

diffs (58 lines):

diff -r 3b661c23eeae -r 3b87aa7ea6fe usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Fri Jul 07 19:45:22 2023 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Fri Jul 07 20:19:08 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.548 2023/07/07 06:03:31 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.549 2023/07/07 20:19:08 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.548 2023/07/07 06:03:31 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.549 2023/07/07 20:19:08 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -1348,20 +1348,16 @@ build_assignment(op_t op, bool sys, tnod
                }
        }
 
-       if (op == SHLASS) {
-               if (portable_size_in_bits(lt) < portable_size_in_bits(rt)) {
-                       if (hflag)
-                               /* semantics of '%s' change in ANSI C; ... */
-                               warning(118, "<<=");
-               }
-       } else if (op != SHRASS) {
-               if (op == ASSIGN || lt != PTR) {
-                       if (lt != rt ||
-                           (ln->tn_type->t_bitfield && rn->tn_op == CON)) {
-                               rn = convert(op, 0, ln->tn_type, rn);
-                               rt = lt;
-                       }
-               }
+       if (op == SHLASS && hflag && allow_trad && allow_c90
+           && portable_size_in_bits(lt) < portable_size_in_bits(rt))
+               /* semantics of '%s' change in ANSI C; ... */
+               warning(118, "<<=");
+
+       if (op != SHLASS && op != SHRASS
+           && (op == ASSIGN || lt != PTR)
+           && (lt != rt || (ln->tn_type->t_bitfield && rn->tn_op == CON))) {
+               rn = convert(op, 0, ln->tn_type, rn);
+               rt = lt;
        }
 
        if (any_query_enabled && rn->tn_op == CVT && rn->tn_cast &&
@@ -2317,7 +2313,7 @@ typeok_shl(const mod_t *mp, tspec_t lt, 
                 * that there is really a difference between
                 * ANSI C and traditional C.
                 */
-               if (hflag && !allow_c99)
+               if (hflag && allow_trad && allow_c90)
                        /* semantics of '%s' change in ANSI C; use ... */
                        warning(118, mp->m_name);
        }



Home | Main Index | Thread Index | Old Index