shithub: scc

Download patch

ref: fdbaed739f4eb78f65514764b87fb87834b76ed3
parent: 06c8e5d1ac23831304404343c9f07110540ae354
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Mar 18 03:52:16 EDT 2014

Unify errors calls in extdcl

--- a/decl.c
+++ b/decl.c
@@ -461,6 +461,7 @@
 	int8_t sclass;
 	struct symbol *sym;
 	extern struct symbol *curfun;
+	char *err;
 
 	forbid_eof = 1;
 
@@ -468,12 +469,11 @@
 	case IDEN: TYPE: case SCLASS: case TQUALIFIER:
 		tp = specifier(&sclass);
 		if (sclass == REGISTER || sclass == AUTO)
-			error("incorrect storage class for file-scope declaration");
-		break;
+			goto bad_storage;
 	case ';':
 		break;
 	default:
-		error("declaration expected");
+		goto dcl_expected;
 	}
 
 	if (yytoken != ';') {
@@ -497,4 +497,11 @@
 	forbid_eof = 0;
 	expect(';');
 	return NULL;
+
+bad_storage:
+	err = "incorrect storage class for file-scope declaration";
+	goto error;
+dcl_expected:
+	err = "declaration expected";
+error:	error(err);
 }