lint: in the warning about ordered enums, mention the affected type
This commit is contained in:
parent
ea3322651c
commit
62071d8c64
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: msg_243.c,v 1.5 2023/03/28 14:44:35 rillig Exp $ */
|
||||
/* $NetBSD: msg_243.c,v 1.6 2023/07/09 12:04:08 rillig Exp $ */
|
||||
# 3 "msg_243.c"
|
||||
|
||||
// Test for message: dubious comparison of enums, op '%s' [243]
|
||||
// Test for message: operator '%s' assumes that '%s' is ordered [243]
|
||||
|
||||
/* lint1-extra-flags: -eP -X 351 */
|
||||
|
||||
|
@ -16,13 +16,13 @@ void eval(_Bool);
|
|||
void
|
||||
example(enum color a, enum color b)
|
||||
{
|
||||
/* expect+1: warning: dubious comparison of enums, op '<' [243] */
|
||||
/* expect+1: warning: operator '<' assumes that 'enum color' is ordered [243] */
|
||||
eval(a < b);
|
||||
/* expect+1: warning: dubious comparison of enums, op '<=' [243] */
|
||||
/* expect+1: warning: operator '<=' assumes that 'enum color' is ordered [243] */
|
||||
eval(a <= b);
|
||||
/* expect+1: warning: dubious comparison of enums, op '>' [243] */
|
||||
/* expect+1: warning: operator '>' assumes that 'enum color' is ordered [243] */
|
||||
eval(a > b);
|
||||
/* expect+1: warning: dubious comparison of enums, op '>=' [243] */
|
||||
/* expect+1: warning: operator '>=' assumes that 'enum color' is ordered [243] */
|
||||
eval(a >= b);
|
||||
eval(a == b);
|
||||
eval(a != b);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: err.c,v 1.208 2023/07/09 11:18:55 rillig Exp $ */
|
||||
/* $NetBSD: err.c,v 1.209 2023/07/09 12:04:08 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID)
|
||||
__RCSID("$NetBSD: err.c,v 1.208 2023/07/09 11:18:55 rillig Exp $");
|
||||
__RCSID("$NetBSD: err.c,v 1.209 2023/07/09 12:04:08 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
@ -298,7 +298,7 @@ static const char *const msgs[] = {
|
|||
"", /* unused */ /* 240 */
|
||||
"dubious operation '%s' on enum", /* 241 */
|
||||
"combination of '%s' and '%s', op '%s'", /* 242 */
|
||||
"dubious comparison of enums, op '%s'", /* 243 */
|
||||
"operator '%s' assumes that '%s' is ordered", /* 243 */
|
||||
"illegal structure pointer combination", /* 244 */
|
||||
"incompatible structure pointers: '%s' '%s' '%s'", /* 245 */
|
||||
"dubious conversion of enum to '%s'", /* 246 */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tree.c,v 1.557 2023/07/09 11:18:55 rillig Exp $ */
|
||||
/* $NetBSD: tree.c,v 1.558 2023/07/09 12:04: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.557 2023/07/09 11:18:55 rillig Exp $");
|
||||
__RCSID("$NetBSD: tree.c,v 1.558 2023/07/09 12:04:08 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <float.h>
|
||||
|
@ -3132,11 +3132,9 @@ check_enum_type_mismatch(op_t op, int arg, const tnode_t *ln, const tnode_t *rn)
|
|||
type_name(rn->tn_type));
|
||||
break;
|
||||
}
|
||||
} else if (Pflag && mp->m_comparison && op != EQ && op != NE) {
|
||||
if (eflag)
|
||||
/* dubious comparison of enums, op '%s' */
|
||||
warning(243, mp->m_name);
|
||||
}
|
||||
} else if (Pflag && eflag && mp->m_comparison && op != EQ && op != NE)
|
||||
/* operator '%s' assumes that '%s' is ordered */
|
||||
warning(243, mp->m_name, type_name(ln->tn_type));
|
||||
}
|
||||
|
||||
/* Prints a warning if the operands mix between enum and integer. */
|
||||
|
|
Loading…
Reference in New Issue