diff options
author | tma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2005-10-04 01:21:34 +0000 |
---|---|---|
committer | tma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2005-10-04 01:21:34 +0000 |
commit | 45d6a88841f0db650d615522b1f6594ea72ceb7e (patch) | |
tree | dec4fac8ff8638b6a0d8749d52e66d0207eb161b /lcc | |
parent | 6d9be1722b2221cae39b389ce218e93d73d99335 (diff) | |
download | ioquake3-aero-45d6a88841f0db650d615522b1f6594ea72ceb7e.tar.gz ioquake3-aero-45d6a88841f0db650d615522b1f6594ea72ceb7e.zip |
* Dewarninged the lcc and q3asm source
* Removed traditional target platforms from the lcc build. This might break
building lcc on Windows using nmake. Submit patches or be quiet :p
* Default target for lcc is now bytecode, so -Wf-target=bytecode is no longer
needed on the lcc command line
git-svn-id: svn://svn.icculus.org/quake3/trunk@132 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'lcc')
-rw-r--r-- | lcc/cpp/cpp.c | 4 | ||||
-rw-r--r-- | lcc/cpp/getopt.c | 5 | ||||
-rw-r--r-- | lcc/cpp/include.c | 2 | ||||
-rw-r--r-- | lcc/cpp/lex.c | 249 | ||||
-rw-r--r-- | lcc/cpp/macro.c | 8 | ||||
-rw-r--r-- | lcc/cpp/nlist.c | 40 | ||||
-rw-r--r-- | lcc/cpp/tokens.c | 4 | ||||
-rw-r--r-- | lcc/custom.mk | 1 | ||||
-rw-r--r-- | lcc/etc/bprint.c | 12 | ||||
-rw-r--r-- | lcc/etc/lcc.c | 25 | ||||
-rw-r--r-- | lcc/etc/linux.c | 4 | ||||
-rw-r--r-- | lcc/lburg/gram.c | 12 | ||||
-rw-r--r-- | lcc/lib/bbexit.c | 2 | ||||
-rw-r--r-- | lcc/makefile | 29 | ||||
-rw-r--r-- | lcc/src/bind.c | 26 | ||||
-rw-r--r-- | lcc/src/bytecode.c | 20 | ||||
-rw-r--r-- | lcc/src/c.h | 2 | ||||
-rw-r--r-- | lcc/src/dag.c | 25 | ||||
-rw-r--r-- | lcc/src/decl.c | 42 | ||||
-rw-r--r-- | lcc/src/enode.c | 62 | ||||
-rw-r--r-- | lcc/src/expr.c | 20 | ||||
-rw-r--r-- | lcc/src/gen.c | 2 | ||||
-rw-r--r-- | lcc/src/init.c | 12 | ||||
-rw-r--r-- | lcc/src/inits.c | 1 | ||||
-rw-r--r-- | lcc/src/input.c | 3 | ||||
-rw-r--r-- | lcc/src/lex.c | 7 | ||||
-rw-r--r-- | lcc/src/null.c | 20 | ||||
-rw-r--r-- | lcc/src/output.c | 5 | ||||
-rw-r--r-- | lcc/src/prof.c | 3 | ||||
-rw-r--r-- | lcc/src/profio.c | 4 | ||||
-rw-r--r-- | lcc/src/simp.c | 64 | ||||
-rw-r--r-- | lcc/src/stab.c | 10 | ||||
-rw-r--r-- | lcc/src/stmt.c | 1 | ||||
-rw-r--r-- | lcc/src/sym.c | 1 | ||||
-rw-r--r-- | lcc/src/symbolic.c | 40 | ||||
-rw-r--r-- | lcc/src/trace.c | 3 | ||||
-rw-r--r-- | lcc/src/types.c | 8 |
37 files changed, 389 insertions, 389 deletions
diff --git a/lcc/cpp/cpp.c b/lcc/cpp/cpp.c index 6baa473..6739e4d 100644 --- a/lcc/cpp/cpp.c +++ b/lcc/cpp/cpp.c @@ -100,7 +100,7 @@ control(Tokenrow *trp) error(ERROR, "Unidentifiable control line"); return; /* else empty line */ } - if ((np = lookup(tp, 0))==NULL || (np->flag&ISKW)==0 && !skipping) { + if ((np = lookup(tp, 0))==NULL || ((np->flag&ISKW)==0 && !skipping)) { error(WARNING, "Unknown preprocessor control %t", tp); return; } @@ -215,7 +215,7 @@ control(Tokenrow *trp) tp = trp->bp+2; kline: if (tp+1>=trp->lp || tp->type!=NUMBER || tp+3<trp->lp - || (tp+3==trp->lp && ((tp+1)->type!=STRING)||*(tp+1)->t=='L')){ + || ((tp+3==trp->lp && ((tp+1)->type!=STRING))||*(tp+1)->t=='L')){ error(ERROR, "Syntax error in #line"); return; } diff --git a/lcc/cpp/getopt.c b/lcc/cpp/getopt.c index 07fd798..abcb35f 100644 --- a/lcc/cpp/getopt.c +++ b/lcc/cpp/getopt.c @@ -1,11 +1,11 @@ #include <stdio.h> +#include <string.h> #define EPR fprintf(stderr, #define ERR(str, chr) if(opterr){EPR "%s%c\n", str, chr);} int opterr = 1; int optind = 1; int optopt; char *optarg; -char *strchr(); int getopt (int argc, char *const argv[], const char *opts) @@ -14,7 +14,7 @@ getopt (int argc, char *const argv[], const char *opts) int c; char *cp; - if (sp == 1) + if (sp == 1) { if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0') return -1; @@ -22,6 +22,7 @@ getopt (int argc, char *const argv[], const char *opts) optind++; return -1; } + } optopt = c = argv[optind][sp]; if (c == ':' || (cp=strchr(opts, c)) == 0) { ERR (": illegal option -- ", c); diff --git a/lcc/cpp/include.c b/lcc/cpp/include.c index 72ec8ae..b3757e8 100644 --- a/lcc/cpp/include.c +++ b/lcc/cpp/include.c @@ -59,7 +59,7 @@ doinclude(Tokenrow *trp) if ((fd = open(iname, 0)) >= 0) break; } - if ( Mflag>1 || !angled&&Mflag==1 ) { + if ( Mflag>1 || (!angled&&Mflag==1) ) { write(1,objname,strlen(objname)); write(1,iname,strlen(iname)); write(1,"\n",1); diff --git a/lcc/cpp/lex.c b/lcc/cpp/lex.c index fc4c5db..8030354 100644 --- a/lcc/cpp/lex.c +++ b/lcc/cpp/lex.c @@ -52,183 +52,183 @@ struct fsm { /*const*/ struct fsm fsm[] = { /* start state */ - START, { C_XX }, ACT(UNCLASS,S_SELF), - START, { ' ', '\t', '\v' }, WS1, - START, { C_NUM }, NUM1, - START, { '.' }, NUM3, - START, { C_ALPH }, ID1, - START, { 'L' }, ST1, - START, { '"' }, ST2, - START, { '\'' }, CC1, - START, { '/' }, COM1, - START, { EOFC }, S_EOF, - START, { '\n' }, S_NL, - START, { '-' }, MINUS1, - START, { '+' }, PLUS1, - START, { '<' }, LT1, - START, { '>' }, GT1, - START, { '=' }, ASG1, - START, { '!' }, NOT1, - START, { '&' }, AND1, - START, { '|' }, OR1, - START, { '#' }, SHARP1, - START, { '%' }, PCT1, - START, { '[' }, ACT(SBRA,S_SELF), - START, { ']' }, ACT(SKET,S_SELF), - START, { '(' }, ACT(LP,S_SELF), - START, { ')' }, ACT(RP,S_SELF), - START, { '*' }, STAR1, - START, { ',' }, ACT(COMMA,S_SELF), - START, { '?' }, ACT(QUEST,S_SELF), - START, { ':' }, ACT(COLON,S_SELF), - START, { ';' }, ACT(SEMIC,S_SELF), - START, { '{' }, ACT(CBRA,S_SELF), - START, { '}' }, ACT(CKET,S_SELF), - START, { '~' }, ACT(TILDE,S_SELF), - START, { '^' }, CIRC1, + {START, { C_XX }, ACT(UNCLASS,S_SELF)}, + {START, { ' ', '\t', '\v' }, WS1}, + {START, { C_NUM }, NUM1}, + {START, { '.' }, NUM3}, + {START, { C_ALPH }, ID1}, + {START, { 'L' }, ST1}, + {START, { '"' }, ST2}, + {START, { '\'' }, CC1}, + {START, { '/' }, COM1}, + {START, { EOFC }, S_EOF}, + {START, { '\n' }, S_NL}, + {START, { '-' }, MINUS1}, + {START, { '+' }, PLUS1}, + {START, { '<' }, LT1}, + {START, { '>' }, GT1}, + {START, { '=' }, ASG1}, + {START, { '!' }, NOT1}, + {START, { '&' }, AND1}, + {START, { '|' }, OR1}, + {START, { '#' }, SHARP1}, + {START, { '%' }, PCT1}, + {START, { '[' }, ACT(SBRA,S_SELF)}, + {START, { ']' }, ACT(SKET,S_SELF)}, + {START, { '(' }, ACT(LP,S_SELF)}, + {START, { ')' }, ACT(RP,S_SELF)}, + {START, { '*' }, STAR1}, + {START, { ',' }, ACT(COMMA,S_SELF)}, + {START, { '?' }, ACT(QUEST,S_SELF)}, + {START, { ':' }, ACT(COLON,S_SELF)}, + {START, { ';' }, ACT(SEMIC,S_SELF)}, + {START, { '{' }, ACT(CBRA,S_SELF)}, + {START, { '}' }, ACT(CKET,S_SELF)}, + {START, { '~' }, ACT(TILDE,S_SELF)}, + {START, { '^' }, CIRC1}, /* saw a digit */ - NUM1, { C_XX }, ACT(NUMBER,S_SELFB), - NUM1, { C_NUM, C_ALPH, '.' }, NUM1, - NUM1, { 'E', 'e' }, NUM2, - NUM1, { '_' }, ACT(NUMBER,S_SELFB), + {NUM1, { C_XX }, ACT(NUMBER,S_SELFB)}, + {NUM1, { C_NUM, C_ALPH, '.' }, NUM1}, + {NUM1, { 'E', 'e' }, NUM2}, + {NUM1, { '_' }, ACT(NUMBER,S_SELFB)}, /* saw possible start of exponent, digits-e */ - NUM2, { C_XX }, ACT(NUMBER,S_SELFB), - NUM2, { '+', '-' }, NUM1, - NUM2, { C_NUM, C_ALPH }, NUM1, - NUM2, { '_' }, ACT(NUMBER,S_SELFB), + {NUM2, { C_XX }, ACT(NUMBER,S_SELFB)}, + {NUM2, { '+', '-' }, NUM1}, + {NUM2, { C_NUM, C_ALPH }, NUM1}, + {NUM2, { '_' }, ACT(NUMBER,S_SELFB)}, /* saw a '.', which could be a number or an operator */ - NUM3, { C_XX }, ACT(DOT,S_SELFB), - NUM3, { '.' }, DOTS1, - NUM3, { C_NUM }, NUM1, + {NUM3, { C_XX }, ACT(DOT,S_SELFB)}, + {NUM3, { '.' }, DOTS1}, + {NUM3, { C_NUM }, NUM1}, - DOTS1, { C_XX }, ACT(UNCLASS, S_SELFB), - DOTS1, { C_NUM }, NUM1, - DOTS1, { '.' }, ACT(ELLIPS, S_SELF), + {DOTS1, { C_XX }, ACT(UNCLASS, S_SELFB)}, + {DOTS1, { C_NUM }, NUM1}, + {DOTS1, { '.' }, ACT(ELLIPS, S_SELF)}, /* saw a letter or _ */ - ID1, { C_XX }, ACT(NAME,S_NAME), - ID1, { C_ALPH, C_NUM }, ID1, + {ID1, { C_XX }, ACT(NAME,S_NAME)}, + {ID1, { C_ALPH, C_NUM }, ID1}, /* saw L (start of wide string?) */ - ST1, { C_XX }, ACT(NAME,S_NAME), - ST1, { C_ALPH, C_NUM }, ID1, - ST1, { '"' }, ST2, - ST1, { '\'' }, CC1, + {ST1, { C_XX }, ACT(NAME,S_NAME)}, + {ST1, { C_ALPH, C_NUM }, ID1}, + {ST1, { '"' }, ST2}, + {ST1, { '\'' }, CC1}, /* saw " beginning string */ - ST2, { C_XX }, ST2, - ST2, { '"' }, ACT(STRING, S_SELF), - ST2, { '\\' }, ST3, - ST2, { '\n' }, S_STNL, - ST2, { EOFC }, S_EOFSTR, + {ST2, { C_XX }, ST2}, + {ST2, { '"' }, ACT(STRING, S_SELF)}, + {ST2, { '\\' }, ST3}, + {ST2, { '\n' }, S_STNL}, + {ST2, { EOFC }, S_EOFSTR}, /* saw \ in string */ - ST3, { C_XX }, ST2, - ST3, { '\n' }, S_STNL, - ST3, { EOFC }, S_EOFSTR, + {ST3, { C_XX }, ST2}, + {ST3, { '\n' }, S_STNL}, + {ST3, { EOFC }, S_EOFSTR}, /* saw ' beginning character const */ - CC1, { C_XX }, CC1, - CC1, { '\'' }, ACT(CCON, S_SELF), - CC1, { '\\' }, CC2, - CC1, { '\n' }, S_STNL, - CC1, { EOFC }, S_EOFSTR, + {CC1, { C_XX }, CC1}, + {CC1, { '\'' }, ACT(CCON, S_SELF)}, + {CC1, { '\\' }, CC2}, + {CC1, { '\n' }, S_STNL}, + {CC1, { EOFC }, S_EOFSTR}, /* saw \ in ccon */ - CC2, { C_XX }, CC1, - CC2, { '\n' }, S_STNL, - CC2, { EOFC }, S_EOFSTR, + {CC2, { C_XX }, CC1}, + {CC2, { '\n' }, S_STNL}, + {CC2, { EOFC }, S_EOFSTR}, /* saw /, perhaps start of comment */ - COM1, { C_XX }, ACT(SLASH, S_SELFB), - COM1, { '=' }, ACT(ASSLASH, S_SELF), - COM1, { '*' }, COM2, - COM1, { '/' }, COM4, + {COM1, { C_XX }, ACT(SLASH, S_SELFB)}, + {COM1, { '=' }, ACT(ASSLASH, S_SELF)}, + {COM1, { '*' }, COM2}, + {COM1, { '/' }, COM4}, /* saw / then *, start of comment */ - COM2, { C_XX }, COM2, - COM2, { '\n' }, S_COMNL, - COM2, { '*' }, COM3, - COM2, { EOFC }, S_EOFCOM, + {COM2, { C_XX }, COM2}, + {COM2, { '\n' }, S_COMNL}, + {COM2, { '*' }, COM3}, + {COM2, { EOFC }, S_EOFCOM}, /* saw the * possibly ending a comment */ - COM3, { C_XX }, COM2, - COM3, { '\n' }, S_COMNL, - COM3, { '*' }, COM3, - COM3, { '/' }, S_COMMENT, + {COM3, { C_XX }, COM2}, + {COM3, { '\n' }, S_COMNL}, + {COM3, { '*' }, COM3}, + {COM3, { '/' }, S_COMMENT}, /* // comment */ - COM4, { C_XX }, COM4, - COM4, { '\n' }, S_NL, - COM4, { EOFC }, S_EOFCOM, + {COM4, { C_XX }, COM4}, + {COM4, { '\n' }, S_NL}, + {COM4, { EOFC }, S_EOFCOM}, /* saw white space, eat it up */ - WS1, { C_XX }, S_WS, - WS1, { ' ', '\t', '\v' }, WS1, + {WS1, { C_XX }, S_WS}, + {WS1, { ' ', '\t', '\v' }, WS1}, /* saw -, check --, -=, -> */ - MINUS1, { C_XX }, ACT(MINUS, S_SELFB), - MINUS1, { '-' }, ACT(MMINUS, S_SELF), - MINUS1, { '=' }, ACT(ASMINUS,S_SELF), - MINUS1, { '>' }, ACT(ARROW,S_SELF), + {MINUS1, { C_XX }, ACT(MINUS, S_SELFB)}, + {MINUS1, { '-' }, ACT(MMINUS, S_SELF)}, + {MINUS1, { '=' }, ACT(ASMINUS,S_SELF)}, + {MINUS1, { '>' }, ACT(ARROW,S_SELF)}, /* saw +, check ++, += */ - PLUS1, { C_XX }, ACT(PLUS, S_SELFB), - PLUS1, { '+' }, ACT(PPLUS, S_SELF), - PLUS1, { '=' }, ACT(ASPLUS, S_SELF), + {PLUS1, { C_XX }, ACT(PLUS, S_SELFB)}, + {PLUS1, { '+' }, ACT(PPLUS, S_SELF)}, + {PLUS1, { '=' }, ACT(ASPLUS, S_SELF)}, /* saw <, check <<, <<=, <= */ - LT1, { C_XX }, ACT(LT, S_SELFB), - LT1, { '<' }, LT2, - LT1, { '=' }, ACT(LEQ, S_SELF), - LT2, { C_XX }, ACT(LSH, S_SELFB), - LT2, { '=' }, ACT(ASLSH, S_SELF), + {LT1, { C_XX }, ACT(LT, S_SELFB)}, + {LT1, { '<' }, LT2}, + {LT1, { '=' }, ACT(LEQ, S_SELF)}, + {LT2, { C_XX }, ACT(LSH, S_SELFB)}, + {LT2, { '=' }, ACT(ASLSH, S_SELF)}, /* saw >, check >>, >>=, >= */ - GT1, { C_XX }, ACT(GT, S_SELFB), - GT1, { '>' }, GT2, - GT1, { '=' }, ACT(GEQ, S_SELF), - GT2, { C_XX }, ACT(RSH, S_SELFB), - GT2, { '=' }, ACT(ASRSH, S_SELF), + {GT1, { C_XX }, ACT(GT, S_SELFB)}, + {GT1, { '>' }, GT2}, + {GT1, { '=' }, ACT(GEQ, S_SELF)}, + {GT2, { C_XX }, ACT(RSH, S_SELFB)}, + {GT2, { '=' }, ACT(ASRSH, S_SELF)}, /* = */ - ASG1, { C_XX }, ACT(ASGN, S_SELFB), - ASG1, { '=' }, ACT(EQ, S_SELF), + {ASG1, { C_XX }, ACT(ASGN, S_SELFB)}, + {ASG1, { '=' }, ACT(EQ, S_SELF)}, /* ! */ - NOT1, { C_XX }, ACT(NOT, S_SELFB), - NOT1, { '=' }, ACT(NEQ, S_SELF), + {NOT1, { C_XX }, ACT(NOT, S_SELFB)}, + {NOT1, { '=' }, ACT(NEQ, S_SELF)}, /* & */ - AND1, { C_XX }, ACT(AND, S_SELFB), - AND1, { '&' }, ACT(LAND, S_SELF), - AND1, { '=' }, ACT(ASAND, S_SELF), + {AND1, { C_XX }, ACT(AND, S_SELFB)}, + {AND1, { '&' }, ACT(LAND, S_SELF)}, + {AND1, { '=' }, ACT(ASAND, S_SELF)}, /* | */ - OR1, { C_XX }, ACT(OR, S_SELFB), - OR1, { '|' }, ACT(LOR, S_SELF), - OR1, { '=' }, ACT(ASOR, S_SELF), + {OR1, { C_XX }, ACT(OR, S_SELFB)}, + {OR1, { '|' }, ACT(LOR, S_SELF)}, + {OR1, { '=' }, ACT(ASOR, S_SELF)}, /* # */ - SHARP1, { C_XX }, ACT(SHARP, S_SELFB), - SHARP1, { '#' }, ACT(DSHARP, S_SELF), + {SHARP1, { C_XX }, ACT(SHARP, S_SELFB)}, + {SHARP1, { '#' }, ACT(DSHARP, S_SELF)}, /* % */ - PCT1, { C_XX }, ACT(PCT, S_SELFB), - PCT1, { '=' }, ACT(ASPCT, S_SELF), + {PCT1, { C_XX }, ACT(PCT, S_SELFB)}, + {PCT1, { '=' }, ACT(ASPCT, S_SELF)}, /* * */ - STAR1, { C_XX }, ACT(STAR, S_SELFB), - STAR1, { '=' }, ACT(ASSTAR, S_SELF), + {STAR1, { C_XX }, ACT(STAR, S_SELFB)}, + {STAR1, { '=' }, ACT(ASSTAR, S_SELF)}, /* ^ */ - CIRC1, { C_XX }, ACT(CIRC, S_SELFB), - CIRC1, { '=' }, ACT(ASCIRC, S_SELF), + {CIRC1, { C_XX }, ACT(CIRC, S_SELFB)}, + {CIRC1, { '=' }, ACT(ASCIRC, S_SELF)}, - -1 + {-1} }; /* first index is char, second is state */ @@ -254,7 +254,7 @@ expandlex(void) continue; case C_ALPH: for (j=0; j<=256; j++) - if ('a'<=j&&j<='z' || 'A'<=j&&j<='Z' + if (('a'<=j&&j<='z') || ('A'<=j&&j<='Z') || j=='_') bigfsm[j][fp->state] = nstate; continue; @@ -305,7 +305,6 @@ gettokens(Tokenrow *trp, int reset) int runelen; Source *s = cursource; int nmac = 0; - extern char outbuf[]; tp = trp->lp; ip = s->inp; diff --git a/lcc/cpp/macro.c b/lcc/cpp/macro.c index 55b4b2c..49d1129 100644 --- a/lcc/cpp/macro.c +++ b/lcc/cpp/macro.c @@ -71,7 +71,7 @@ dodefine(Tokenrow *trp) if (np->flag&ISDEFINED) { if (comparetokens(def, np->vp) || (np->ap==NULL) != (args==NULL) - || np->ap && comparetokens(args, np->ap)) + || (np->ap && comparetokens(args, np->ap))) error(ERROR, "Macro redefinition of %t", trp->bp+2); } if (args) { @@ -141,7 +141,7 @@ expandrow(Tokenrow *trp, char *flag) || quicklook(tp->t[0], tp->len>1?tp->t[1]:0)==0 || (np = lookup(tp, 0))==NULL || (np->flag&(ISDEFINED|ISMAC))==0 - || tp->hideset && checkhideset(tp->hideset, np)) { + || (tp->hideset && checkhideset(tp->hideset, np))) { tp++; continue; } @@ -300,7 +300,7 @@ gatherargs(Tokenrow *trp, Tokenrow **atr, int *narg) parens--; if (lp->type==DSHARP) lp->type = DSHARP1; /* ## not special in arg */ - if (lp->type==COMMA && parens==0 || parens<0 && (lp-1)->type!=LP) { + if ((lp->type==COMMA && parens==0) || (parens<0 && (lp-1)->type!=LP)) { if (*narg>=NARG-1) error(FATAL, "Sorry, too many macro arguments"); ttr.bp = ttr.tp = bp; @@ -339,7 +339,7 @@ substargs(Nlist *np, Tokenrow *rtr, Tokenrow **atr) if (rtr->tp->type==NAME && (argno = lookuparg(np, rtr->tp)) >= 0) { if ((rtr->tp+1)->type==DSHARP - || rtr->tp!=rtr->bp && (rtr->tp-1)->type==DSHARP) + || (rtr->tp!=rtr->bp && (rtr->tp-1)->type==DSHARP)) insertrow(rtr, 1, atr[argno]); else { copytokenrow(&tatr, atr[argno]); diff --git a/lcc/cpp/nlist.c b/lcc/cpp/nlist.c index 33c2db9..d857dfa 100644 --- a/lcc/cpp/nlist.c +++ b/lcc/cpp/nlist.c @@ -20,26 +20,26 @@ struct kwtab { int val; int flag; } kwtab[] = { - "if", KIF, ISKW, - "ifdef", KIFDEF, ISKW, - "ifndef", KIFNDEF, ISKW, - "elif", KELIF, ISKW, - "else", KELSE, ISKW, - "endif", KENDIF, ISKW, - "include", KINCLUDE, ISKW, - "define", KDEFINE, ISKW, - "undef", KUNDEF, ISKW, - "line", KLINE, ISKW, - "error", KERROR, ISKW, - "pragma", KPRAGMA, ISKW, - "eval", KEVAL, ISKW, - "defined", KDEFINED, ISDEFINED+ISUNCHANGE, - "__LINE__", KLINENO, ISMAC+ISUNCHANGE, - "__FILE__", KFILE, ISMAC+ISUNCHANGE, - "__DATE__", KDATE, ISMAC+ISUNCHANGE, - "__TIME__", KTIME, ISMAC+ISUNCHANGE, - "__STDC__", KSTDC, ISUNCHANGE, - NULL + {"if", KIF, ISKW}, + {"ifdef", KIFDEF, ISKW}, + {"ifndef", KIFNDEF, ISKW}, + {"elif", KELIF, ISKW}, + {"else", KELSE, ISKW}, + {"endif", KENDIF, ISKW}, + {"include", KINCLUDE, ISKW}, + {"define", KDEFINE, ISKW}, + {"undef", KUNDEF, ISKW}, + {"line", KLINE, ISKW}, + {"error", KERROR, ISKW}, + {"pragma", KPRAGMA, ISKW}, + {"eval", KEVAL, ISKW}, + {"defined", KDEFINED, ISDEFINED+ISUNCHANGE}, + {"__LINE__", KLINENO, ISMAC+ISUNCHANGE}, + {"__FILE__", KFILE, ISMAC+ISUNCHANGE}, + {"__DATE__", KDATE, ISMAC+ISUNCHANGE}, + {"__TIME__", KTIME, ISMAC+ISUNCHANGE}, + {"__STDC__", KSTDC, ISUNCHANGE}, + {NULL} }; unsigned long namebit[077+1]; diff --git a/lcc/cpp/tokens.c b/lcc/cpp/tokens.c index ebbd186..147569b 100644 --- a/lcc/cpp/tokens.c +++ b/lcc/cpp/tokens.c @@ -154,14 +154,14 @@ makespace(Tokenrow *trp) return; if (tp->wslen) { if (tp->flag&XPWS - && (wstab[tp->type] || trp->tp>trp->bp && wstab[(tp-1)->type])) { + && (wstab[tp->type] || (trp->tp>trp->bp && wstab[(tp-1)->type]))) { tp->wslen = 0; return; } tp->t[-1] = ' '; return; } - if (wstab[tp->type] || trp->tp>trp->bp && wstab[(tp-1)->type]) + if (wstab[tp->type] || (trp->tp>trp->bp && wstab[(tp-1)->type])) return; tt = newstring(tp->t, tp->len, 1); *tt++ = ' '; diff --git a/lcc/custom.mk b/lcc/custom.mk deleted file mode 100644 index 9577988..0000000 --- a/lcc/custom.mk +++ /dev/null @@ -1 +0,0 @@ -BUILDDIR=.obj diff --git a/lcc/etc/bprint.c b/lcc/etc/bprint.c index d22f537..fd073ab 100644 --- a/lcc/etc/bprint.c +++ b/lcc/etc/bprint.c @@ -70,7 +70,7 @@ void *alloc(unsigned n) { void emitdata(char *file) { FILE *fp; - if (fp = fopen(file, "w")) { + if ((fp = fopen(file, "w"))) { struct file *p; for (p = filelist; p; p = p->link) { int i; @@ -78,7 +78,7 @@ void emitdata(char *file) { struct caller *r; fprintf(fp, "1\n%s\n", p->name); for (i = 0, q = p->funcs; q; i++, q = q->link) - if (r = q->callers) + if ((r = q->callers)) for (i--; r; r = r->link) i++; fprintf(fp, "%d\n", i); @@ -109,7 +109,7 @@ FILE *openfile(char *name) { for (i = 0; dirs[i]; i++) { char buf[200]; sprintf(buf, "%s/%s", dirs[i], name); - if (fp = fopen(buf, "r")) + if ((fp = fopen(buf, "r"))) return fp; } return fopen(name, "r"); @@ -297,9 +297,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; @@ -461,7 +461,7 @@ int main(int argc, char *argv[]) { if (i < argc) { int nf = i < argc - 1 ? 1 : 0; for ( ; i < argc; i++, nf ? nf++ : 0) - if (p = findfile(string(argv[i]))) + if ((p = findfile(string(argv[i])))) (*f)(p, nf); else fprintf(stderr, "%s: no data for `%s'\n", progname, argv[i]); diff --git a/lcc/etc/lcc.c b/lcc/etc/lcc.c index a52119b..3b8e6e2 100644 --- a/lcc/etc/lcc.c +++ b/lcc/etc/lcc.c @@ -11,6 +11,7 @@ static char rcsid[] = "Id: dummy rcsid"; #include <assert.h> #include <ctype.h> #include <signal.h> +#include <unistd.h> #ifndef TEMPDIR #define TEMPDIR "/tmp" @@ -47,7 +48,6 @@ extern char *stringf(const char *, ...); extern int suffix(char *, char *[], int); extern char *tempname(char *); -extern int access(char *, int); extern int getpid(void); extern char *cpp[], *include[], *com[], *as[],*ld[], inputs[], *suffixes[]; @@ -71,7 +71,7 @@ char *tempdir = TEMPDIR; /* directory for temporary files */ static char *progname; static List lccinputs; /* list of input directories */ -main(int argc, char *argv[]) { +int main(int argc, char *argv[]) { int i, j, nf; progname = argv[0]; @@ -93,7 +93,7 @@ main(int argc, char *argv[]) { tempdir = getenv("TMPDIR"); assert(tempdir); i = strlen(tempdir); - for (; i > 0 && tempdir[i-1] == '/' || tempdir[i-1] == '\\'; i--) + for (; (i > 0 && tempdir[i-1] == '/') || tempdir[i-1] == '\\'; i--) tempdir[i-1] = '\0'; if (argc <= 1) { help(); @@ -149,7 +149,7 @@ main(int argc, char *argv[]) { char *name = exists(argv[i]); if (name) { if (strcmp(name, argv[i]) != 0 - || nf > 1 && suffix(name, suffixes, 3) >= 0) + || (nf > 1 && suffix(name, suffixes, 3) >= 0)) fprintf(stderr, "%s:\n", name); filename(name, 0); } else @@ -214,7 +214,6 @@ char *basepath(char *name) { #define _P_WAIT 0 extern int fork(void); extern int wait(int *); -extern void execv(const char *, char *[]); static int _spawnvp(int mode, const char *cmdname, char *argv[]) { int pid, n, status; @@ -261,7 +260,7 @@ static int callsys(char **av) { } for (i = 0; status == 0 && av[i] != NULL; ) { int j = 0; - char *s; + char *s = NULL; for ( ; av[i] != NULL && (s = strchr(av[i], '\n')) == NULL; i++) argv[j++] = av[i]; if (s != NULL) { @@ -319,7 +318,7 @@ static void compose(char *cmd[], List a, List b, List c) { if (s && isdigit(s[1])) { int k = s[1] - '0'; assert(k >=1 && k <= 3); - if (b = lists[k-1]) { + if ((b = lists[k-1])) { b = b->link; av[j] = alloc(strlen(cmd[i]) + strlen(b->str) - 1); strncpy(av[j], cmd[i], s - cmd[i]); @@ -452,7 +451,7 @@ static int filename(char *name, char *base) { static List find(char *str, List list) { List b; - if (b = list) + if ((b = list)) do { if (strcmp(str, b->str) == 0) return b; @@ -508,7 +507,7 @@ static void help(void) { if (strncmp("-tempdir", msgs[i], 8) == 0 && tempdir) fprintf(stderr, "; default=%s", tempdir); } -#define xx(v) if (s = getenv(#v)) fprintf(stderr, #v "=%s\n", s) +#define xx(v) if ((s = getenv(#v))) fprintf(stderr, #v "=%s\n", s) xx(LCCINPUTS); xx(LCCDIR); #ifdef WIN32 @@ -521,13 +520,13 @@ static void help(void) { /* initinputs - if LCCINPUTS or include is defined, use them to initialize various lists */ static void initinputs(void) { char *s = getenv("LCCINPUTS"); - List list, b; + List b; if (s == 0 || (s = inputs)[0] == 0) s = "."; if (s) { lccinputs = path2list(s); - if (b = lccinputs) + if ((b = lccinputs)) do { b = b->link; if (strcmp(b->str, ".") != 0) { @@ -701,7 +700,7 @@ static List path2list(const char *path) { sep = ';'; while (*path) { char *p, buf[512]; - if (p = strchr(path, sep)) { + if ((p = strchr(path, sep))) { assert(p - path < sizeof buf); strncpy(buf, path, p - path); buf[p-path] = '\0'; @@ -767,7 +766,7 @@ int suffix(char *name, char *tails[], int n) { for (i = 0; i < n; i++) { char *s = tails[i], *t; - for ( ; t = strchr(s, ';'); s = t + 1) { + for ( ; (t = strchr(s, ';')); s = t + 1) { int m = t - s; if (len > m && strncmp(&name[len-m], s, m) == 0) return i; diff --git a/lcc/etc/linux.c b/lcc/etc/linux.c index a65636d..bf50025 100644 --- a/lcc/etc/linux.c +++ b/lcc/etc/linux.c @@ -2,8 +2,6 @@ #include <string.h> -static char rcsid[] = "Dummy rcsid"; - /* TTimo - 10-18-2001 our binaries are named q3lcc q3rcc and q3cpp @@ -26,7 +24,7 @@ char *cpp[] = { LCCDIR "q3cpp", "$1", "$2", "$3", 0 }; char *include[] = {"-I" LCCDIR "include", "-I" LCCDIR "gcc/include", "-I/usr/include", "-I" SYSTEM "include", 0 }; -char *com[] = {LCCDIR "q3rcc", "-target=x86/linux", "$1", "$2", "$3", 0 }; +char *com[] = {LCCDIR "q3rcc", "-target=bytecode", "$1", "$2", "$3", 0 }; char *as[] = { "/usr/bin/as", "-o", "$3", "$1", "$2", 0 }; // NOTE TTimo I don't think we have any use with the native linkage // our target is always bytecode.. diff --git a/lcc/lburg/gram.c b/lcc/lburg/gram.c index 6e1f6e4..a1cc890 100644 --- a/lcc/lburg/gram.c +++ b/lcc/lburg/gram.c @@ -18,9 +18,9 @@ YYCONST static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley +Cygnus.28) 01/20/91 #ifndef YYDONT_INCLUDE_STDIO #include <stdio.h> #endif -#ifdef __cplusplus +//#ifdef __cplusplus TA <tim@ngus.net> stdlib.h applies to C too #include <stdlib.h> /* for malloc/realloc/free */ -#endif +//#endif #line 2 "lburg/gram.y" #include <stdio.h> #include "lburg.h" @@ -227,7 +227,9 @@ inline #endif yygrow () { +#if YYDEBUG int old_stacksize = yystacksize; +#endif short *new_yyss; YYSTYPE *new_yyvs; @@ -469,7 +471,7 @@ yypush: *++yyvsp = yyval; yyloop: - if (yyn = yydefred[yystate]) goto yyreduce; + if ((yyn = yydefred[yystate])) goto yyreduce; yyn = yysindex[yystate]; if (yychar < 0) { @@ -509,13 +511,13 @@ yyloop: if (yyerrflag) goto yyinrecovery; #ifdef lint goto yynewerror; -#endif yynewerror: +#endif yyerror("syntax error"); #ifdef lint goto yyerrlab; -#endif yyerrlab: +#endif ++yynerrs; yyinrecovery: if (yyerrflag < 3) diff --git a/lcc/lib/bbexit.c b/lcc/lib/bbexit.c index 471d606..6dff067 100644 --- a/lcc/lib/bbexit.c +++ b/lcc/lib/bbexit.c @@ -55,7 +55,7 @@ static void profout(struct _bbdata *p, FILE *fp) { for (i = 0; p->files[i]; i++) fprintf(fp, "%s\n", p->files[i]); for (i = 0, f = p->funcs; f; i++, f = f->link) - if (q = f->callers) + if ((q = f->callers)) for (i--; q; q = q->link) i++; fprintf(fp, "%d\n", i); diff --git a/lcc/makefile b/lcc/makefile index 96c54d5..c496406 100644 --- a/lcc/makefile +++ b/lcc/makefile @@ -5,7 +5,7 @@ A=.a O=.o E= CC=cc -CFLAGS=-g -Wall +CFLAGS=-O2 -Wall -fno-strict-aliasing LDFLAGS= LD=cc AR=ar ruv @@ -13,9 +13,8 @@ RANLIB=ranlib DIFF=diff RM=rm -f RMDIR=rmdir +BUILDDIR=build TSTDIR=$(BUILDDIR)/$(TARGET)/tst -CUSTOM=custom.mk -include $(CUSTOM) B=$(BUILDDIR)/ T=$(TSTDIR)/ @@ -24,14 +23,18 @@ T=$(TSTDIR)/ what: -@echo make all q3rcc lburg q3cpp q3lcc bprint liblcc triple clean clobber +makedirs: + @if [ ! -d $(B) ];then mkdir $(B);fi + @if [ ! -d $(T) ];then mkdir $(T);fi + all:: q3rcc lburg q3cpp q3lcc bprint liblcc -q3rcc: $Bq3rcc$E -lburg: $Blburg$E -q3cpp: $Bq3cpp$E -q3lcc: $Bq3lcc$E -bprint: $Bbprint$E -liblcc: $Bliblcc$A +q3rcc: makedirs $Bq3rcc$E +lburg: makedirs $Blburg$E +q3cpp: makedirs $Bq3cpp$E +q3lcc: makedirs $Bq3lcc$E +bprint: makedirs $Bbprint$E +liblcc: makedirs $Bliblcc$A RCCOBJS=$Balloc$O \ $Bbind$O \ @@ -61,13 +64,7 @@ RCCOBJS=$Balloc$O \ $Bnull$O \ $Bsymbolic$O \ $Bgen$O \ - $Bbytecode$O \ - $Balpha$O \ - $Bmips$O \ - $Bsparc$O \ - $Bstab$O \ - $Bx86$O \ - $Bx86linux$O + $Bbytecode$O $Bq3rcc$E:: $Bmain$O $Blibrcc$A $(EXTRAOBJS) $(LD) $(LDFLAGS) -o $@ $Bmain$O $(EXTRAOBJS) $Blibrcc$A $(EXTRALIBS) 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); |