diff options
| author | rillig <rillig@NetBSD.org> | 2023-07-07 20:19:08 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2023-07-07 20:19:08 +0000 |
| commit | c1f166c43175f048ffeb27a51ea2c80a1c068dc1 (patch) | |
| tree | a80423da43b291496b7d29275aa99c0b2f8c9a20 | |
| parent | 4175df945b048e5aeed932baf36d22ba89310121 (diff) | |
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.
| -rw-r--r-- | usr.bin/xlint/lint1/tree.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/usr.bin/xlint/lint1/tree.c b/usr.bin/xlint/lint1/tree.c index 5eaefd5f87e..c38f1e45809 100644 --- a/usr.bin/xlint/lint1/tree.c +++ b/usr.bin/xlint/lint1/tree.c @@ -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, tnode_t *ln, tnode_t *rn) } } - 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, tspec_t rt) * 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); } |
