commit 4a268a57f3be8c3af8c85d03ab13cdb17d0979c6
parent 8d908c4c320555aaef7fccc0e5c9399940dfe842
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 11 May 2016 12:23:32 +0200
Merge remote-tracking branch 'origin/master'
Diffstat:
15 files changed, 16 insertions(+), 32 deletions(-)
diff --git a/cc1/code.c b/cc1/code.c
@@ -9,9 +9,7 @@
#include "cc1.h"
static void emitbin(unsigned, void *),
- emitswitcht(unsigned, void *),
emitcast(unsigned, void *),
- emitswitch(unsigned, void *),
emitsym(unsigned, void *),
emitexp(unsigned, void *),
emitsymid(unsigned, void *),
@@ -61,7 +59,7 @@ char *optxt[] = {
[OLABEL] = "L%d\n",
[ODEFAULT] = "\tf\tL%d\n",
[OBSWITCH] = "\ts",
- [OESWITCH] = "\tk\n",
+ [OESWITCH] = "\tk\tL%d\n",
[OCASE] = "\tv\tL%d",
[OJUMP] = "\tj\tL%d\n",
[OBRANCH] = "\ty\tL%d",
@@ -129,7 +127,7 @@ void (*opcode[])(unsigned, void *) = {
[ORET] = emittext,
[ODECL] = emitdcl,
[OBSWITCH] = emittext,
- [OESWITCH] = emittext,
+ [OESWITCH] = emitsymid,
[OPAR] = emitbin,
[OCALL] = emitbin,
[OINIT] = emitinit
@@ -188,11 +186,9 @@ emitvar(Symbol *sym)
static void
emitconst(Node *np)
{
- char *bp, c;
Symbol *sym = np->sym;
Type *tp = np->type;
TUINT u;
- size_t n;
switch (tp->op) {
case PTR:
@@ -241,7 +237,6 @@ static void
emittype(Type *tp)
{
TINT n;
- Type **vp;
Symbol **sp;
char *tag;
@@ -291,7 +286,7 @@ emitstring(Symbol *sym, Type *tp)
char *bp, *s, *lim;
int n;
- bp = bp = sym->u.s;
+ bp = sym->u.s;
lim = &sym->u.s[tp->n.elem];
while (bp < lim) {
s = bp;
diff --git a/cc1/decl.c b/cc1/decl.c
@@ -283,7 +283,6 @@ fundcl(struct declarators *dp)
Symbol *syms[NR_FUNPARAM+1], **pars;
int k_r, ntypes, nsyms;
size_t size;
- void (*fp)(Type **, Symbol **, int *, int *);
pushctx();
expect('(');
@@ -367,7 +366,7 @@ static Type *
specifier(int *sclass, int *qualifier)
{
Type *tp = NULL;
- int spec, qlf, sign, type, cls, size, mask;
+ int spec, qlf, sign, type, cls, size;
spec = qlf = sign = type = cls = size = 0;
diff --git a/cc1/expr.c b/cc1/expr.c
@@ -56,7 +56,6 @@ promote(Node *np)
{
Type *tp;
Node *new;
- unsigned r;
struct limits *lim, *ilim;
tp = np->type;
@@ -85,7 +84,7 @@ promote(Node *np)
static void
arithconv(Node **p1, Node **p2)
{
- int n, to = 0, s1, s2;
+ int to = 0, s1, s2;
unsigned r1, r2;
Type *tp1, *tp2;
Node *np1, *np2;
diff --git a/cc1/fold.c b/cc1/fold.c
@@ -383,7 +383,7 @@ commutative(int *op, Node **lp, Node **rp)
static Node *
identity(int *op, Node *lp, Node *rp)
{
- int iszeror, isoner, istruer, val;
+ int iszeror, isoner, istruer;
int iszerol, isonel, istruel;
if (!rp)
diff --git a/cc1/init.c b/cc1/init.c
@@ -51,7 +51,6 @@ arydesig(Init *ip)
static TINT
fielddesig(Init *ip)
{
- TINT npos;
int ons;
Symbol *sym, **p;
Type *tp = ip->type;
@@ -79,7 +78,6 @@ fielddesig(Init *ip)
static Init *
designation(Init *ip)
{
- struct designator *dp;
TINT (*fun)(Init *);
switch (yytoken) {
diff --git a/cc1/stmt.c b/cc1/stmt.c
@@ -223,7 +223,7 @@ Swtch(Symbol *obr, Symbol *lcont, Switch *osw)
emit(OBSWITCH, NULL);
emit(OEXPR, cond);
stmt(lbreak, lcont, &sw);
- emit(OESWITCH, NULL);
+ emit(OESWITCH, lbreak);
emit(OLABEL, lbreak);
}
diff --git a/cc1/symbol.c b/cc1/symbol.c
@@ -102,8 +102,6 @@ void
popctx(void)
{
Symbol *next, *sym;
- char *name;
- short f;
if (--curctx == GLOBALCTX) {
for (sym = labels; sym; sym = next) {
diff --git a/cc1/tests/test012.c b/cc1/tests/test012.c
@@ -12,7 +12,7 @@ A3 I "x
s A3
v L5 #I0
L5
- k
+ k L4
L4
s A3
v L7 #I0
@@ -24,9 +24,9 @@ L9
f L11
L11
h #I1
- k
+ k L8
L8
- k
+ k L6
L6
h #I2
L10
@@ -34,7 +34,7 @@ L10
v L13 #I1
L13
h #I3
- k
+ k L12
L12
s A3
A3 #I2 :I
@@ -42,7 +42,7 @@ L15
v L16 #I1
L16
h #I4
- k
+ k L14
L14
s A3
v L18 #I0
@@ -54,7 +54,7 @@ L19
f L20
L20
h #I1
- k
+ k L17
L17
}
*/
diff --git a/cc1/tests/test036.c b/cc1/tests/test036.c
@@ -43,7 +43,7 @@ L18
y L10 R7 #I1 :-I #I0 >I
b
L11
- k
+ k L8
L8
}
*/
diff --git a/cc2/arch/amd64-sysv/code.c b/cc2/arch/amd64-sysv/code.c
@@ -34,7 +34,6 @@ static char *
symname(Symbol *sym)
{
static char name[IDENTSIZ+1];
- static unsigned short id;
if (sym->name) {
switch (sym->kind) {
diff --git a/cc2/arch/i386-sysv/code.c b/cc2/arch/i386-sysv/code.c
@@ -34,7 +34,6 @@ static char *
symname(Symbol *sym)
{
static char name[IDENTSIZ+1];
- static unsigned short id;
if (sym->name) {
switch (sym->kind) {
diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
@@ -157,7 +157,6 @@ sigil(Symbol *sym)
static char *
symname(Symbol *sym)
{
- static unsigned id;
char c = sigil(sym);
if (sym->name) {
diff --git a/cc2/arch/z80/code.c b/cc2/arch/z80/code.c
@@ -35,7 +35,6 @@ static char *
symname(Symbol *sym)
{
static char name[IDENTSIZ+1];
- static unsigned short id;
if (sym->name) {
switch (sym->kind) {
diff --git a/cc2/node.c b/cc2/node.c
@@ -20,7 +20,6 @@ struct arena {
static struct arena *arena;
static Node *freep;
-static int inhome;
Node *
newnode(int op)
diff --git a/cc2/parser.c b/cc2/parser.c
@@ -32,8 +32,8 @@ union tokenop {
typedef void parsefun(char *, union tokenop);
static parsefun type, symbol, getname, unary, binary, ternary, call,
- parameter, constant, composed, binit, einit,
- jump, oreturn, loop, assign, ocase, casetbl;
+ constant, composed, binit, einit,
+ jump, oreturn, loop, assign, casetbl;
typedef void evalfun(void);
static evalfun vardecl, beginfun, endfun, endpars, stmt,