shithub: scc

Download patch

ref: 8f5f61842eec2f1553ddbc90bf454600168f0718
parent: 6e980d9048da9c1aaaafa68ee7835ad83423a07a
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Jan 18 09:43:26 EST 2016

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

--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -614,15 +614,24 @@
 	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);