shithub: scc

Download patch

ref: d6c6483728fa4ad0577f51fd26d7ef29ea91e7b3
parent: fdbaed739f4eb78f65514764b87fb87834b76ed3
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Mar 18 04:07:13 EDT 2014

Unify errors in fielddcl

--- a/decl.c
+++ b/decl.c
@@ -312,17 +312,17 @@
 {
 	struct ctype *tp;
 	struct symbol *sym;
+	char *err;
 
 	switch (yytoken) {
 	case SCLASS:
-		error("storage class '%s' in struct/union field", yytext);
+		goto bad_storage;
 	case IDEN: case TYPE: case TQUALIFIER:
 		tp = specifier(NULL);
-		break;
 	case ';':
 		break;
 	default:
-		error("declaration expected");
+		goto dcl_expected;
 	}
 
 	if (yytoken != ';') {
@@ -333,6 +333,14 @@
 	}
 
 	expect(';');
+	return;
+
+bad_storage:
+	err = "storage class '%s' in struct/union field";
+	goto error;
+dcl_expected:
+	err = "declaration expected";
+error:	error(err, yytext);
 }
 
 static struct ctype *
--