diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-09-16 18:52:53 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-09-16 18:52:53 +0000 |
commit | a586ad04d0d33919f7cb1de64baf8a1b7eefbe39 (patch) | |
tree | 6af9ebdf525ce7b870bae53abc0953ad4f3ac4a2 | |
parent | c0dd75448fcd63a05c6283b7faf6957a853eedb4 (diff) |
sync to ragge's tree to fix #include<file.h> and a declaration parsing
error.
-rw-r--r-- | usr.bin/pcc/cc/ccom/pftn.c | 7 | ||||
-rw-r--r-- | usr.bin/pcc/cc/ccom/scan.l | 4 | ||||
-rw-r--r-- | usr.bin/pcc/cc/ccom/trees.c | 14 | ||||
-rw-r--r-- | usr.bin/pcc/cc/cpp/cpp.c | 18 | ||||
-rw-r--r-- | usr.bin/pcc/cc/cpp/scanner.l | 6 | ||||
-rw-r--r-- | usr.bin/pcc/mip/common.c | 4 | ||||
-rw-r--r-- | usr.bin/pcc/mip/regs.c | 20 |
7 files changed, 44 insertions, 29 deletions
diff --git a/usr.bin/pcc/cc/ccom/pftn.c b/usr.bin/pcc/cc/ccom/pftn.c index f709122a539..7d4c3a8169b 100644 --- a/usr.bin/pcc/cc/ccom/pftn.c +++ b/usr.bin/pcc/cc/ccom/pftn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pftn.c,v 1.2 2007/09/15 22:04:39 ray Exp $ */ +/* $OpenBSD: pftn.c,v 1.3 2007/09/16 18:52:52 otto Exp $ */ /* * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se). * All rights reserved. @@ -1347,7 +1347,10 @@ dynalloc(struct symtab *p, int *poff) pol = buildtree(MUL, pol, n); } /* Create stack gap */ - spalloc(tn, pol, tsize(t, 0, p->ssue)); + if (pol == NIL) + uerror("aggregate dynamic array not allowed"); + else + spalloc(tn, pol, tsize(t, 0, p->ssue)); arrstkp = 0; } diff --git a/usr.bin/pcc/cc/ccom/scan.l b/usr.bin/pcc/cc/ccom/scan.l index 09a23ea4f50..7edd4bd7c5b 100644 --- a/usr.bin/pcc/cc/ccom/scan.l +++ b/usr.bin/pcc/cc/ccom/scan.l @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: scan.l,v 1.2 2007/09/15 22:04:39 ray Exp $ */ +/* $OpenBSD: scan.l,v 1.3 2007/09/16 18:52:52 otto Exp $ */ /* * Copyright (c) 2002 Anders Magnusson. All rights reserved. @@ -215,7 +215,7 @@ L?\"(\\.|[^\\"])*\" { "~" { yylval.intval = COMPL; return(C_UNOP); } "-" { return('-'); } "+" { return('+'); } -"*" { return('*'); } +"*" { if (parbal && notype == 0) notype = 1; return('*'); } "/" { yylval.intval = DIV; return(C_DIVOP); } "%" { yylval.intval = MOD; return(C_DIVOP); } "<" { yylval.intval = LT; return(C_RELOP); } diff --git a/usr.bin/pcc/cc/ccom/trees.c b/usr.bin/pcc/cc/ccom/trees.c index c25bb27e85f..a017e2486d5 100644 --- a/usr.bin/pcc/cc/ccom/trees.c +++ b/usr.bin/pcc/cc/ccom/trees.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trees.c,v 1.2 2007/09/15 22:04:39 ray Exp $ */ +/* $OpenBSD: trees.c,v 1.3 2007/09/16 18:52:52 otto Exp $ */ /* * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se). * All rights reserved. @@ -730,10 +730,14 @@ chkpun(NODE *p) /* return of void allowed but nothing else */ if (t1 == VOID && t2 == VOID) return; - if (t1 == VOID) - return werror("returning value from void function"); - if (t2 == VOID) - return uerror("using void value"); + if (t1 == VOID) { + werror("returning value from void function"); + return; + } + if (t2 == VOID) { + uerror("using void value"); + return; + } case COLON: if (t1 == VOID && t2 == VOID) return; diff --git a/usr.bin/pcc/cc/cpp/cpp.c b/usr.bin/pcc/cc/cpp/cpp.c index be86b34ea72..12d77bfb8c9 100644 --- a/usr.bin/pcc/cc/cpp/cpp.c +++ b/usr.bin/pcc/cc/cpp/cpp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpp.c,v 1.2 2007/09/15 22:04:39 ray Exp $ */ +/* $OpenBSD: cpp.c,v 1.3 2007/09/16 18:52:52 otto Exp $ */ /* * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se). @@ -104,8 +104,8 @@ int dflag; /* debug printouts */ #endif int ofd; -static usch outbuf[CPPBUF]; -static int obufp, istty; +usch outbuf[CPPBUF]; +int obufp, istty; int Cflag, Mflag; usch *Mfile; struct initar *initar; @@ -483,9 +483,10 @@ include() return; osp = stringbuf; slow = 1; - if (yylex() != WSPACE) - goto bad; -again: if ((c = yylex()) != STRING && c != '<' && c != IDENT) +again: + if ((c = yylex()) == WSPACE) + c = yylex(); + if (c != STRING && c != '<' && c != IDENT) goto bad; if (c == IDENT) { @@ -817,7 +818,7 @@ struct recur *rp; gotwarn++; if (rp == NULL) goto noid; - } else if (c == WSPACE) + } else if (c == WSPACE || c == '\n') ws = 1; } while (c == WSPACE || c == '\n' || c == WARN); @@ -1333,7 +1334,8 @@ getsymtab(usch *str) { struct symtab *sp = malloc(sizeof(struct symtab)); - sp->namep = savstr(str), savch('\0'); + sp->namep = savstr(str); + savch('\0'); sp->value = NULL; sp->file = ifiles ? ifiles->orgfn : (usch *)"<initial>"; sp->line = ifiles ? ifiles->lineno : 0; diff --git a/usr.bin/pcc/cc/cpp/scanner.l b/usr.bin/pcc/cc/cpp/scanner.l index d6b6d3df4cc..25bf1f26944 100644 --- a/usr.bin/pcc/cc/cpp/scanner.l +++ b/usr.bin/pcc/cc/cpp/scanner.l @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: scanner.l,v 1.2 2007/09/15 22:04:39 ray Exp $ */ +/* $OpenBSD: scanner.l,v 1.3 2007/09/16 18:52:52 otto Exp $ */ /* * Copyright (c) 2004 Anders Magnusson. All rights reserved. @@ -192,7 +192,7 @@ L?'(\\.|[^\\'])+' { if (YYSTATE) <CONTR>"ifndef" { contr = 0; ifndefstmt(); } <CONTR>"ifdef" { contr = 0; ifdefstmt(); } -<CONTR>"if"{WS}+ { contr = 0; storepb(); BEGIN IFR; ifstmt(); BEGIN 0; } +<CONTR>"if" { contr = 0; storepb(); BEGIN IFR; ifstmt(); BEGIN 0; } <CONTR>"include" { contr = 0; BEGIN 0; include(); prtline(); } <CONTR>"else" { contr = 0; elsestmt(); } <CONTR>"endif" { contr = 0; endifstmt(); } @@ -201,7 +201,7 @@ L?'(\\.|[^\\'])+' { if (YYSTATE) <CONTR>"undef" { contr = 0; if (slow) return IDENT; undefstmt(); } <CONTR>"line" { contr = 0; storepb(); BEGIN 0; line(); } <CONTR>"pragma" { contr = 0; pragmastmt(); } -<CONTR>"elif"{WS}+ { contr = 0; storepb(); BEGIN IFR; elifstmt(); BEGIN 0; } +<CONTR>"elif" { contr = 0; storepb(); BEGIN IFR; elifstmt(); BEGIN 0; } diff --git a/usr.bin/pcc/mip/common.c b/usr.bin/pcc/mip/common.c index 8b2c88f0fe8..d66d963ac73 100644 --- a/usr.bin/pcc/mip/common.c +++ b/usr.bin/pcc/mip/common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: common.c,v 1.2 2007/09/15 22:04:39 ray Exp $ */ +/* $OpenBSD: common.c,v 1.3 2007/09/16 18:52:52 otto Exp $ */ /* * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se). * All rights reserved. @@ -461,7 +461,7 @@ struct b { }; #define ALIGNMENT ((int)&((struct b *)0)->a2) -#define ROUNDUP(x) ((x) + (sizeof(ALIGNMENT)-1)) & ~(sizeof(ALIGNMENT)-1) +#define ROUNDUP(x) ((x) + ((ALIGNMENT)-1)) & ~((ALIGNMENT)-1) static char *allocpole; static int allocleft; diff --git a/usr.bin/pcc/mip/regs.c b/usr.bin/pcc/mip/regs.c index 06a2f7fab75..a6360af6e8b 100644 --- a/usr.bin/pcc/mip/regs.c +++ b/usr.bin/pcc/mip/regs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: regs.c,v 1.2 2007/09/15 22:04:39 ray Exp $ */ +/* $OpenBSD: regs.c,v 1.3 2007/09/16 18:52:52 otto Exp $ */ /* * Copyright (c) 2005 Anders Magnusson (ragge@ludd.luth.se). * All rights reserved. @@ -752,11 +752,15 @@ argswalk(NODE *p) static void setlive(NODE *p, int set, REGW *rv) { - if (rv != NULL) - return set ? LIVEADDR(rv) : LIVEDELR(rv); + if (rv != NULL) { + set ? LIVEADDR(rv) : LIVEDELR(rv); + return; + } - if (p->n_regw != NULL) - return set ? LIVEADDR(p->n_regw) : LIVEDELR(p->n_regw); + if (p->n_regw != NULL) { + set ? LIVEADDR(p->n_regw) : LIVEDELR(p->n_regw); + return; + } switch (optype(p->n_op)) { case LTYPE: @@ -783,8 +787,10 @@ setlive(NODE *p, int set, REGW *rv) static void addedge_r(NODE *p, REGW *w) { - if (p->n_regw != NULL) - return AddEdge(p->n_regw, w); + if (p->n_regw != NULL) { + AddEdge(p->n_regw, w); + return; + } if (optype(p->n_op) == BITYPE) addedge_r(p->n_right, w); |