Module Name: src Committed By: rillig Date: Sat Jan 16 18:58:22 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: d_c99_bool_strict.exp src/usr.bin/xlint/lint1: tree.c Log Message: lint: simplify typeok_strict_bool_compatible To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp cvs rdiff -u -r1.160 -r1.161 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/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.9 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.10 --- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.9 Sat Jan 16 18:48:52 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp Sat Jan 16 18:58:21 2021 @@ -20,7 +20,7 @@ d_c99_bool_strict.c(224): operands of '= d_c99_bool_strict.c(252): return value type mismatch (_Bool) and (int) [211] d_c99_bool_strict.c(258): return value type mismatch (_Bool) and (int) [211] d_c99_bool_strict.c(264): return value type mismatch (_Bool) and (int) [211] -d_c99_bool_strict.c(270): return value type mismatch (_Bool) and (pointer to const void) [211] +d_c99_bool_strict.c(270): return value type mismatch (_Bool) and (pointer) [211] d_c99_bool_strict.c(268): warning: argument p unused in function strict_bool_conversion_return_pointer [231] d_c99_bool_strict.c(276): return value type mismatch (char) and (_Bool) [211] d_c99_bool_strict.c(282): return value type mismatch (char) and (_Bool) [211] Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.160 src/usr.bin/xlint/lint1/tree.c:1.161 --- src/usr.bin/xlint/lint1/tree.c:1.160 Sat Jan 16 18:48:52 2021 +++ src/usr.bin/xlint/lint1/tree.c Sat Jan 16 18:58:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.160 2021/01/16 18:48:52 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.161 2021/01/16 18:58:21 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.160 2021/01/16 18:48:52 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.161 2021/01/16 18:58:21 rillig Exp $"); #endif #include <float.h> @@ -1088,9 +1088,7 @@ typeok_assign(const mod_t *mp, const tno * special rule C99 6.3.1.2, without silent change in behavior. */ static bool -typeok_strict_bool_assign(op_t op, int arg, - const tnode_t *ln, tspec_t lt, - const tnode_t *rn, tspec_t rt) +typeok_strict_bool_compatible(op_t op, int arg, tspec_t lt, tspec_t rt) { if ((lt == BOOL) == (rt == BOOL)) return true; @@ -1100,8 +1098,7 @@ typeok_strict_bool_assign(op_t op, int a error(334, arg, tspec_name(lt), tspec_name(rt)); } else if (op == RETURN) { /* return value type mismatch (%s) and (%s) */ - error(211, type_name(ln->tn_type), type_name(rn->tn_type)); - return false; + error(211, tspec_name(lt), tspec_name(rt)); } else { /* operands of '%s' have incompatible types (%s != %s) */ error(107, getopname(op), tspec_name(lt), tspec_name(rt)); @@ -1148,7 +1145,7 @@ typeok_scalar_strict_bool(op_t op, const } if (needs_compatible_types(op)) - return typeok_strict_bool_assign(op, arg, ln, lt, rn, rt); + return typeok_strict_bool_compatible(op, arg, lt, rt); if (mp->m_takes_only_bool || op == QUEST) { bool binary = mp->m_binary;