diff options
| -rw-r--r-- | utils/cc/cc.y | 54 | ||||
| -rw-r--r-- | utils/cc/lex.c | 4 |
2 files changed, 33 insertions, 25 deletions
diff --git a/utils/cc/cc.y b/utils/cc/cc.y index 9ddb1976..3057547b 100644 --- a/utils/cc/cc.y +++ b/utils/cc/cc.y @@ -35,7 +35,7 @@ %type <node> xdecor xdecor2 labels label ulstmnt %type <node> adlist edecor tag qual qlist %type <node> abdecor abdecor1 abdecor2 abdecor3 -%type <node> zexpr lexpr init ilist +%type <node> zexpr lexpr init ilist forexpr %left ';' %left ',' @@ -62,6 +62,7 @@ %token LIF LINT LLONG LREGISTER LRETURN LSHORT LSIZEOF LUSED %token LSTATIC LSTRUCT LSWITCH LTYPEDEF LTYPESTR LUNION LUNSIGNED %token LWHILE LVOID LENUM LSIGNED LCONSTNT LVOLATILE LSET LSIGNOF +%token LRESTRICT LINLINE %% prog: | prog xdecl @@ -146,26 +147,13 @@ xdecor2: * automatic declarator */ adecl: - { - $$ = Z; - } -| adecl ctlist ';' + ctlist ';' { $$ = dodecl(adecl, lastclass, lasttype, Z); - if($1 != Z) - if($$ != Z) - $$ = new(OLIST, $1, $$); - else - $$ = $1; } -| adecl ctlist adlist ';' +| ctlist adlist ';' { - $$ = $1; - if($3 != Z) { - $$ = $3; - if($1 != Z) - $$ = new(OLIST, $1, $3); - } + $$ = $2; } adlist: @@ -371,11 +359,11 @@ arglist: } block: - '{' adecl slist '}' + '{' slist '}' { - $$ = invert($3); - if($2 != Z) - $$ = new(OLIST, $2, $$); + $$ = invert($2); + // if($2 != Z) + // $$ = new(OLIST, $2, $$); if($$ == Z) $$ = new(OLIST, Z, Z); } @@ -384,6 +372,10 @@ slist: { $$ = Z; } +| slist adecl + { + $$ = new(OLIST, $1, $2); + } | slist stmnt { $$ = new(OLIST, $1, $2); @@ -421,6 +413,13 @@ stmnt: $$ = new(OLIST, $1, $2); } +forexpr: + zcexpr +| ctlist adlist + { + $$ = $2; + } + ulstmnt: zcexpr ';' | { @@ -448,9 +447,16 @@ ulstmnt: if($7 == Z) warn($3, "empty else body"); } -| LFOR '(' zcexpr ';' zcexpr ';' zcexpr ')' stmnt +| { markdcl(); } LFOR '(' forexpr ';' zcexpr ';' zcexpr ')' stmnt { - $$ = new(OFOR, new(OLIST, $5, new(OLIST, $3, $7)), $9); + $$ = revertdcl(); + if($$){ + if($4) + $4 = new(OLIST, $$, $4); + else + $4 = $$; + } + $$ = new(OFOR, new(OLIST, $6, new(OLIST, $4, $8)), $10); } | LWHILE '(' cexpr ')' stmnt { @@ -1129,10 +1135,12 @@ cname: /* class words */ | LTYPEDEF { $$ = BTYPEDEF; } | LTYPESTR { $$ = BTYPESTR; } | LREGISTER { $$ = BREGISTER; } +| LINLINE { $$ = 0; } gname: /* garbage words */ LCONSTNT { $$ = BCONSTNT; } | LVOLATILE { $$ = BVOLATILE; } +| LRESTRICT { $$ = 0; } name: LNAME diff --git a/utils/cc/lex.c b/utils/cc/lex.c index 8e96b7bb..8ba5af5a 100644 --- a/utils/cc/lex.c +++ b/utils/cc/lex.c @@ -203,8 +203,8 @@ compile(char *file, char **defs, int ndef) if((debug['a'] || debug['Z']) && !debug['n']) { if (first) { outfile = 0; - Binit(&outbuf, dup(1, -1), OWRITE); - dup(2, 1); + Binit(&outbuf, mydup(1, -1), OWRITE); + mydup(2, 1); } } else { c = mycreat(outfile, 0664); |
