shithub: scc

Download patch

ref: d5570660a7452191e33dc3d8817efc6ebd6c20e9
parent: 12da403dac1d4581566efa3a72e98b04dd828395
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Jul 8 10:41:20 EDT 2014

Simplify enumdcl

This commit removes one indentation level and removes non needed
gotos.

--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -358,39 +358,31 @@
 	register Type *tp;
 	Symbol *sym;
 	int val = 0;
-	char *err;
 
 	next();
 	tp = newtag(ENUM);
-	if (yytoken != ';') {
-		expect('{');
-		if (tp->defined)
-			goto redefined;
-		tp->defined = 1;
-		while (yytoken != '}') {
-			if (yytoken != IDEN)
-				goto iden_expected;
-			sym = newiden();
-			sym->type = inttype;
-			if (accept('='))
-				initializer(inttype);
-			sym->u.i = val++;
-			newfield(tp, sym);
-			if (!accept(','))
-				break;
-		}
-		expect('}');
+	if (yytoken == ';')
+		return tp;
+
+	expect('{');
+	if (tp->defined)
+		error("redefinition of enumeration '%s'", yytext);
+	tp->defined = 1;
+	while (yytoken != '}') {
+		if (yytoken != IDEN)
+			error("identifier expected");
+		sym = newiden();
+		sym->type = inttype;
+		if (accept('='))
+			initializer(inttype);
+		sym->u.i = val++;
+		newfield(tp, sym);
+		if (!accept(','))
+			break;
 	}
+	expect('}');
 
 	return tp;
-
-redefined:
-	err = "redefinition of enumeration '%s'";
-	goto error;
-iden_expected:
-	err = "identifier expected";
-error:
-	error(err, yytext);
 }
 
 void