lint: add type information for message about unknown member name
This commit is contained in:
parent
ee9d2e6631
commit
94c797a88b
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: d_c99_init.c,v 1.25 2021/03/30 15:05:05 rillig Exp $ */
|
||||
/* $NetBSD: d_c99_init.c,v 1.26 2021/03/30 15:18:19 rillig Exp $ */
|
||||
# 3 "d_c99_init.c"
|
||||
|
||||
/*
|
||||
|
@ -329,21 +329,21 @@ ensure_array_type_is_not_modified_during_initialization(void)
|
|||
}
|
||||
|
||||
struct point unknown_member_name_beginning = {
|
||||
.r = 5, /* expect: undefined struct/union member: r */
|
||||
.r = 5, /* expect: does not have member 'r' */
|
||||
.x = 4,
|
||||
.y = 3,
|
||||
};
|
||||
|
||||
struct point unknown_member_name_middle = {
|
||||
.x = 4,
|
||||
.r = 5, /* expect: undefined struct/union member: r */
|
||||
.r = 5, /* expect: does not have member 'r' */
|
||||
.y = 3,
|
||||
};
|
||||
|
||||
struct point unknown_member_name_end = {
|
||||
.x = 4,
|
||||
.y = 3,
|
||||
.r = 5, /* expect: undefined struct/union member: r */
|
||||
.r = 5, /* expect: does not have member 'r' */
|
||||
};
|
||||
|
||||
union value {
|
||||
|
@ -352,18 +352,18 @@ union value {
|
|||
};
|
||||
|
||||
union value unknown_union_member_name_first = {
|
||||
.unknown_value = 4, /* expect: undefined struct/union member */
|
||||
.unknown_value = 4, /* expect: does not have member */
|
||||
.int_value = 3,
|
||||
};
|
||||
|
||||
union value unknown_union_member_name_second = {
|
||||
.int_value = 3,
|
||||
.unknown_value = 4, /* expect: undefined struct/union member */
|
||||
.unknown_value = 4, /* expect: does not have member */
|
||||
};
|
||||
|
||||
struct point designators_with_subscript = {
|
||||
[0] = 3, /* expect: only for arrays */
|
||||
.member[0][0].member = 4, /* expect: undefined struct/union member */
|
||||
.member[0][0].member = 4, /* expect: does not have member 'member' */
|
||||
.x.y.z = 5, /* intentionally not caught, see designator_look_up */
|
||||
};
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@ d_c99_init.c(238): warning: illegal combination of integer (char) and pointer (p
|
|||
d_c99_init.c(242): warning: illegal combination of integer (char) and pointer (pointer to char) [183]
|
||||
d_c99_init.c(281): error: cannot initialize 'struct <unnamed>' from 'int' [185]
|
||||
d_c99_init.c(323): error: duplicate case in switch: 0 [199]
|
||||
d_c99_init.c(332): error: undefined struct/union member: r [101]
|
||||
d_c99_init.c(339): error: undefined struct/union member: r [101]
|
||||
d_c99_init.c(346): error: undefined struct/union member: r [101]
|
||||
d_c99_init.c(355): error: undefined struct/union member: unknown_value [101]
|
||||
d_c99_init.c(361): error: undefined struct/union member: unknown_value [101]
|
||||
d_c99_init.c(332): error: type 'struct point' does not have member 'r' [101]
|
||||
d_c99_init.c(339): error: type 'struct point' does not have member 'r' [101]
|
||||
d_c99_init.c(346): error: type 'struct point' does not have member 'r' [101]
|
||||
d_c99_init.c(355): error: type 'union value' does not have member 'unknown_value' [101]
|
||||
d_c99_init.c(361): error: type 'union value' does not have member 'unknown_value' [101]
|
||||
d_c99_init.c(365): error: syntax error 'designator '[...]' is only for arrays' [249]
|
||||
d_c99_init.c(366): error: undefined struct/union member: member [101]
|
||||
d_c99_init.c(366): error: type 'struct point' does not have member 'member' [101]
|
||||
d_c99_init.c(372): warning: structure has no named members [65]
|
||||
d_c99_init.c(373): error: too many struct/union initializers [172]
|
||||
d_c99_init.c(378): warning: union has no named members [65]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: msg_101.c,v 1.3 2021/01/31 11:12:07 rillig Exp $ */
|
||||
/* $NetBSD: msg_101.c,v 1.4 2021/03/30 15:18:19 rillig Exp $ */
|
||||
# 3 "msg_101.c"
|
||||
|
||||
// Test for message: undefined struct/union member: %s [101]
|
||||
// Test for message: type '%s' does not have member '%s' [101]
|
||||
|
||||
struct point {
|
||||
int x, y;
|
||||
|
|
|
@ -1 +1 @@
|
|||
msg_101.c(13): error: undefined struct/union member: z [101]
|
||||
msg_101.c(13): error: type 'int' does not have member 'z' [101]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: err.c,v 1.98 2021/03/30 15:07:53 rillig Exp $ */
|
||||
/* $NetBSD: err.c,v 1.99 2021/03/30 15:18:19 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.98 2021/03/30 15:07:53 rillig Exp $");
|
||||
__RCSID("$NetBSD: err.c,v 1.99 2021/03/30 15:18:19 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -155,7 +155,7 @@ const char *msgs[] = {
|
|||
"suffixes F and L are illegal in traditional C", /* 98 */
|
||||
"'%s' undefined", /* 99 */
|
||||
"unary + is illegal in traditional C", /* 100 */
|
||||
"undefined struct/union member: %s", /* 101 */
|
||||
"type '%s' does not have member '%s'", /* 101 */
|
||||
"illegal member use: %s", /* 102 */
|
||||
"left operand of '.' must be struct/union object", /* 103 */
|
||||
"left operand of '->' must be pointer to struct/union not %s",/* 104 */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: init.c,v 1.181 2021/03/30 15:10:46 rillig Exp $ */
|
||||
/* $NetBSD: init.c,v 1.182 2021/03/30 15:18:19 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: init.c,v 1.181 2021/03/30 15:10:46 rillig Exp $");
|
||||
__RCSID("$NetBSD: init.c,v 1.182 2021/03/30 15:18:19 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -306,9 +306,8 @@ look_up_member_type(const type_t *tp, const char *name)
|
|||
|
||||
member = look_up_member(tp, name);
|
||||
if (member == NULL) {
|
||||
/* TODO: add type information */
|
||||
/* undefined struct/union member: %s */
|
||||
error(101, name);
|
||||
/* type '%s' does not have member '%s' */
|
||||
error(101, type_name(tp), name);
|
||||
}
|
||||
|
||||
return sym_type(member);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tree.c,v 1.253 2021/03/28 13:09:43 rillig Exp $ */
|
||||
/* $NetBSD: tree.c,v 1.254 2021/03/30 15:18:19 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.253 2021/03/28 13:09:43 rillig Exp $");
|
||||
__RCSID("$NetBSD: tree.c,v 1.254 2021/03/30 15:18:19 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <float.h>
|
||||
|
@ -347,8 +347,8 @@ struct_or_union_member(tnode_t *tn, op_t op, sym_t *msym)
|
|||
* that no defined struct or union has a member with the same name.
|
||||
*/
|
||||
if (msym->s_scl == NOSCL) {
|
||||
/* undefined struct/union member: %s */
|
||||
error(101, msym->s_name);
|
||||
/* type '%s' does not have member '%s' */
|
||||
error(101, type_name(msym->s_type), msym->s_name);
|
||||
rmsym(msym);
|
||||
msym->s_kind = FMEMBER;
|
||||
msym->s_scl = MOS;
|
||||
|
|
Loading…
Reference in New Issue