lint: add type information to enum type mismatch

This commit is contained in:
rillig 2021-02-28 01:30:22 +00:00
parent 4a3dd2aa12
commit fb1e12220d
4 changed files with 13 additions and 12 deletions

View File

@ -1,7 +1,7 @@
/* $NetBSD: msg_130.c,v 1.4 2021/02/27 13:43:36 rillig Exp $ */
/* $NetBSD: msg_130.c,v 1.5 2021/02/28 01:30:22 rillig Exp $ */
# 3 "msg_130.c"
// Test for message: enum type mismatch, op %s [130]
// Test for message: enum type mismatch: '%s' '%s' '%s' [130]
enum color {
RED = 1 << 0,

View File

@ -1,3 +1,3 @@
msg_130.c(27): warning: enum type mismatch, op : [130]
msg_130.c(29): warning: enum type mismatch, op != [130]
msg_130.c(30): warning: enum type mismatch, op == [130]
msg_130.c(27): warning: enum type mismatch: 'enum color' ':' 'enum daytime' [130]
msg_130.c(29): warning: enum type mismatch: 'enum color' '!=' 'enum size' [130]
msg_130.c(30): warning: enum type mismatch: 'enum color' '==' 'enum size' [130]

View File

@ -1,4 +1,4 @@
/* $NetBSD: err.c,v 1.83 2021/02/28 01:06:57 rillig Exp $ */
/* $NetBSD: err.c,v 1.84 2021/02/28 01:30:22 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: err.c,v 1.83 2021/02/28 01:06:57 rillig Exp $");
__RCSID("$NetBSD: err.c,v 1.84 2021/02/28 01:30:22 rillig Exp $");
#endif
#include <sys/types.h>
@ -189,7 +189,7 @@ const char *msgs[] = {
"'&' before array or function: ignored", /* 127 */
"operands have incompatible pointer types, op %s (%s != %s)", /* 128 */
"expression has null effect", /* 129 */
"enum type mismatch, op %s", /* 130 */
"enum type mismatch: '%s' '%s' '%s'", /* 130 */
"conversion to '%s' may sign-extend incorrectly", /* 131 */
"conversion from '%s' to '%s' may lose accuracy", /* 132 */
"conversion of pointer to '%s' loses bits", /* 133 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: tree.c,v 1.223 2021/02/28 01:06:57 rillig Exp $ */
/* $NetBSD: tree.c,v 1.224 2021/02/28 01:30:22 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.223 2021/02/28 01:06:57 rillig Exp $");
__RCSID("$NetBSD: tree.c,v 1.224 2021/02/28 01:30:22 rillig Exp $");
#endif
#include <float.h>
@ -1732,8 +1732,9 @@ check_enum_type_mismatch(op_t op, int arg, const tnode_t *ln, const tnode_t *rn)
type_name(ln->tn_type), type_name(rn->tn_type));
break;
default:
/* enum type mismatch, op %s */
warning(130, mp->m_name);
/* enum type mismatch: '%s' '%s' '%s' */
warning(130, type_name(ln->tn_type), mp->m_name,
type_name(rn->tn_type));
break;
}
} else if (Pflag && mp->m_comparison && op != EQ && op != NE) {