commit 8f5f61842eec2f1553ddbc90bf454600168f0718
parent 6e980d9048da9c1aaaafa68ee7835ad83423a07a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Mon, 18 Jan 2016 14:43:26 +0100
Give all the possible errors in field()
In this case is better to keep testiing and return if some of the
test failed. The empty() case returns directly because we don't have
the name of the field, which is required in other place, and the
simplest thing here is to return
Diffstat:
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/cc1/decl.c b/cc1/decl.c
@@ -614,15 +614,24 @@ field(struct decl *dcl)
char *name = sym->name;
Type *structp = dcl->parent, *tp = dcl->type;
TINT n = structp->n.elem;
+ int err = 0;
if (empty(sym, tp))
return sym;
- if (dcl->sclass)
- error("storage class in struct/union field");
- if (tp->op == FTN)
- error("invalid type in struct/union");
- if (!tp->defined)
+ if (tp->op == FTN) {
+ errorp("invalid type in struct/union");
+ err = 1;
+ }
+ if (dcl->sclass) {
+ errorp("storage class in struct/union field");
+ err = 1;
+ }
+ if (!tp->defined) {
error("field '%s' has incomplete type", name);
+ err = 1;
+ }
+ if (err)
+ return sym;
if ((sym = install(dcl->ns, sym)) == NULL)
error("duplicated member '%s'", name);