shithub: scc

Download patch

ref: b41e00fe1e8913bd4e35ff3a913b67a9aaedb26f
parent: 50be87310cc42377a409547fbb946f2750e5e925
author: Roberto E. Vargas Caballero <[email protected]>
date: Sun Nov 16 07:44:33 EST 2014

Remove unneeded struct in symbol structure

This structure was not needed at all.

--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -58,15 +58,13 @@
 	uint8_t ctx;
 	uint8_t ns;
 	uint8_t token;
-	struct {
-		bool isglobal : 1;
-		bool isstatic : 1;
-		bool isauto : 1;
-		bool isregister : 1;
-		bool isdefined : 1;
-		bool isfield : 1;
-		bool isparameter : 1;
-	} s;
+	bool isglobal : 1;
+	bool isstatic : 1;
+	bool isauto : 1;
+	bool isregister : 1;
+	bool isdefined : 1;
+	bool isfield : 1;
+	bool isparameter : 1;
 	union {
 		int i;
 		char *s;
--- a/cc1/code.c
+++ b/cc1/code.c
@@ -84,17 +84,17 @@
 {
 	char c;
 
-	if (sym->s.isstatic && !sym->s.isglobal)
+	if (sym->isstatic && !sym->isglobal)
 		c = 'T';
-	else if (sym->s.isstatic && sym->s.isglobal)
+	else if (sym->isstatic && sym->isglobal)
 		c = 'Y';
-	else if (sym->s.isglobal)
+	else if (sym->isglobal)
 		c = 'G';
-	else if (sym->s.isregister)
+	else if (sym->isregister)
 		c = 'R';
-	else if (sym->s.isfield)
+	else if (sym->isfield)
 		c = 'M';
-	else if (sym->s.isparameter)
+	else if (sym->isparameter)
 		c = 'P';
 	else
 		c = 'A';
@@ -223,7 +223,7 @@
 emitfun(Symbol *sym)
 {
 	printf("%c%d\tF\t%s\t{\n",
-	       sym->s.isglobal ? 'G' : 'Y', sym->id, sym->name);
+	       sym->isglobal ? 'G' : 'Y', sym->id, sym->name);
 }
 
 void
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -238,7 +238,7 @@
 static struct node *
 initializer(Symbol *sym)
 {
-	if (!sym->s.isdefined)
+	if (!sym->isdefined)
 		error("'%s' initialized and declared extern", sym->name);
 
 	if (accept('{')) {
@@ -324,7 +324,7 @@
 
 		do {
 			sym = declarator(base, ID_EXPECTED, tagtype->ns);
-			sym->s.isfield = 1;
+			sym->isfield = 1;
 			tp = sym->type;
 			if (tp->op == FTN)
 				error("invalid type in struct/union");
@@ -387,7 +387,7 @@
 	if ((tp = specifier(&sclass)) == voidtype)
 		return tp;
 	sym = declarator(tp, ID_ACCEPTED, NS_IDEN);
-	sym->s.isparameter = 1;
+	sym->isparameter = 1;
 	tp = sym->type;
 	if (tp->op == FTN)
 		error("incorrect function type for a function parameter");
@@ -395,10 +395,10 @@
 		tp = mktype(tp->type, PTR, 0, NULL);
 	switch (sclass) {
 	case REGISTER:
-		sym->s.isregister = 1;
+		sym->isregister = 1;
 		break;
 	case 0:
-		sym->s.isauto = 1;
+		sym->isauto = 1;
 		break;
 	default:
 		error("bad storage class in function parameter");
@@ -426,13 +426,13 @@
 			sym->token = TYPEIDEN;
 			continue;
 		case STATIC:
-			sym->s.isstatic = 1;
+			sym->isstatic = 1;
 			break;
 		case EXTERN:
-			sym->s.isdefined = 0;
+			sym->isdefined = 0;
 			break;
 		case REGISTER:
-			sym->s.isregister = 1;
+			sym->isregister = 1;
 			if (isfun)
 				goto bad_function;
 			break;
@@ -441,7 +441,7 @@
 				goto bad_function;
 			/* passtrough */
 		default:
-			sym->s.isauto = 1;
+			sym->isauto = 1;
 			break;
 		}
 		if (accept('='))
@@ -486,17 +486,17 @@
 		do {
 			sym = declarator(base, ID_EXPECTED, NS_IDEN);
 			tp = sym->type;
-			sym->s.isstatic = 1;
-			sym->s.isglobal= 1;
+			sym->isstatic = 1;
+			sym->isglobal= 1;
 
 			switch (sclass) {
 			case REGISTER: case AUTO:
 				error("incorrect storage class for file-scope declaration");
 			case STATIC:
-				sym->s.isglobal = 0;
+				sym->isglobal = 0;
 				break;
 			case EXTERN:
-				sym->s.isdefined = 0;
+				sym->isdefined = 0;
 				break;
 			case TYPEDEF:
 				sym->token = TYPEIDEN;
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -377,7 +377,7 @@
 {
 	if (!np->b.lvalue)
 		error("lvalue required in unary expression");
-	if (np->b.symbol && np->u.sym->s.isregister)
+	if (np->b.symbol && np->u.sym->isregister)
 		error("address of register variable '%s' requested", yytext);
 	return unarycode(op, mktype(np->type, PTR, 0, NULL), np);
 }
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
@@ -31,15 +31,15 @@
 
 	if ((sym = lookup(s, NS_LABEL)) != NULL) {
 		if (define) {
-			if (sym->s.isdefined)
+			if (sym->isdefined)
 				error("label '%s' already defined", s);
-			sym->s.isdefined = 1;
+			sym->isdefined = 1;
 		}
 		return sym;
 	}
 
 	sym = install(s, NS_LABEL);
-	sym->s.isdefined = define;
+	sym->isdefined = define;
 	return sym;
 }
 
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -38,7 +38,7 @@
 	for (sym = tbl->head; sym; sym = next) {
 		if (sym->ctx <= curctx)
 			break;
-		if (ns == NS_LABEL && !sym->s.isdefined)
+		if (ns == NS_LABEL && !sym->isdefined)
 			error("label '%s' is not defined", sym->name);
 		if (ns == NS_TAG)
 			sym->type->defined = 0;
@@ -94,7 +94,7 @@
 	sym->ctx = curctx;
 	sym->token = IDEN;
 	sym->id = (curctx) ? ++localcnt : ++globalcnt;
-	sym->s.isdefined = 1;
+	sym->isdefined = 1;
 	sym->ns = ns;
 	tbl = &symtab[(ns > NS_STRUCTS) ? NS_STRUCTS : ns];
 	sym->next = tbl->head;