Module Name: src
Committed By: rillig
Date: Tue Jun 21 22:21:49 UTC 2022
Modified Files:
src/usr.bin/xlint/lint1: tree.c
Log Message:
lint: merge duplicate code in typeok_minus
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.457 -r1.458 src/usr.bin/xlint/lint1/tree.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.457 src/usr.bin/xlint/lint1/tree.c:1.458
--- src/usr.bin/xlint/lint1/tree.c:1.457 Tue Jun 21 22:16:26 2022
+++ src/usr.bin/xlint/lint1/tree.c Tue Jun 21 22:21:49 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.457 2022/06/21 22:16:26 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.458 2022/06/21 22:21:49 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.457 2022/06/21 22:16:26 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.458 2022/06/21 22:21:49 rillig Exp $");
#endif
#include <float.h>
@@ -1106,10 +1106,8 @@ typeok_minus(op_t op,
const type_t *rtp, tspec_t rt)
{
/* operands have scalar types (checked in typeok) */
- if (lt == PTR && (!is_integer(rt) && rt != PTR)) {
- warn_incompatible_types(op, ltp, lt, rtp, rt);
- return false;
- } else if (rt == PTR && lt != PTR) {
+ if ((lt == PTR && rt != PTR && !is_integer(rt)) ||
+ (lt != PTR && rt == PTR)) {
warn_incompatible_types(op, ltp, lt, rtp, rt);
return false;
}