aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2024-04-13 21:21:18 -0700
committerMichael Forney <mforney@mforney.org>2024-04-13 22:01:10 -0700
commitfc05a07d20b7c5baf312faaab46247d9057233b1 (patch)
treee408eec31b031754699aca3a4f04b867a9eaf3ec
parentc19a0bd9b78be94b455af55ad8ceb9be49410974 (diff)
decl: Include offending struct member in error messages
-rw-r--r--decl.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/decl.c b/decl.c
index 655e4b9..1fc57af 100644
--- a/decl.c
+++ b/decl.c
@@ -777,16 +777,16 @@ addmember(struct structbuilder *b, struct qualtype mt, char *name, int align, un
size_t end;
if (t->flexible)
- error(&tok.loc, "struct has member after flexible array member");
+ error(&tok.loc, "struct has member '%s' after flexible array member", name);
if (mt.type->incomplete) {
if (mt.type->kind != TYPEARRAY)
- error(&tok.loc, "struct member has incomplete type");
+ error(&tok.loc, "struct member '%s' has incomplete type", name);
t->flexible = true;
}
if (mt.type->kind == TYPEFUNC)
- error(&tok.loc, "struct member has function type");
+ error(&tok.loc, "struct member '%s' has function type", name);
if (mt.type->flexible)
- error(&tok.loc, "struct member contains flexible array member");
+ error(&tok.loc, "struct member '%s' contains flexible array member", name);
assert(mt.type->align > 0);
if (name || width == -1) {
m = xmalloc(sizeof(*m));
@@ -804,7 +804,7 @@ addmember(struct structbuilder *b, struct qualtype mt, char *name, int align, un
m->bits.after = 0;
if (align < mt.type->align) {
if (align)
- error(&tok.loc, "specified alignment of struct member is less strict than is required by type");
+ error(&tok.loc, "specified alignment of struct member '%s' is less strict than is required by type", name);
align = b->pack ? 1 : mt.type->align;
}
if (t->kind == TYPESTRUCT) {
@@ -818,15 +818,15 @@ addmember(struct structbuilder *b, struct qualtype mt, char *name, int align, un
b->bits = 0;
} else { /* bit-field */
if (!(mt.type->prop & PROPINT))
- error(&tok.loc, "bit-field has invalid type");
+ error(&tok.loc, "bit-field '%s' has invalid type", name);
if (align)
- error(&tok.loc, "alignment specified for bit-field");
+ error(&tok.loc, "alignment specified for bit-field '%s'", name);
if (b->pack)
- error(&tok.loc, "bit-field in packed struct is not supported");
+ error(&tok.loc, "bit-field '%s' in packed struct is not supported", name);
if (!width && name)
- error(&tok.loc, "bit-field with zero width must not have declarator");
+ error(&tok.loc, "bit-field '%s' with zero width must not have declarator", name);
if (width > mt.type->size * 8)
- error(&tok.loc, "bit-field exceeds width of underlying type");
+ error(&tok.loc, "bit-field '%s' exceeds width of underlying type", name);
align = mt.type->align;
if (t->kind == TYPESTRUCT) {
/* calculate end of the storage-unit for this bit-field */