ref: da85f84a98f023ad5abea1f52fe3ea1d1475a16b
parent: 6394e7a9cdf65e35718af27855726192c3af5eaa
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Sep 12 04:51:14 EDT 2017
[cc1] Remove use of unsigned in tokens and ops This was a fossil from other age in the scc development. These unsigned didn't make any sense, and they should be int.
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -383,7 +383,7 @@
/* types.c */
extern int eqtype(Type *tp1, Type *tp2, int eqflag);
-extern Type *ctype(unsigned type, unsigned sign, unsigned size);
+extern Type *ctype(int type, int sign, int size);
extern Type *mktype(Type *tp, int op, TINT nelem, Type *data[]);
extern Type *duptype(Type *base);
extern struct limits *getlimits(Type *tp);
@@ -413,8 +413,8 @@
/* lex.c */
extern int ahead(void);
-extern unsigned next(void);
-extern void expect(unsigned tok);
+extern int next(void);
+extern void expect(int tok);
extern void discard(void);
extern int addinput(char *fname, Symbol *hide, char *buffer);
extern void delinput(void);
@@ -425,8 +425,8 @@
/* code.c */
extern void prtree(Node *np);
-extern void emit(unsigned, void *);
-extern Node *node(unsigned op, Type *tp, Node *left, Node *rigth);
+extern void emit(int, void *);
+extern Node *node(int op, Type *tp, Node *left, Node *rigth);
extern Node *varnode(Symbol *sym);
extern Node *constnode(Symbol *sym);
extern Node *sizeofnode(Type *tp);
@@ -472,7 +472,7 @@
*/
extern struct yystype yylval;
extern char yytext[];
-extern unsigned yytoken;
+extern int yytoken;
extern unsigned short yylen;
extern int disexpand;
extern unsigned cppctx;
--- a/cc1/code.c
+++ b/cc1/code.c
@@ -7,17 +7,17 @@
#include "../inc/scc.h"
#include "cc1.h"
-static void emitbin(unsigned, void *),
- emitcast(unsigned, void *),
- emitsym(unsigned, void *),
- emitexp(unsigned, void *),
- emitsymid(unsigned, void *),
- emittext(unsigned, void *),
- emitfun(unsigned, void *),
- emitdcl(unsigned, void *),
- emitinit(unsigned, void *),
- emittype(unsigned, void *),
- emitbuilt(unsigned, void *);
+static void emitbin(int, void *),
+ emitcast(int, void *),
+ emitsym(int, void *),
+ emitexp(int, void *),
+ emitsymid(int, void *),
+ emittext(int, void *),
+ emitfun(int, void *),
+ emitdcl(int, void *),
+ emitinit(int, void *),
+ emittype(int, void *),
+ emitbuilt(int, void *);
char *optxt[] = {
[OADD] = "+",
@@ -75,7 +75,7 @@
[OFIELD] = "."
};
-void (*opcode[])(unsigned, void *) = {
+void (*opcode[])(int, void *) = {
[OADD] = emitbin,
[OSUB] = emitbin,
[OMUL] = emitbin,
@@ -176,7 +176,7 @@
}
void
-emit(unsigned op, void *arg)
+emit(int op, void *arg)
{
extern int failure;
@@ -231,7 +231,7 @@
}
static void
-emitsym(unsigned op, void *arg)
+emitsym(int op, void *arg)
{
Node *np = arg;
@@ -263,7 +263,7 @@
}
static void
-emittype(unsigned op, void *arg)
+emittype(int op, void *arg)
{
TINT n;
Symbol **sp;
@@ -390,7 +390,7 @@
}
static void
-emitinit(unsigned op, void *arg)
+emitinit(int op, void *arg)
{
Node *np = arg;
@@ -400,7 +400,7 @@
}
static void
-emitdcl(unsigned op, void *arg)
+emitdcl(int op, void *arg)
{
Symbol *sym = arg;
@@ -422,7 +422,7 @@
}
static void
-emitcast(unsigned op, void *arg)
+emitcast(int op, void *arg)
{
Node *np = arg, *lp = np->left;
@@ -432,7 +432,7 @@
}
static void
-emitbin(unsigned op, void *arg)
+emitbin(int op, void *arg)
{
Node *np = arg;
char *s;
@@ -446,7 +446,7 @@
}
static void
-emitbuilt(unsigned op, void *arg)
+emitbuilt(int op, void *arg)
{
Node *np = arg;
@@ -458,7 +458,7 @@
static void
-emitexp(unsigned op, void *arg)
+emitexp(int op, void *arg)
{
Node *np = arg;
@@ -468,7 +468,7 @@
}
static void
-emitfun(unsigned op, void *arg)
+emitfun(int op, void *arg)
{
Symbol *sym = arg, **sp;
@@ -481,13 +481,13 @@
}
static void
-emittext(unsigned op, void *arg)
+emittext(int op, void *arg)
{
fputs(optxt[op], outfp);
}
static void
-emitsymid(unsigned op, void *arg)
+emitsymid(int op, void *arg)
{
Symbol *sym = arg;
fprintf(outfp, optxt[op], sym->id);
@@ -494,7 +494,7 @@
}
Node *
-node(unsigned op, Type *tp, Node *lp, Node *rp)
+node(int op, Type *tp, Node *lp, Node *rp)
{
Node *np;
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -12,7 +12,7 @@
#include "../inc/scc.h"
#include "cc1.h"
-unsigned yytoken;
+int yytoken;
struct yystype yylval;
char yytext[STRINGSIZ+3];
unsigned short yylen;
@@ -376,7 +376,7 @@
return sym;
}
-static unsigned
+static int
integer(char *s, int base)
{
Type *tp;
@@ -412,7 +412,7 @@
}
static char *
-digits(unsigned base)
+digits(int base)
{
char *p;
int c;
@@ -439,7 +439,7 @@
return yytext;
}
-static unsigned
+static int
number(void)
{
int base;
@@ -504,7 +504,7 @@
return c;
}
-static unsigned
+static int
character(void)
{
int c;
@@ -528,7 +528,7 @@
return CONSTANT;
}
-static unsigned
+static int
string(void)
{
char *bp = yytext;
@@ -559,7 +559,7 @@
return STRING;
}
-static unsigned
+static int
iden(void)
{
Symbol *sym;
@@ -583,7 +583,7 @@
return sym->token;
}
-static unsigned
+static int
follow(int expect, int ifyes, int ifno)
{
if (*input->p++ == expect)
@@ -592,7 +592,7 @@
return ifno;
}
-static unsigned
+static int
minus(void)
{
switch (*input->p++) {
@@ -603,7 +603,7 @@
}
}
-static unsigned
+static int
plus(void)
{
switch (*input->p++) {
@@ -613,7 +613,7 @@
}
}
-static unsigned
+static int
relational(int op, int equal, int shift, int assig)
{
int c;
@@ -626,7 +626,7 @@
return op;
}
-static unsigned
+static int
logic(int op, int equal, int logic)
{
int c;
@@ -639,7 +639,7 @@
return op;
}
-static unsigned
+static int
dot(void)
{
int c;
@@ -652,10 +652,10 @@
return ELLIPSIS;
}
-static unsigned
+static int
operator(void)
{
- unsigned t;
+ int t;
switch (t = *input->p++) {
case '<': t = relational('<', LE, SHL, SHL_EQ); break;
@@ -714,7 +714,7 @@
return c;
}
-unsigned
+int
next(void)
{
int c;
@@ -743,7 +743,7 @@
}
void
-expect(unsigned tok)
+expect(int tok)
{
if (yytoken != tok) {
if (isgraph(tok))
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -106,7 +106,7 @@
}
Type *
-ctype(unsigned type, unsigned sign, unsigned size)
+ctype(int type, int sign, int size)
{
switch (type) {
case CHAR: