aboutsummaryrefslogtreecommitdiffstats
path: root/lcc/src
diff options
context:
space:
mode:
Diffstat (limited to 'lcc/src')
-rw-r--r--lcc/src/bind.c26
-rw-r--r--lcc/src/bytecode.c20
-rw-r--r--lcc/src/c.h2
-rw-r--r--lcc/src/dag.c25
-rw-r--r--lcc/src/decl.c42
-rw-r--r--lcc/src/enode.c62
-rw-r--r--lcc/src/expr.c20
-rw-r--r--lcc/src/gen.c2
-rw-r--r--lcc/src/init.c12
-rw-r--r--lcc/src/inits.c1
-rw-r--r--lcc/src/input.c3
-rw-r--r--lcc/src/lex.c7
-rw-r--r--lcc/src/null.c20
-rw-r--r--lcc/src/output.c5
-rw-r--r--lcc/src/prof.c3
-rw-r--r--lcc/src/profio.c4
-rw-r--r--lcc/src/simp.c64
-rw-r--r--lcc/src/stab.c10
-rw-r--r--lcc/src/stmt.c1
-rw-r--r--lcc/src/sym.c1
-rw-r--r--lcc/src/symbolic.c40
-rw-r--r--lcc/src/trace.c3
-rw-r--r--lcc/src/types.c8
23 files changed, 193 insertions, 188 deletions
diff --git a/lcc/src/bind.c b/lcc/src/bind.c
index 562ffda..c27036f 100644
--- a/lcc/src/bind.c
+++ b/lcc/src/bind.c
@@ -7,17 +7,17 @@ extern Interface symbolicIR, symbolic64IR;
extern Interface nullIR;
extern Interface bytecodeIR;
Binding bindings[] = {
- "alpha/osf", &alphaIR,
- "mips/irix", &mipsebIR,
- "mips/ultrix", &mipselIR,
- "sparc/sun", &sparcIR,
- "sparc/solaris", &solarisIR,
- "x86/win32", &x86IR,
- "x86/linux", &x86linuxIR,
- "symbolic/osf", &symbolic64IR,
- "symbolic/irix", &symbolicIR,
- "symbolic", &symbolicIR,
- "null", &nullIR,
- "bytecode", &bytecodeIR,
- NULL, NULL
+ /*{ "alpha/osf", &alphaIR },*/
+ /*{ "mips/irix", &mipsebIR },*/
+ /*{ "mips/ultrix", &mipselIR },*/
+ /*{ "sparc/sun", &sparcIR },*/
+ /*{ "sparc/solaris", &solarisIR },*/
+ /*{ "x86/win32", &x86IR },*/
+ /*{ "x86/linux", &x86linuxIR },*/
+ { "symbolic/osf", &symbolic64IR },
+ { "symbolic/irix", &symbolicIR },
+ { "symbolic", &symbolicIR },
+ { "null", &nullIR },
+ { "bytecode", &bytecodeIR },
+ { NULL, NULL },
};
diff --git a/lcc/src/bytecode.c b/lcc/src/bytecode.c
index 8b8a6b6..b267d6f 100644
--- a/lcc/src/bytecode.c
+++ b/lcc/src/bytecode.c
@@ -320,16 +320,16 @@ static void I(stabline)(Coordinate *cp) {
#define b_blockend blockend
Interface bytecodeIR = {
- 1, 1, 0, /* char */
- 2, 2, 0, /* short */
- 4, 4, 0, /* int */
- 4, 4, 0, /* long */
- 4, 4, 0, /* long long */
- 4, 4, 0, /* float */ // JDC: use inline floats
- 4, 4, 0, /* double */ // JDC: don't ever emit 8 byte double code
- 4, 4, 0, /* long double */ // JDC: don't ever emit 8 byte double code
- 4, 4, 0, /* T* */
- 0, 4, 0, /* struct */
+ {1, 1, 0}, /* char */
+ {2, 2, 0}, /* short */
+ {4, 4, 0}, /* int */
+ {4, 4, 0}, /* long */
+ {4, 4, 0}, /* long long */
+ {4, 4, 0}, /* float */ // JDC: use inline floats
+ {4, 4, 0}, /* double */ // JDC: don't ever emit 8 byte double code
+ {4, 4, 0}, /* long double */ // JDC: don't ever emit 8 byte double code
+ {4, 4, 0}, /* T* */
+ {0, 4, 0}, /* struct */
0, /* little_endian */
0, /* mulops_calls */
0, /* wants_callb */
diff --git a/lcc/src/c.h b/lcc/src/c.h
index a0e45b0..b46cf3b 100644
--- a/lcc/src/c.h
+++ b/lcc/src/c.h
@@ -14,7 +14,7 @@
#define BUFSIZE 4096
#define istypename(t,tsym) (kind[t] == CHAR \
- || t == ID && tsym && tsym->sclass == TYPEDEF)
+ || (t == ID && tsym && tsym->sclass == TYPEDEF))
#define sizeop(n) ((n)<<10)
#define generic(op) ((op)&0x3F0)
#define specific(op) ((op)&0x3FF)
diff --git a/lcc/src/dag.c b/lcc/src/dag.c
index 8e0ddea..420cbe7 100644
--- a/lcc/src/dag.c
+++ b/lcc/src/dag.c
@@ -2,9 +2,9 @@
#define iscall(op) (generic(op) == CALL \
- || IR->mulops_calls \
+ || (IR->mulops_calls \
&& (generic(op)==DIV||generic(op)==MOD||generic(op)==MUL) \
- && ( optype(op)==U || optype(op)==I))
+ && ( optype(op)==U || optype(op)==I)))
static Node forest;
static struct dag {
struct node node;
@@ -102,7 +102,7 @@ Node listnodes(Tree tp, int tlab, int flab) {
Node p = NULL, l, r;
int op;
- assert(tlab || flab || tlab == 0 && flab == 0);
+ assert(tlab || flab || (tlab == 0 && flab == 0));
if (tp == NULL)
return NULL;
if (tp->node)
@@ -172,8 +172,8 @@ Node listnodes(Tree tp, int tlab, int flab) {
p = node(op, NULL, NULL, constant(ty, tp->u.v)); } break;
case RIGHT: { if ( tp->kids[0] && tp->kids[1]
&& generic(tp->kids[1]->op) == ASGN
- && (generic(tp->kids[0]->op) == INDIR
- && tp->kids[0]->kids[0] == tp->kids[1]->kids[0]
+ && ((generic(tp->kids[0]->op) == INDIR
+ && tp->kids[0]->kids[0] == tp->kids[1]->kids[0])
|| (tp->kids[0]->op == FIELD
&& tp->kids[0] == tp->kids[1]->kids[0]))) {
assert(tlab == 0 && flab == 0);
@@ -276,11 +276,11 @@ Node listnodes(Tree tp, int tlab, int flab) {
unsigned int fmask = fieldmask(f);
unsigned int mask = fmask<<fieldright(f);
Tree q = tp->kids[1];
- if (q->op == CNST+I && q->u.v.i == 0
- || q->op == CNST+U && q->u.v.u == 0)
+ if ((q->op == CNST+I && q->u.v.i == 0)
+ || (q->op == CNST+U && q->u.v.u == 0))
q = bittree(BAND, x, cnsttree(unsignedtype, (unsigned long)~mask));
- else if (q->op == CNST+I && (q->u.v.i&fmask) == fmask
- || q->op == CNST+U && (q->u.v.u&fmask) == fmask)
+ else if ((q->op == CNST+I && (q->u.v.i&fmask) == fmask)
+ || (q->op == CNST+U && (q->u.v.u&fmask) == fmask))
q = bittree(BOR, x, cnsttree(unsignedtype, (unsigned long)mask));
else {
listnodes(q, 0, 0);
@@ -621,11 +621,11 @@ static Node prune(Node forest) {
return forest;
}
static Node visit(Node p, int listed) {
- if (p)
+ if (p) {
if (p->syms[2])
p = tmpnode(p);
- else if (p->count <= 1 && !iscall(p->op)
- || p->count == 0 && iscall(p->op)) {
+ else if ((p->count <= 1 && !iscall(p->op))
+ || (p->count == 0 && iscall(p->op))) {
p->kids[0] = visit(p->kids[0], 0);
p->kids[1] = visit(p->kids[1], 0);
}
@@ -654,6 +654,7 @@ static Node visit(Node p, int listed) {
if (!listed)
p = tmpnode(p);
};
+ }
return p;
}
static Node tmpnode(Node p) {
diff --git a/lcc/src/decl.c b/lcc/src/decl.c
index fc1d6bc..132241e 100644
--- a/lcc/src/decl.c
+++ b/lcc/src/decl.c
@@ -115,10 +115,10 @@ static Type specifier(int *sclass) {
type = INT;
ty = inttype;
}
- if (size == SHORT && type != INT
- || size == LONG+LONG && type != INT
- || size == LONG && type != INT && type != DOUBLE
- || sign && type != INT && type != CHAR)
+ if ((size == SHORT && type != INT)
+ || (size == LONG+LONG && type != INT)
+ || (size == LONG && type != INT && type != DOUBLE)
+ || (sign && type != INT && type != CHAR))
error("invalid type specification\n");
if (type == CHAR && sign)
ty = sign == UNSIGNED ? unsignedchar : signedchar;
@@ -196,7 +196,7 @@ static void decl(Symbol (*dcl)(int, char *, Type, Coordinate *)) {
}
} else if (ty == NULL
|| !(isenum(ty) ||
- isstruct(ty) && (*unqual(ty)->u.sym->name < '1' || *unqual(ty)->u.sym->name > '9')))
+ (isstruct(ty) && (*unqual(ty)->u.sym->name < '1' || *unqual(ty)->u.sym->name > '9'))))
error("empty declaration\n");
test(';', stop);
}
@@ -220,9 +220,9 @@ static Symbol dclglobal(int sclass, char *id, Type ty, Coordinate *pos) {
if (!isfunc(ty) && p->defined && t == '=')
error("redefinition of `%s' previously defined at %w\n", p->name, &p->src);
- if (p->sclass == EXTERN && sclass == STATIC
- || p->sclass == STATIC && sclass == AUTO
- || p->sclass == AUTO && sclass == STATIC)
+ if ((p->sclass == EXTERN && sclass == STATIC)
+ || (p->sclass == STATIC && sclass == AUTO)
+ || (p->sclass == AUTO && sclass == STATIC))
warning("inconsistent linkage for `%s' previously declared at %w\n", p->name, &p->src);
}
@@ -416,7 +416,7 @@ static Symbol *parameters(Type fty) {
error("missing parameter type\n");
n++;
ty = dclr(specifier(&sclass), &id, NULL, 1);
- if ( ty == voidtype && (ty1 || id)
+ if ( (ty == voidtype && (ty1 || id))
|| ty1 == voidtype)
error("illegal formal parameter types\n");
if (id == NULL)
@@ -736,10 +736,10 @@ static void funcdefn(int sclass, char *id, Type ty, Symbol params[], Coordinate
if (ty->u.f.oldstyle)
warning("`%t %s()' is a non-ANSI definition\n", rty, id);
else if (!(rty == inttype
- && (n == 0 && callee[0] == NULL
- || n == 2 && callee[0]->type == inttype
+ && ((n == 0 && callee[0] == NULL)
+ || (n == 2 && callee[0]->type == inttype
&& isptr(callee[1]->type) && callee[1]->type->type == charptype
- && !variadic(ty))))
+ && !variadic(ty)))))
warning("`%s' is a non-ANSI definition\n", typestring(ty, id));
}
p = lookup(id, identifiers);
@@ -853,7 +853,7 @@ void compound(int loop, struct swtch *swp, int lev) {
registers = append(retv, registers);
}
while (kind[t] == CHAR || kind[t] == STATIC
- || istypename(t, tsym) && getchr() != ':')
+ || (istypename(t, tsym) && getchr() != ':'))
decl(dcllocal);
{
int i;
@@ -908,7 +908,7 @@ static void checkref(Symbol p, void *cl) {
p->type, p->name);
}
if (p->sclass == AUTO
- && (p->scope == PARAM && regcount == 0
+ && ((p->scope == PARAM && regcount == 0)
|| p->scope >= LOCAL)
&& !p->addressed && isscalar(p->type) && p->ref >= 3.0)
p->sclass = REGISTER;
@@ -933,13 +933,14 @@ static Symbol dcllocal(int sclass, char *id, Type ty, Coordinate *pos) {
sclass = AUTO;
}
q = lookup(id, identifiers);
- if (q && q->scope >= level
- || q && q->scope == PARAM && level == LOCAL)
+ if ((q && q->scope >= level)
+ || (q && q->scope == PARAM && level == LOCAL)) {
if (sclass == EXTERN && q->sclass == EXTERN
&& eqtype(q->type, ty, 1))
ty = compose(ty, q->type);
else
error("redeclaration of `%s' previously declared at %w\n", q->name, &q->src);
+ }
assert(level >= LOCAL);
p = install(id, &identifiers, level, sclass == STATIC || sclass == EXTERN ? PERM : FUNC);
@@ -964,13 +965,14 @@ static Symbol dcllocal(int sclass, char *id, Type ty, Coordinate *pos) {
p->u.alias = q; break;
case STATIC: (*IR->defsymbol)(p);
initglobal(p, 0);
- if (!p->defined)
+ if (!p->defined) {
if (p->type->size > 0) {
defglobal(p, BSS);
(*IR->space)(p->type->size);
} else
error("undefined size for `%t %s'\n",
p->type, p->name);
+ }
p->defined = 1; break;
case REGISTER: registers = append(p, registers);
regcount++;
@@ -987,7 +989,7 @@ static Symbol dcllocal(int sclass, char *id, Type ty, Coordinate *pos) {
t = gettok();
definept(NULL);
if (isscalar(p->type)
- || isstruct(p->type) && t != '{') {
+ || (isstruct(p->type) && t != '{')) {
if (t == '{') {
t = gettok();
e = expr1(0);
@@ -1027,7 +1029,7 @@ static void doextern(Symbol p, void *cl) {
}
static void doglobal(Symbol p, void *cl) {
if (!p->defined && (p->sclass == EXTERN
- || isfunc(p->type) && p->sclass == AUTO))
+ || (isfunc(p->type) && p->sclass == AUTO)))
(*IR->import)(p);
else if (!p->defined && !isfunc(p->type)
&& (p->sclass == AUTO || p->sclass == STATIC)) {
@@ -1077,7 +1079,7 @@ void checklab(Symbol p, void *cl) {
Type enumdcl(void) {
char *tag;
Type ty;
- Symbol p;
+ Symbol p = {0};
Coordinate pos;
t = gettok();
diff --git a/lcc/src/enode.c b/lcc/src/enode.c
index 0503cc3..0f2adbd 100644
--- a/lcc/src/enode.c
+++ b/lcc/src/enode.c
@@ -64,7 +64,7 @@ Tree call(Tree f, Type fty, Coordinate src) {
else
q = cast(q, promote(q->type));
}
- if (!IR->wants_argb && isstruct(q->type))
+ if (!IR->wants_argb && isstruct(q->type)) {
if (iscallb(q))
q = addrof(q);
else {
@@ -73,6 +73,7 @@ Tree call(Tree f, Type fty, Coordinate src) {
q = tree(RIGHT, ptr(t1->type),
root(q), lvalue(idtree(t1)));
}
+ }
if (q->type->size == 0)
q->type = inttype;
if (hascall(q))
@@ -223,15 +224,15 @@ static int isnullptr(Tree e) {
Type ty = unqual(e->type);
return generic(e->op) == CNST
- && (ty->op == INT && e->u.v.i == 0
- || ty->op == UNSIGNED && e->u.v.u == 0
- || isvoidptr(ty) && e->u.v.p == NULL);
+ && ((ty->op == INT && e->u.v.i == 0)
+ || (ty->op == UNSIGNED && e->u.v.u == 0)
+ || (isvoidptr(ty) && e->u.v.p == NULL));
}
Tree eqtree(int op, Tree l, Tree r) {
Type xty = l->type, yty = r->type;
- if (isptr(xty) && isnullptr(r)
- || isptr(xty) && !isfunc(xty->type) && isvoidptr(yty)
+ if ((isptr(xty) && isnullptr(r))
+ || (isptr(xty) && !isfunc(xty->type) && isvoidptr(yty))
|| (isptr(xty) && isptr(yty)
&& eqtype(unqual(xty->type), unqual(yty->type), 1))) {
Type ty = unsignedptr;
@@ -239,8 +240,8 @@ Tree eqtree(int op, Tree l, Tree r) {
r = cast(r, ty);
return simplify(mkop(op,ty), inttype, l, r);
}
- if (isptr(yty) && isnullptr(l)
- || isptr(yty) && !isfunc(yty->type) && isvoidptr(xty))
+ if ((isptr(yty) && isnullptr(l))
+ || (isptr(yty) && !isfunc(yty->type) && isvoidptr(xty)))
return eqtree(op, r, l);
return cmptree(op, l, r);
}
@@ -253,13 +254,13 @@ Type assign(Type xty, Tree e) {
xty = xty->type;
if (xty->size == 0 || yty->size == 0)
return NULL;
- if ( isarith(xty) && isarith(yty)
- || isstruct(xty) && xty == yty)
+ if ( (isarith(xty) && isarith(yty))
+ || (isstruct(xty) && xty == yty))
return xty;
if (isptr(xty) && isnullptr(e))
return xty;
- if ((isvoidptr(xty) && isptr(yty)
- || isptr(xty) && isvoidptr(yty))
+ if (((isvoidptr(xty) && isptr(yty))
+ || (isptr(xty) && isvoidptr(yty)))
&& ( (isconst(xty->type) || !isconst(yty->type))
&& (isvolatile(xty->type) || !isvolatile(yty->type))))
return xty;
@@ -273,8 +274,8 @@ Type assign(Type xty, Tree e) {
&& ( (isconst(xty->type) || !isconst(yty->type))
&& (isvolatile(xty->type) || !isvolatile(yty->type)))) {
Type lty = unqual(xty->type), rty = unqual(yty->type);
- if (isenum(lty) && rty == inttype
- || isenum(rty) && lty == inttype) {
+ if ((isenum(lty) && rty == inttype)
+ || (isenum(rty) && lty == inttype)) {
if (Aflag >= 1)
warning("assignment between `%t' and `%t' is compiler-dependent\n",
xty, yty);
@@ -302,13 +303,14 @@ Tree asgntree(int op, Tree l, Tree r) {
if (isptr(aty))
aty = unqual(aty)->type;
if ( isconst(aty)
- || isstruct(aty) && unqual(aty)->u.sym->u.s.cfields)
+ || (isstruct(aty) && unqual(aty)->u.sym->u.s.cfields)) {
if (isaddrop(l->op)
&& !l->u.sym->computed && !l->u.sym->generated)
error("assignment to const identifier `%s'\n",
l->u.sym->name);
else
error("assignment to const location\n");
+ }
if (l->op == FIELD) {
long n = 8*l->u.field->type->size - fieldsize(l->u.field);
if (n > 0 && isunsigned(l->u.field->type))
@@ -345,8 +347,8 @@ Tree condtree(Tree e, Tree l, Tree r) {
ty = xty;
else if (isnullptr(l) && isptr(yty))
ty = yty;
- else if (isptr(xty) && !isfunc(xty->type) && isvoidptr(yty)
- || isptr(yty) && !isfunc(yty->type) && isvoidptr(xty))
+ else if ((isptr(xty) && !isfunc(xty->type) && isvoidptr(yty))
+ || (isptr(yty) && !isfunc(yty->type) && isvoidptr(xty)))
ty = voidptype;
else if ((isptr(xty) && isptr(yty)
&& eqtype(unqual(xty->type), unqual(yty->type), 1)))
@@ -357,11 +359,11 @@ Tree condtree(Tree e, Tree l, Tree r) {
}
if (isptr(ty)) {
ty = unqual(unqual(ty)->type);
- if (isptr(xty) && isconst(unqual(xty)->type)
- || isptr(yty) && isconst(unqual(yty)->type))
+ if ((isptr(xty) && isconst(unqual(xty)->type))
+ || (isptr(yty) && isconst(unqual(yty)->type)))
ty = qual(CONST, ty);
- if (isptr(xty) && isvolatile(unqual(xty)->type)
- || isptr(yty) && isvolatile(unqual(yty)->type))
+ if ((isptr(xty) && isvolatile(unqual(xty)->type))
+ || (isptr(yty) && isvolatile(unqual(yty)->type)))
ty = qual(VOLATILE, ty);
ty = ptr(ty);
}
@@ -518,15 +520,15 @@ static Tree subtree(int op, Tree l, Tree r) {
void typeerror(int op, Tree l, Tree r) {
int i;
static struct { int op; char *name; } ops[] = {
- ASGN, "=", INDIR, "*", NEG, "-",
- ADD, "+", SUB, "-", LSH, "<<",
- MOD, "%", RSH, ">>", BAND, "&",
- BCOM, "~", BOR, "|", BXOR, "^",
- DIV, "/", MUL, "*", EQ, "==",
- GE, ">=", GT, ">", LE, "<=",
- LT, "<", NE, "!=", AND, "&&",
- NOT, "!", OR, "||", COND, "?:",
- 0, 0
+ {ASGN, "="}, {INDIR, "*"}, {NEG, "-"},
+ {ADD, "+"}, {SUB, "-"}, {LSH, "<<"},
+ {MOD, "%"}, {RSH, ">>"}, {BAND, "&"},
+ {BCOM, "~"}, {BOR, "|"}, {BXOR, "^"},
+ {DIV, "/"}, {MUL, "*"}, {EQ, "=="},
+ {GE, ">="}, {GT, ">"}, {LE, "<="},
+ {LT, "<"}, {NE, "!="}, {AND, "&&"},
+ {NOT, "!"}, {OR, "||"}, {COND, "?:"},
+ {0, 0}
};
op = generic(op);
diff --git a/lcc/src/expr.c b/lcc/src/expr.c
index 79f8f40..f20a090 100644
--- a/lcc/src/expr.c
+++ b/lcc/src/expr.c
@@ -230,13 +230,13 @@ static Tree unary(void) {
pty = p->type;
if (isenum(pty))
pty = pty->type;
- if (isarith(pty) && isarith(ty)
- || isptr(pty) && isptr(ty)) {
+ if ((isarith(pty) && isarith(ty))
+ || (isptr(pty) && isptr(ty))) {
explicitCast++;
p = cast(p, ty);
explicitCast--;
- } else if (isptr(pty) && isint(ty)
- || isint(pty) && isptr(ty)) {
+ } else if ((isptr(pty) && isint(ty))
+ || (isint(pty) && isptr(ty))) {
if (Aflag >= 1 && ty->size < pty->size)
warning("conversion from `%t' to `%t' is compiler dependent\n", p->type, ty);
@@ -278,11 +278,12 @@ static Tree postfix(Tree p) {
Tree q;
t = gettok();
q = expr(']');
- if (YYnull)
+ if (YYnull) {
if (isptr(p->type))
p = nullcheck(p);
else if (isptr(q->type))
q = nullcheck(q);
+ }
p = (*optree['+'])(ADD, pointer(p), pointer(q));
if (isptr(p->type) && isarray(p->type->type))
p = retype(p, p->type->type);
@@ -497,12 +498,13 @@ Type binary(Type xty, Type yty) {
xx(unsignedlonglong);
xx(longlong);
xx(unsignedlong);
- if (xty == longtype && yty == unsignedtype
- || xty == unsignedtype && yty == longtype)
+ if ((xty == longtype && yty == unsignedtype)
+ || (xty == unsignedtype && yty == longtype)) {
if (longtype->size > unsignedtype->size)
return longtype;
else
return unsignedlong;
+ }
xx(longtype);
xx(unsignedtype);
return inttype;
@@ -618,8 +620,8 @@ Tree cast(Tree p, Type type) {
if (src->op != dst->op)
p = simplify(CVP, dst, p, NULL);
else {
- if (isfunc(src->type) && !isfunc(dst->type)
- || !isfunc(src->type) && isfunc(dst->type))
+ if ((isfunc(src->type) && !isfunc(dst->type))
+ || (!isfunc(src->type) && isfunc(dst->type)))
warning("conversion from `%t' to `%t' is compiler dependent\n", p->type, type);
if (src->size != dst->size)
diff --git a/lcc/src/gen.c b/lcc/src/gen.c
index 7202c45..4ee170d 100644
--- a/lcc/src/gen.c
+++ b/lcc/src/gen.c
@@ -368,7 +368,7 @@ static unsigned emitasm(Node p, int nt) {
void emit(Node p) {
for (; p; p = p->x.next) {
assert(p->x.registered);
- if (p->x.equatable && requate(p) || moveself(p))
+ if ((p->x.equatable && requate(p)) || moveself(p))
;
else
(*emitter)(p, p->x.inst);
diff --git a/lcc/src/init.c b/lcc/src/init.c
index 27bbc51..172d7c0 100644
--- a/lcc/src/init.c
+++ b/lcc/src/init.c
@@ -81,7 +81,7 @@ static int initarray(int len, Type ty, int lev) {
do {
initializer(ty, lev);
n += ty->size;
- if (len > 0 && n >= len || t != ',')
+ if ((len > 0 && n >= len) || t != ',')
break;
t = gettok();
} while (t != '}');
@@ -99,7 +99,7 @@ static int initchar(int len, Type ty) {
(*IR->defstring)(inttype->size, buf);
s = buf;
}
- if (len > 0 && n >= len || t != ',')
+ if ((len > 0 && n >= len) || t != ',')
break;
t = gettok();
} while (t != '}');
@@ -123,9 +123,9 @@ static int initfields(Field p, Field q) {
do {
i = initvalue(inttype)->u.v.i;
if (fieldsize(p) < 8*p->type->size) {
- if (p->type == inttype &&
- (i < -(int)(fieldmask(p)>>1)-1 || i > (int)(fieldmask(p)>>1))
- || p->type == unsignedtype && (i&~fieldmask(p)) != 0)
+ if ((p->type == inttype &&
+ (i < -(int)(fieldmask(p)>>1)-1 || i > (int)(fieldmask(p)>>1)))
+ || (p->type == unsignedtype && (i&~fieldmask(p)) != 0))
warning("initializer exceeds bit-field width\n");
i &= fieldmask(p);
}
@@ -185,7 +185,7 @@ static int initstruct(int len, Type ty, int lev) {
(*IR->space)(a - n%a);
n = roundup(n, a);
}
- if (len > 0 && n >= len || t != ',')
+ if ((len > 0 && n >= len) || t != ',')
break;
t = gettok();
} while (t != '}');
diff --git a/lcc/src/inits.c b/lcc/src/inits.c
index 449724a..c42f61e 100644
--- a/lcc/src/inits.c
+++ b/lcc/src/inits.c
@@ -4,5 +4,4 @@ void init(int argc, char *argv[]) {
{extern void prof_init(int, char *[]); prof_init(argc, argv);}
{extern void trace_init(int, char *[]); trace_init(argc, argv);}
{extern void type_init(int, char *[]); type_init(argc, argv);}
- {extern void x86linux_init(int, char *[]); x86linux_init(argc, argv);}
}
diff --git a/lcc/src/input.c b/lcc/src/input.c
index 4f0afc8..c2a084e 100644
--- a/lcc/src/input.c
+++ b/lcc/src/input.c
@@ -125,10 +125,11 @@ static void resynch(void) {
} else if (Aflag >= 2 && *cp != '\n')
warning("unrecognized control line\n");
while (*cp)
- if (*cp++ == '\n')
+ if (*cp++ == '\n') {
if (cp == limit + 1)
nextline();
else
break;
+ }
}
diff --git a/lcc/src/lex.c b/lcc/src/lex.c
index 6643172..ec2f1ec 100644
--- a/lcc/src/lex.c
+++ b/lcc/src/lex.c
@@ -685,17 +685,18 @@ int gettok(void) {
}
goto id;
default:
- if ((map[cp[-1]]&BLANK) == 0)
+ if ((map[cp[-1]]&BLANK) == 0) {
if (cp[-1] < ' ' || cp[-1] >= 0177)
error("illegal character `\\0%o'\n", cp[-1]);
else
error("illegal character `%c'\n", cp[-1]);
+ }
}
}
}
static Symbol icon(unsigned long n, int overflow, int base) {
- if ((*cp=='u'||*cp=='U') && (cp[1]=='l'||cp[1]=='L')
- || (*cp=='l'||*cp=='L') && (cp[1]=='u'||cp[1]=='U')) {
+ if (((*cp=='u'||*cp=='U') && (cp[1]=='l'||cp[1]=='L'))
+ || ((*cp=='l'||*cp=='L') && (cp[1]=='u'||cp[1]=='U'))) {
tval.type = unsignedlong;
cp += 2;
} else if (*cp == 'u' || *cp == 'U') {
diff --git a/lcc/src/null.c b/lcc/src/null.c
index 136e4a8..b9f551c 100644
--- a/lcc/src/null.c
+++ b/lcc/src/null.c
@@ -29,16 +29,16 @@ static void I(stabtype)(Symbol p) {}
Interface nullIR = {
- 1, 1, 0, /* char */
- 2, 2, 0, /* short */
- 4, 4, 0, /* int */
- 8, 8, 1, /* long */
- 8 ,8, 1, /* long long */
- 4, 4, 1, /* float */
- 8, 8, 1, /* double */
- 16,16,1, /* long double */
- 4, 4, 0, /* T* */
- 0, 4, 0, /* struct */
+ {1, 1, 0}, /* char */
+ {2, 2, 0}, /* short */
+ {4, 4, 0}, /* int */
+ {8, 8, 1}, /* long */
+ {8 ,8, 1}, /* long long */
+ {4, 4, 1}, /* float */
+ {8, 8, 1}, /* double */
+ {16,16,1}, /* long double */
+ {4, 4, 0}, /* T* */
+ {0, 4, 0}, /* struct */
1, /* little_endian */
0, /* mulops_calls */
0, /* wants_callb */
diff --git a/lcc/src/output.c b/lcc/src/output.c
index dc7a698..a9c93e7 100644
--- a/lcc/src/output.c
+++ b/lcc/src/output.c
@@ -5,7 +5,7 @@ static char *outs(const char *str, FILE *f, char *bp) {
if (f)
fputs(str, f);
else
- while (*bp = *str++)
+ while ((*bp = *str++))
bp++;
return bp;
}
@@ -95,9 +95,10 @@ void vfprint(FILE *f, char *bp, const char *fmt, va_list ap) {
case 'c': if (f) fputc(va_arg(ap, int), f); else *bp++ = va_arg(ap, int); break;
case 'S': { char *s = va_arg(ap, char *);
int n = va_arg(ap, int);
- if (s)
+ if (s) {
for ( ; n-- > 0; s++)
if (f) (void)putc(*s, f); else *bp++ = *s;
+ }
} break;
case 'k': { int t = va_arg(ap, int);
static char *tokens[] = {
diff --git a/lcc/src/prof.c b/lcc/src/prof.c
index a5123b4..02709ed 100644
--- a/lcc/src/prof.c
+++ b/lcc/src/prof.c
@@ -203,7 +203,7 @@ void prof_init(int argc, char *argv[]) {
return;
inited = 1;
type_init(argc, argv);
- if (IR)
+ if (IR) {
for (i = 1; i < argc; i++)
if (strncmp(argv[i], "-a", 2) == 0) {
if (ncalled == -1
@@ -224,4 +224,5 @@ void prof_init(int argc, char *argv[]) {
attach((Apply)bbincr, YYcounts, &events.points);
}
}
+ }
}
diff --git a/lcc/src/profio.c b/lcc/src/profio.c
index e1ce8da..37fc25b 100644
--- a/lcc/src/profio.c
+++ b/lcc/src/profio.c
@@ -150,9 +150,9 @@ int findcount(char *file, int x, int y) {
struct count *c = cursor->counts;
for (l = 0, u = cursor->count - 1; l <= u; ) {
int k = (l + u)/2;
- if (c[k].y > y || c[k].y == y && c[k].x > x)
+ if (c[k].y > y || (c[k].y == y && c[k].x > x))
u = k - 1;
- else if (c[k].y < y || c[k].y == y && c[k].x < x)
+ else if (c[k].y < y || (c[k].y == y && c[k].x < x))
l = k + 1;
else
return c[k].count;
diff --git a/lcc/src/simp.c b/lcc/src/simp.c
index 4d79af0..227dfbb 100644
--- a/lcc/src/simp.c
+++ b/lcc/src/simp.c
@@ -53,10 +53,10 @@ int needconst;
int explicitCast;
static int addi(long x, long y, long min, long max, int needconst) {
int cond = x == 0 || y == 0
- || x < 0 && y < 0 && x >= min - y
- || x < 0 && y > 0
- || x > 0 && y < 0
- || x > 0 && y > 0 && x <= max - y;
+ || (x < 0 && y < 0 && x >= min - y)
+ || (x < 0 && y > 0)
+ || (x > 0 && y < 0)
+ || (x > 0 && y > 0 && x <= max - y);
if (!cond && needconst) {
warning("overflow in constant expression\n");
cond = 1;
@@ -68,10 +68,10 @@ static int addi(long x, long y, long min, long max, int needconst) {
static int addd(double x, double y, double min, double max, int needconst) {
int cond = x == 0 || y == 0
- || x < 0 && y < 0 && x >= min - y
- || x < 0 && y > 0
- || x > 0 && y < 0
- || x > 0 && y > 0 && x <= max - y;
+ || (x < 0 && y < 0 && x >= min - y)
+ || (x < 0 && y > 0)
+ || (x > 0 && y < 0)
+ || (x > 0 && y > 0 && x <= max - y);
if (!cond && needconst) {
warning("overflow in constant expression\n");
cond = 1;
@@ -146,11 +146,11 @@ static int divd(double x, double y, double min, double max, int needconst) {
/* mul[id] - return 1 if min <= x*y <= max, 0 otherwise */
static int muli(long x, long y, long min, long max, int needconst) {
- int cond = x > -1 && x <= 1 || y > -1 && y <= 1
- || x < 0 && y < 0 && -x <= max/-y
- || x < 0 && y > 0 && x >= min/y
- || x > 0 && y < 0 && y >= min/x
- || x > 0 && y > 0 && x <= max/y;
+ int cond = (x > -1 && x <= 1) || (y > -1 && y <= 1)
+ || (x < 0 && y < 0 && -x <= max/-y)
+ || (x < 0 && y > 0 && x >= min/y)
+ || (x > 0 && y < 0 && y >= min/x)
+ || (x > 0 && y > 0 && x <= max/y);
if (!cond && needconst) {
warning("overflow in constant expression\n");
cond = 1;
@@ -161,11 +161,11 @@ static int muli(long x, long y, long min, long max, int needconst) {
}
static int muld(double x, double y, double min, double max, int needconst) {
- int cond = x >= -1 && x <= 1 || y >= -1 && y <= 1
- || x < 0 && y < 0 && -x <= max/-y
- || x < 0 && y > 0 && x >= min/y
- || x > 0 && y < 0 && y >= min/x
- || x > 0 && y > 0 && x <= max/y;
+ int cond = (x >= -1 && x <= 1) || (y >= -1 && y <= 1)
+ || (x < 0 && y < 0 && -x <= max/-y)
+ || (x < 0 && y > 0 && x >= min/y)
+ || (x > 0 && y < 0 && y >= min/x)
+ || (x > 0 && y > 0 && x <= max/y);
if (!cond && needconst) {
warning("overflow in constant expression\n");
cond = 1;
@@ -204,7 +204,6 @@ int intexpr(int tok, int n) {
}
Tree simplify(int op, Type ty, Tree l, Tree r) {
int n;
- Tree p;
if (optype(op) == 0)
op = mkop(op, ty);
@@ -256,13 +255,14 @@ Tree simplify(int op, Type ty, Tree l, Tree r) {
break;
case CVF+F: {
float d;
- if (l->op == CNST+F)
+ if (l->op == CNST+F) {
if (l->u.v.d < ty->u.sym->u.limits.min.d)
d = ty->u.sym->u.limits.min.d;
else if (l->u.v.d > ty->u.sym->u.limits.max.d)
d = ty->u.sym->u.limits.max.d;
else
d = l->u.v.d;
+ }
xcvtcnst(F,l->u.v.d,ty,d,(long double)d);
break;
}
@@ -308,14 +308,14 @@ Tree simplify(int op, Type ty, Tree l, Tree r) {
identity(r,retype(l,ty),I,i,0);
identity(r,retype(l,ty),U,u,0);
if (isaddrop(l->op)
- && (r->op == CNST+I && r->u.v.i <= longtype->u.sym->u.limits.max.i
- && r->u.v.i >= longtype->u.sym->u.limits.min.i
- || r->op == CNST+U && r->u.v.u <= longtype->u.sym->u.limits.max.i))
+ && ((r->op == CNST+I && r->u.v.i <= longtype->u.sym->u.limits.max.i
+ && r->u.v.i >= longtype->u.sym->u.limits.min.i)
+ || (r->op == CNST+U && r->u.v.u <= longtype->u.sym->u.limits.max.i)))
return addrtree(l, cast(r, longtype)->u.v.i, ty);
if (l->op == ADD+P && isaddrop(l->kids[1]->op)
- && (r->op == CNST+I && r->u.v.i <= longtype->u.sym->u.limits.max.i
- && r->u.v.i >= longtype->u.sym->u.limits.min.i
- || r->op == CNST+U && r->u.v.u <= longtype->u.sym->u.limits.max.i))
+ && ((r->op == CNST+I && r->u.v.i <= longtype->u.sym->u.limits.max.i
+ && r->u.v.i >= longtype->u.sym->u.limits.min.i)
+ || (r->op == CNST+U && r->u.v.u <= longtype->u.sym->u.limits.max.i)))
return simplify(ADD+P, ty, l->kids[0],
addrtree(l->kids[1], cast(r, longtype)->u.v.i, ty));
if ((l->op == ADD+I || l->op == SUB+I)
@@ -385,9 +385,9 @@ Tree simplify(int op, Type ty, Tree l, Tree r) {
break;
case DIV+I:
identity(r,l,I,i,1);
- if (r->op == CNST+I && r->u.v.i == 0
- || l->op == CNST+I && l->u.v.i == ty->u.sym->u.limits.min.i
- && r->op == CNST+I && r->u.v.i == -1)
+ if ((r->op == CNST+I && r->u.v.i == 0)
+ || (l->op == CNST+I && l->u.v.i == ty->u.sym->u.limits.min.i
+ && r->op == CNST+I && r->u.v.i == -1))
break;
xfoldcnst(I,i,/,divi);
break;
@@ -465,9 +465,9 @@ Tree simplify(int op, Type ty, Tree l, Tree r) {
case MOD+I:
if (r->op == CNST+I && r->u.v.i == 1) /* l%1 => (l,0) */
return tree(RIGHT, ty, root(l), cnsttree(ty, 0L));
- if (r->op == CNST+I && r->u.v.i == 0
- || l->op == CNST+I && l->u.v.i == ty->u.sym->u.limits.min.i
- && r->op == CNST+I && r->u.v.i == -1)
+ if ((r->op == CNST+I && r->u.v.i == 0)
+ || (l->op == CNST+I && l->u.v.i == ty->u.sym->u.limits.min.i
+ && r->op == CNST+I && r->u.v.i == -1))
break;
xfoldcnst(I,i,%,divi);
break;
diff --git a/lcc/src/stab.c b/lcc/src/stab.c
index e1b52cf..e53604d 100644
--- a/lcc/src/stab.c
+++ b/lcc/src/stab.c
@@ -201,9 +201,7 @@ void stabblock(int brace, int lev, Symbol *p) {
if (brace == '{')
while (*p)
stabsym(*p++);
- if (IR == &sparcIR)
- print(".stabd 0x%x,0,%d\n", brace == '{' ? N_LBRAC : N_RBRAC, lev);
- else {
+ {
int lab = genlabel(1);
print(".stabn 0x%x,0,%d,%s%d-%s\n", brace == '{' ? N_LBRAC : N_RBRAC, lev,
stabprefix, lab, cfunc->x.name);
@@ -252,9 +250,7 @@ void stabline(Coordinate *cp) {
print("%s%d:\n", stabprefix, lab);
currentfile = cp->file;
}
- if (IR == &sparcIR)
- print(".stabd 0x%x,0,%d\n", N_SLINE, cp->y);
- else {
+ {
int lab = genlabel(1);
print(".stabn 0x%x,0,%d,%s%d-%s\n", N_SLINE, cp->y,
stabprefix, lab, cfunc->x.name);
@@ -280,7 +276,7 @@ void stabsym(Symbol p) {
sz = p->type->type->size;
} else
tc = dbxtype(p->type);
- if (p->sclass == AUTO && p->scope == GLOBAL || p->sclass == EXTERN) {
+ if ((p->sclass == AUTO && p->scope == GLOBAL) || p->sclass == EXTERN) {
print(".stabs \"%s:G", p->name);
code = N_GSYM;
} else if (p->sclass == STATIC) {
diff --git a/lcc/src/stmt.c b/lcc/src/stmt.c
index 94ab403..9c3bdbe 100644
--- a/lcc/src/stmt.c
+++ b/lcc/src/stmt.c
@@ -37,7 +37,6 @@ Code code(int kind) {
return cp;
}
int reachable(int kind) {
- Code cp;
if (kind > Start) {
Code cp;
diff --git a/lcc/src/sym.c b/lcc/src/sym.c
index 723cdd4..2a1cfeb 100644
--- a/lcc/src/sym.c
+++ b/lcc/src/sym.c
@@ -296,7 +296,6 @@ Symbol mksymbol(int sclass, const char *name, Type ty) {
/* vtoa - return string for the constant v of type ty */
char *vtoa(Type ty, Value v) {
- char buf[50];
ty = unqual(ty);
switch (ty->op) {
diff --git a/lcc/src/symbolic.c b/lcc/src/symbolic.c
index dcb613e..affa67a 100644
--- a/lcc/src/symbolic.c
+++ b/lcc/src/symbolic.c
@@ -404,16 +404,16 @@ static void I(stabsym)(Symbol p) {}
static void I(stabtype)(Symbol p) {}
Interface symbolicIR = {
- 1, 1, 0, /* char */
- 2, 2, 0, /* short */
- 4, 4, 0, /* int */
- 4, 4, 0, /* long */
- 4, 4, 0, /* long long */
- 4, 4, 1, /* float */
- 8, 8, 1, /* double */
- 8, 8, 1, /* long double */
- 4, 4, 0, /* T* */
- 0, 4, 0, /* struct */
+ {1, 1, 0}, /* char */
+ {2, 2, 0}, /* short */
+ {4, 4, 0}, /* int */
+ {4, 4, 0}, /* long */
+ {4, 4, 0}, /* long long */
+ {4, 4, 1}, /* float */
+ {8, 8, 1}, /* double */
+ {8, 8, 1}, /* long double */
+ {4, 4, 0}, /* T* */
+ {0, 4, 0}, /* struct */
0, /* little_endian */
0, /* mulops_calls */
0, /* wants_callb */
@@ -449,16 +449,16 @@ Interface symbolicIR = {
};
Interface symbolic64IR = {
- 1, 1, 0, /* char */
- 2, 2, 0, /* short */
- 4, 4, 0, /* int */
- 8, 8, 0, /* long */
- 8, 8, 0, /* long long */
- 4, 4, 1, /* float */
- 8, 8, 1, /* double */
- 8, 8, 1, /* long double */
- 8, 8, 0, /* T* */
- 0, 1, 0, /* struct */
+ {1, 1, 0}, /* char */
+ {2, 2, 0}, /* short */
+ {4, 4, 0}, /* int */
+ {8, 8, 0}, /* long */
+ {8, 8, 0}, /* long long */
+ {4, 4, 1}, /* float */
+ {8, 8, 1}, /* double */
+ {8, 8, 1}, /* long double */
+ {8, 8, 0}, /* T* */
+ {0, 1, 0}, /* struct */
1, /* little_endian */
0, /* mulops_calls */
0, /* wants_callb */
diff --git a/lcc/src/trace.c b/lcc/src/trace.c
index 06b627d..3b9ba78 100644
--- a/lcc/src/trace.c
+++ b/lcc/src/trace.c
@@ -8,7 +8,7 @@ static Symbol frameno; /* local holding frame number */
/* appendstr - append str to the evolving format string, expanding it if necessary */
static void appendstr(char *str) {
do
- if (fp == fmtend)
+ if (fp == fmtend) {
if (fp) {
char *s = allocate(2*(fmtend - fmt), FUNC);
strncpy(s, fmt, fmtend - fmt);
@@ -19,6 +19,7 @@ static void appendstr(char *str) {
fp = fmt = allocate(80, FUNC);
fmtend = fmt + 80;
}
+ }
while ((*fp++ = *str++) != 0);
fp--;
}
diff --git a/lcc/src/types.c b/lcc/src/types.c
index 207cdb5..4aa3d18 100644
--- a/lcc/src/types.c
+++ b/lcc/src/types.c
@@ -233,8 +233,8 @@ Type qual(int op, Type ty) {
ty->align, NULL);
else if (isfunc(ty))
warning("qualified function type ignored\n");
- else if (isconst(ty) && op == CONST
- || isvolatile(ty) && op == VOLATILE)
+ else if ((isconst(ty) && op == CONST)
+ || (isvolatile(ty) && op == VOLATILE))
error("illegal type `%k %t'\n", op, ty);
else {
if (isqual(ty)) {
@@ -276,7 +276,7 @@ Type newstruct(int op, char *tag) {
tag = stringd(genlabel(1));
else
if ((p = lookup(tag, types)) != NULL && (p->scope == level
- || p->scope == PARAM && level == PARAM+1)) {
+ || (p->scope == PARAM && level == PARAM+1))) {
if (p->type->op == op && !p->defined)
return p->type;
error("redefinition of `%s' previously defined at %w\n",
@@ -400,7 +400,7 @@ Type compose(Type ty1, Type ty2) {
case CONST: case VOLATILE:
return qual(ty1->op, compose(ty1->type, ty2->type));
case ARRAY: { Type ty = compose(ty1->type, ty2->type);
- if (ty1->size && (ty1->type->size && ty2->size == 0 || ty1->size == ty2->size))
+ if (ty1->size && ((ty1->type->size && ty2->size == 0) || ty1->size == ty2->size))
return array(ty, ty1->size/ty1->type->size, ty1->align);
if (ty2->size && ty2->type->size && ty1->size == 0)
return array(ty, ty2->size/ty2->type->size, ty2->align);