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: flatten typeok_ordered_comparison
details: https://anonhg.NetBSD.org/src/rev/a34d56d1ece7
branches: trunk
changeset: 949825:a34d56d1ece7
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jan 17 16:32:36 2021 +0000
description:
lint: flatten typeok_ordered_comparison
diffstat:
usr.bin/xlint/lint1/tree.c | 33 +++++++++++++++++----------------
1 files changed, 17 insertions(+), 16 deletions(-)
diffs (56 lines):
diff -r 251a9e54ff7a -r a34d56d1ece7 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sun Jan 17 16:25:30 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sun Jan 17 16:32:36 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.177 2021/01/17 16:25:30 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.178 2021/01/17 16:32:36 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.177 2021/01/17 16:25:30 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.178 2021/01/17 16:32:36 rillig Exp $");
#endif
#include <float.h>
@@ -962,22 +962,23 @@
const tnode_t *ln, const type_t *ltp, tspec_t lt,
const tnode_t *rn, const type_t *rtp, tspec_t rt)
{
- if ((lt == PTR || rt == PTR) && lt != rt) {
- if (is_integer(lt) || is_integer(rt)) {
- const char *lx = lt == PTR ?
- "pointer" : "integer";
- const char *rx = rt == PTR ?
- "pointer" : "integer";
- /* illegal combination of %s (%s) and ... */
- warning(123, lx, type_name(ltp),
- rx, type_name(rtp), getopname(op));
- } else {
- warn_incompatible_types(op, lt, rt);
- return false;
- }
- } else if (lt == PTR && rt == PTR) {
+ if (lt == PTR && rt == PTR) {
check_pointer_comparison(op, ln, rn);
+ return true;
}
+
+ if (lt != PTR && rt != PTR)
+ return true;
+
+ if (!is_integer(lt) && !is_integer(rt)) {
+ warn_incompatible_types(op, lt, rt);
+ return false;
+ }
+
+ const char *lx = lt == PTR ? "pointer" : "integer";
+ const char *rx = rt == PTR ? "pointer" : "integer";
+ /* illegal combination of %s (%s) and %s (%s), op %s */
+ warning(123, lx, type_name(ltp), rx, type_name(rtp), getopname(op));
return true;
}
Home |
Main Index |
Thread Index |
Old Index