[hackers] [scc] Give all the possible errors in field() || Roberto E. Vargas Caballero
commit 8f5f61842eec2f1553ddbc90bf454600168f0718
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Jan 18 14:43:26 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Jan 18 14:43:26 2016 +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
diff --git a/cc1/decl.c b/cc1/decl.c
index e2fbae7..2844540 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -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);
Received on Mon Jan 18 2016 - 17:51:56 CET
This archive was generated by hypermail 2.3.0
: Mon Jan 18 2016 - 18:00:42 CET