scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit cbf56869f601cec10f2e34496016b628352b5388
parent 5800a17b4c0575160843305eb85a9a53aa4386b1
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 14 Feb 2015 09:03:19 +0100

Remove register declarations

The usage of register must be done at the end. At this moment in some
moments is good show the code to other persons, and some time people
blame what the fuck are you doing using this old feature.

Diffstat:
cc1/code.c | 2+-
cc1/decl.c | 12++++++------
cc1/expr.c | 48++++++++++++++++++++++++------------------------
cc1/lex.c | 36++++++++++++++++++------------------
cc1/symbol.c | 14+++++++-------
cc1/types.c | 2+-
lib/xcalloc.c | 2+-
lib/xmalloc.c | 2+-
lib/xrealloc.c | 4++--
lib/xstrdup.c | 4++--
10 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/cc1/code.c b/cc1/code.c @@ -104,7 +104,7 @@ emitvar(Symbol *sym) static void emitconst(Node *np) { - register char *bp, c; + char *bp, c; Symbol *sym = np->u.sym; if (np->type == inttype) { diff --git a/cc1/decl.c b/cc1/decl.c @@ -106,7 +106,7 @@ static struct dcldata *declarator0(struct dcldata *dp, uint8_t ns); static struct dcldata * directdcl(struct dcldata *dp, uint8_t ns) { - register Symbol *sym; + Symbol *sym; if (accept('(')) { dp = declarator0(dp, ns); @@ -131,7 +131,7 @@ directdcl(struct dcldata *dp, uint8_t ns) static struct dcldata* declarator0(struct dcldata *dp, uint8_t ns) { - register uint8_t n; + uint8_t n; for (n = 0; accept('*'); ++n) { while (accept(TQUALIFIER)) @@ -150,7 +150,7 @@ static Symbol * declarator(Type *tp, int8_t flags, uint8_t ns) { struct dcldata data[NR_DECLARATORS+2]; - register struct dcldata *bp; + struct dcldata *bp; Symbol *sym; memset(data, 0, sizeof(data)); @@ -186,7 +186,7 @@ specifier(int8_t *sclass) qlf = sign = type = cls = size = 0; for (;;) { - register int8_t *p; + int8_t *p; Type *(*dcl)(void) = NULL; switch (yytoken) { @@ -270,7 +270,7 @@ initializer(Symbol *sym) static Symbol * newtag(uint8_t tag) { - register Symbol *sym; + Symbol *sym; static uint8_t ns = NS_STRUCTS; switch (yytoken) { @@ -363,7 +363,7 @@ structdcl(void) static Type * enumdcl(void) { - register Type *tp; + Type *tp; Symbol *sym; int val = 0; diff --git a/cc1/expr.c b/cc1/expr.c @@ -465,7 +465,7 @@ arguments(Node *np) static Node * postfix(void) { - register Node *np1, *np2; + Node *np1, *np2; np1 = primary(); for (;;) { @@ -511,7 +511,7 @@ typeof(Node *np) static Type * sizeexp(void) { - register Type *tp; + Type *tp; expect('('); switch (yytoken) { @@ -531,8 +531,8 @@ static Node *cast(void); static Node * unary(void) { - register Node *(*fun)(char, Node *); - register char op; + Node *(*fun)(char, Node *); + char op; Type *tp; switch (yytoken) { @@ -560,8 +560,8 @@ unary(void) static Node * cast(void) { - register Node *np1, *np2; - register Type *tp; + Node *np1, *np2; + Type *tp; if (!accept('(')) return unary(); @@ -594,8 +594,8 @@ cast(void) static Node * mul(void) { - register Node *np, *(*fun)(char, Node *, Node *); - register char op; + Node *np, *(*fun)(char, Node *, Node *); + char op; np = cast(); for (;;) { @@ -613,8 +613,8 @@ mul(void) static Node * add(void) { - register char op; - register Node *np; + char op; + Node *np; np = mul(); for (;;) { @@ -631,8 +631,8 @@ add(void) static Node * shift(void) { - register char op; - register Node *np; + char op; + Node *np; np = add(); for (;;) { @@ -649,8 +649,8 @@ shift(void) static Node * relational(void) { - register char op; - register Node *np; + char op; + Node *np; np = shift(); for (;;) { @@ -669,8 +669,8 @@ relational(void) static Node * eq(void) { - register char op; - register Node *np; + char op; + Node *np; np = relational(); for (;;) { @@ -687,7 +687,7 @@ eq(void) static Node * bit_and(void) { - register Node *np; + Node *np; np = eq(); while (accept('&')) @@ -698,7 +698,7 @@ bit_and(void) static Node * bit_xor(void) { - register Node *np; + Node *np; np = bit_and(); while (accept('^')) @@ -709,7 +709,7 @@ bit_xor(void) static Node * bit_or(void) { - register Node *np; + Node *np; np = bit_xor(); while (accept('|')) @@ -720,7 +720,7 @@ bit_or(void) static Node * and(void) { - register Node *np; + Node *np; np = bit_or(); while (accept(AND)) @@ -731,7 +731,7 @@ and(void) static Node * or(void) { - register Node *np; + Node *np; np = and(); while (accept(OR)) @@ -758,8 +758,8 @@ ternary(void) static Node * assign(void) { - register Node *np, *(*fun)(char , Node *, Node *); - register char op; + Node *np, *(*fun)(char , Node *, Node *); + char op; np = ternary(); for (;;) { @@ -786,7 +786,7 @@ assign(void) Node * expr(void) { - register Node *np1, *np2; + Node *np1, *np2; np1 = assign(); while (accept(',')) { diff --git a/cc1/lex.c b/cc1/lex.c @@ -58,7 +58,7 @@ type: static uint8_t number(void) { - register char ch, *bp; + char ch, *bp; static char base; if ((ch = getc(yyin)) == '0') { @@ -137,7 +137,7 @@ static uint8_t character(void) { static char c; - register Symbol *sym; + Symbol *sym; getc(yyin); /* discard the initial ' */ c = getc(yyin); @@ -156,8 +156,8 @@ static uint8_t string(void) { static char buf[STRINGSIZ+1]; - register char *bp; - register int c; + char *bp; + int c; static Symbol *sym; getc(yyin); /* discard the initial " */ @@ -190,9 +190,9 @@ end_string: static uint8_t iden(void) { - register char *bp; - register int c; - register Symbol *sym; + char *bp; + int c; + Symbol *sym; for (bp = yytext; bp < &yytext[IDENTSIZ]; *bp++ = c) { if (!isalnum(c = getc(yyin)) && c != '_') @@ -213,7 +213,7 @@ iden(void) static uint8_t follow(int expect, int ifyes, int ifno) { - register int c = getc(yyin); + int c = getc(yyin); if (c == expect) { yytext[1] = c; @@ -227,7 +227,7 @@ follow(int expect, int ifyes, int ifno) static uint8_t minus(void) { - register int c = getc(yyin); + int c = getc(yyin); yytext[1] = c; yytext[2] = '\0'; @@ -245,7 +245,7 @@ minus(void) static uint8_t plus(void) { - register int c = getc(yyin); + int c = getc(yyin); yytext[1] = c; yytext[2] = '\0'; @@ -262,7 +262,7 @@ plus(void) static uint8_t relational(uint8_t op, uint8_t equal, uint8_t shift, uint8_t assig) { - register int c = getc(yyin); + int c = getc(yyin); yytext[1] = c; yytext[2] = '\0'; @@ -279,7 +279,7 @@ relational(uint8_t op, uint8_t equal, uint8_t shift, uint8_t assig) static uint8_t logic(uint8_t op, uint8_t equal, uint8_t logic) { - register int c = getc(yyin); + int c = getc(yyin); yytext[1] = c; yytext[2] = '\0'; @@ -313,7 +313,7 @@ dot(void) static uint8_t operator(void) { - register uint8_t c = getc(yyin); + uint8_t c = getc(yyin); yytext[0] = c; yytext[1] = '\0'; @@ -338,7 +338,7 @@ static int skipspaces(void) { - register int c; + int c; while (isspace(c = getc(yyin))) { if (c == '\n') @@ -350,7 +350,7 @@ skipspaces(void) uint8_t next(void) { - register int c; + int c; ungetc(c = skipspaces(), yyin); @@ -372,7 +372,7 @@ next(void) } void -expect(register uint8_t tok) +expect(uint8_t tok) { if (yytoken != tok) unexpected(); @@ -382,7 +382,7 @@ expect(register uint8_t tok) uint8_t ahead(void) { - register int c; + int c; ungetc(c = skipspaces(), yyin); @@ -390,7 +390,7 @@ ahead(void) } void -open_file(register const char *file) +open_file(const char *file) { if (yyin != NULL) fclose(yyin); diff --git a/cc1/symbol.c b/cc1/symbol.c @@ -19,9 +19,9 @@ static struct symtab { } symtab [NR_NAMESPACES]; static inline uint8_t -hash(register const char *s) +hash(const char *s) { - register uint8_t h, ch; + uint8_t h, ch; for (h = 0; ch = *s++; h += ch) /* nothing */; @@ -32,7 +32,7 @@ static void freesyms(uint8_t ns) { static struct symtab *tbl; - register Symbol *sym, *next; + Symbol *sym, *next; tbl = &symtab[ns]; for (sym = tbl->head; sym; sym = next) { @@ -69,10 +69,10 @@ popctx(void) } Symbol * -lookup(register char *s, uint8_t ns) +lookup(char *s, uint8_t ns) { struct symtab *tbl; - register Symbol *sym; + Symbol *sym; tbl = &symtab[(ns > NS_STRUCTS) ? NS_STRUCTS : ns]; for (sym = tbl->htab[hash(s)]; sym; sym = sym->hash) { @@ -86,7 +86,7 @@ lookup(register char *s, uint8_t ns) Symbol * install(char *s, uint8_t ns) { - register Symbol *sym, **t; + Symbol *sym, **t; struct symtab *tbl; sym = xcalloc(1, sizeof(*sym)); @@ -148,7 +148,7 @@ init_keywords(void) {"while", WHILE, WHILE}, {NULL, 0, 0}, }; - register Symbol *sym; + Symbol *sym; for (bp = buff; bp->str; ++bp) { sym = install(bp->str, NS_IDEN); diff --git a/cc1/types.c b/cc1/types.c @@ -190,7 +190,7 @@ mktype(Type *tp, uint8_t op, short nelem, void *data) { static Type *typetab[NR_TYPE_HASH], **tbl, type; static uint8_t t; - register Type *bp; + Type *bp; static char letters[] = { [PTR] = L_POINTER, [ARY] = L_ARRAY, [FTN] = L_FUNCTION, [ENUM] = L_INT, diff --git a/lib/xcalloc.c b/lib/xcalloc.c @@ -5,7 +5,7 @@ void * xcalloc(size_t n, size_t size) { - register void *p = calloc(n, size); + void *p = calloc(n, size); if (!p) die("out of memory"); diff --git a/lib/xmalloc.c b/lib/xmalloc.c @@ -5,7 +5,7 @@ void * xmalloc(size_t size) { - register void *p = malloc(size); + void *p = malloc(size); if (!p) die("out of memory"); diff --git a/lib/xrealloc.c b/lib/xrealloc.c @@ -3,9 +3,9 @@ #include "../inc/cc.h" void * -xrealloc(void *buff, register size_t size) +xrealloc(void *buff, size_t size) { - register void *p = realloc(buff, size); + void *p = realloc(buff, size); if (!p) die("out of memory"); diff --git a/lib/xstrdup.c b/lib/xstrdup.c @@ -5,8 +5,8 @@ char * xstrdup(const char *s) { - register size_t len = strlen(s) + 1; - register char *p = xmalloc(len); + size_t len = strlen(s) + 1; + char *p = xmalloc(len); return memcpy(p, s, len); }