Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.53
 
1.54
 
MAIN:ragge:20030612092208
 
pftn.c
_>7979         int scl;
 8080         union dimfun *dsym, *ddef;
 8181         int slev, temp;
<>82 -        int changed;
  82+        int changed;    /* XXX 4.4 */
8383 
 8484         if (q == NIL)
 8585                 return/* an error was detected */
     
 !
8989 
 9090         p = q->n_sp;
 9191 
<>92 -# ifndef BUG1
  92+#ifdef PCC_DEBUG
9393         if (ddebug) {
 9494                 printf("defid(%s (%p), ", p->sname, p);
 9595                 tprint(q->n_type);
 9696                 printf(", %s, (%p,%p)), level %d\n", scnames(class),
 9797                     q->n_df, q->n_sue, blevel);
 9898         }
<>99 -# endif
  99+#endif
100100 
 101101         fixtype(q, class);
 102102 
     
 !
106106         stp = p->stype;
 107107         slev = p->slevel;
 108108 
<>109 -# ifndef BUG1
  109+#ifdef PCC_DEBUG
110110         if (ddebug) {
 111111                 printf("        modified to ");
 112112                 tprint(type);
     
 !
116116                 printf(", %s, (%p,%p)), level %d\n",
 117117                     scnames(p->sclass), p->sdf, p->ssue, slev);
 118118         }
<>119 -# endif
  119+#endif
120120 
<>121 -        if (stp == FTN && p->sclass == SNULL)
  121+        if (stp == FTN && p->sclass == SNULL)   /* XXX 4.4 */
122122                 goto enter;
 123123 
 124124         if (blevel==1 && stp!=FARG)
     
 !
136136                 case TYPEDEF:
 137137                         ;
 138138         }
<>139 -        if (stp == UNDEF|| stp == FARG)
  139+        if (stp == UNDEF|| stp == FARG/* XXX 4.4 */
140140                 goto enter;
 141141 
 142142         if (type != stp)
     
 !
149149         /* test (and possibly adjust) dimensions */
 150150         dsym = p->sdf;
 151151         ddef = q->n_df;
<>152 -        changed = 0;
  152+        changed = 0;    /* XXX 4.4 */
153153         for( temp=type; temp&TMASK; temp = DECREF(temp) ){
 154154                 if( ISARY(temp) ){
 155155                         if (dsym->ddim == 0) {
     
 !
164164         }
 165165 
 166166         if (changed) {
<>167 -                FIXDEF(p);
  167+                FIXDEF(p);      /* XXX 4.4 */
168168         }
 169169 
 170170         /* check that redeclarations are to the same structure */
     
 !
176176 
 177177         scl = p->sclass;
 178178 
<>179 -# ifndef BUG1
  179+#ifdef PCC_DEBUG
180180         if (ddebug)
 181181                 printf("        previous class: %s\n", scnames(scl));
<>182 -# endif
  182+#endif
183183 
 184184         if (class&FIELD) {
 185185                 /* redefinition */
     
 !
250250                 }
 251251                 break;
 252252 
<>253 -        case MOE:
  253+        case MOE:       /* XXX 4.4 */
254254                 break;
 255255 
 256256         case EXTDEF:
     
 !
298298 
 299299         enter/* make a new entry */
 300300 
<>301 -# ifndef BUG1
  301+#ifdef PCC_DEBUG
302302         if(ddebug)
 303303                 printf("        new entry made\n");
<>304 -# endif
 305 -        if (type == UNDEF)
  304+#endif
  305+        if (type == UNDEF)      /* XXX 4.4 */
306306                 uerror("void type for %s", p->sname);
 307307         p->stype = type;
 308308         p->sclass = class;
     
 !
340340                 if (arrstkp)
 341341                         dynalloc(p, &autooff);
 342342                 else
<>343 -                        (void) oalloc(p, &autooff);
  343+                        oalloc(p, &autooff);
344344                 break;
 345345         case STATIC:
 346346         case EXTDEF:
     
 !
359359                 break;
 360360         case MOU:
 361361         case MOS:
<>362 -                (void) oalloc( p, &strucoff );
 363 -                if( class == MOU ) strucoff = 0;
  362+                oalloc(p, &strucoff);
  363+                if (class == MOU)
  364+                        strucoff = 0;
364365                 ssave(p);
 365366                 break;
 366367 
     
 !
383384         /* user-supplied routine to fix up new definitions */
 384385         FIXDEF(p);
 385386 
<>386 -# ifndef BUG1
  387+#ifdef PCC_DEBUG
387388         if (ddebug)
 388389                 printf( "       sdf, ssue, offset: %p, %p, %d\n",
 389390                     p->sdf, p->ssue, p->soffset);
<>390 -# endif
  391+#endif
391392 
 392393 }
 393394 
     
 !
441442         swx = 0;
 442443         swp = swtab;
 443444         tmpfree(); /* Release memory resources */
<>444 -        (void) locctr(DATA);
  445+        locctr(DATA);
445446 }
 446447 
 447448 void
     
 !
453454         int i;
 454455 
 455456         argoff = ARGINIT;
<>456 -# ifndef BUG1
  457+#ifdef PCC_DEBUG
457458         if (ddebug > 2)
 458459                 printf("dclargs()\n");
<>459 -# endif
  460+#endif
460461 
 461462         /* Generate a list for bfcode() */
 462463         parr = tmpalloc(sizeof(struct symtab *) * nparams);
 463464         for (a = lparam, i = 0; a != NULL && a != (struct params *)&lpole;
 464465             a = a->prev) {
 465466                 p = parr[i++] = a->sym;
<>466 -# ifndef BUG1
 467 -                if (ddebug > 2) {
  467+#ifdef PCC_DEBUG
  468+                if (ddebug > 2) {       /* XXX 4.4 */
468469                         printf("\t%s (%p) ",p->sname, p);
 469470                         tprint(p->stype);
 470471                         printf("\n");
 471472                 }
<>472 -# endif
  473+#endif
473474                 if (p->stype == FARG) {
 474475                         q = block(FREE, NIL, NIL, INT, 0, MKSUE(INT));
 475476                         q->n_sp = p;
 476477                         defid(q, PARAM);
 477478                 }
<>478 -                FIXARG(p); /* local arg hook, eg. for sym. debugger */
  479+/* XXX 4.4 */           FIXARG(p); /* local arg hook, eg. for sym. debugger */
479480           /* always set aside space, even for register arguments */
 480481                 oalloc(p, &argoff);
 481482         }
 482483         cendarg();
<>483 -        (void) locctr(PROG);
  484+        locctr(PROG);
484485         defalign(ALINT);
 485486         ftnno = getlab();
 486487         bfcode(parr, nparams);
     
 !
584585         r->rsym = q->n_sp;
 585586         r->rlparam = lparam;
 586587 
<>587 -        /* the "real" definition is where the members are seen */
 588 -        if (s != NULL)
 589 -                s->suse = lineno;
590588         return r;
 591589 }
 592590 
     
 !
682680         sue->suesize = strucoff;
 683681         sue->suealign = al;
 684682 
<>685 -//      FIXSTRUCT(szindex, oparam); /* local hook, eg. for sym debugger */
686683 #ifdef PCC_DEBUG
 687684         if (ddebug>1) {
 688685                 int i;
     
 !
720717         ftnend();
 721718 }
 722719 
<>723 -void
  720+void    /* XXX 4.4  hela funktionen */
724721 ftnarg(char *name)
 725722 {
 726723         struct symtab *s = lookup(name, 0);
     
 !
768765                 switch( (ty>>i)&TMASK ){
 769766 
 770767                 case FTN:
<>771 -                        uerror( "can't assign to function" );
 772 -                        return( ALCHAR );
  768+                        cerror("compiler takes alignment of function");
773769                 case PTR:
<>774 -                        return( ALPOINT );
  770+                        return(ALPOINT);
775771                 case ARY:
 776772                         continue;
 777773                 case 0:
     
 !
822818                 switch( (ty>>i)&TMASK ){
 823819 
 824820                 case FTN:
<>825 -                        /* cerror( "compiler takes size of function"); */
 826 -                        uerror( "can't take size of function" );
 827 -                        return( SZCHAR );
  821+                        cerror( "compiler takes size of function");
828822                 case PTR:
 829823                         return( SZPOINT * mult );
 830824                 case ARY:
<>831 -                        mult *= (unsigned int) d->ddim;
  825+                        mult *= d->ddim;
832826                         d++;
 833827                         continue;
 834828                 case 0:
     
 !
846840                 }
 847841         } else {
 848842                 if (sue->suelem == NULL)
<>849 -                        uerror("unknown structure/union");
  843+                        uerror("unknown structure/union/enum");
850844         }
 851845 
 852846         return((unsigned int)sue->suesize * mult);
     
 !
915909 
 916910 int ibseen = 0/* the number of } constructions which have been filled */
 917911 
<>918 -int ifull = 0; /* 1 if all initializers have been seen */
  912+int ifull = 0; /* 1 if all initializers have been seen */ /* XXX 4.4 */
919913 
 920914 int iclass/* storage class of thing being initialized */
 921915 
     
 !
927921 void
 928922 beginit(struct symtab *p, int class)
 929923 {
<>930 -# ifndef BUG1
  924+#ifdef PCC_DEBUG
931925         if (idebug >= 3)
 932926                 printf("beginit(), symtab = %p\n", p);
<>933 -# endif
  927+#endif
934928 
 935929         iclass = p->sclass;
 936930         if (class == EXTERN || class == FORTRAN)
     
 !
946940         case EXTDEF:
 947941         case STATIC:
 948942                 ilocctr = ISARY(p->stype)?ADATA:DATA;
<>949 -                if (nerrors == 0) {
 950 -                        (void) locctr(ilocctr);
 951 -                        defalign(talign(p->stype, p->ssue));
 952 -                        defnam(p);
 953 -                }
  943+                locctr(ilocctr);
  944+                defalign(talign(p->stype, p->ssue));
  945+                defnam(p);
954946         }
 955947 
 956948         inoff = 0;
     
 !
972964         struct instk *sp;
 973965 
 974966         for (;;) {
<>975 -# ifndef BUG1
  967+#ifdef PCC_DEBUG
976968                 if (idebug)
 977969                         printf("instk((%p, %o,%p,%p, %lld)\n",
 978970                             p, t, d, sue, (long long)off);
<>979 -# endif
  971+#endif
980972 
 981973                 /* save information on the stack */
 982974                 sp = tmpalloc(sizeof(struct instk));
     
 !
10131005                         ++d;
 10141006                         continue;
 10151007                 } else if (t == STRTY || t == UNIONTY) {
<>1016 -                        if (pstk->in_sue == 0) {
  1008+                        if (pstk->in_sue == 0) { /* XXX lite 4.4 */
10171009                                 uerror("can't initialize undefined %s",
 10181010                                     t == STRTY ? "structure" : "union");
 10191011                                 iclass = -1;
     
 !
11521144         union dimfun *d, *d1;
 11531145         int n;
 11541146 
<>1155 -# ifndef BUG1
  1147+#ifdef PCC_DEBUG
11561148         if (idebug)
 11571149                 printf("endinit(), inoff = %lld\n", (long long)inoff);
<>1158 -# endif
  1150+#endif
11591151 
 11601152         switch( iclass ){
 11611153 
 11621154         case EXTERN:
 11631155         case AUTO:
 11641156         case REGISTER:
<>1165 -        case -1:
  1157+        case -1:        /* XXX 4.4 */
11661158                 return;
 11671159                 }
 11681160 
     
 !
11891181                 if (n == 0)
 11901182                         werror("empty array declaration");
 11911183                 d->ddim = n;
<>1192 -                if (d1->ddim == 0) {
 1193 -                        FIXDEF(pstk->in_sym);
 1194 -                }
11951184         }
 11961185 
 11971186         else if (t == STRTY || t == UNIONTY) {
     
 !
12151204  * stolen from endinit()
 12161205  */
 12171206 void
<>1218 -fixinit(void)
  1207+fixinit(void)   /* XXX 4.4 hela fixinit */
12191208 {
 12201209         while (pstk->in_prev)
 12211210                 pstk = pstk->in_prev;
     
 !
12611250 
 12621251         if( p == NIL ) return/* for throwing away strings that have been turned into lists */
 12631252 
<>1264 -        if( ifull ){
  1253+        if( ifull ){    /* XXX 4.4 */
12651254                 uerror( "too many initializers" );
 12661255                 iclass = -1;
 12671256                 goto leave;
     
 !
12711260                 goto leave;
 12721261                 }
 12731262 
<>1274 -# ifndef BUG1
  1263+#ifdef PCC_DEBUG
12751264         if (idebug > 1)
 12761265                 printf("doinit(%p)\n", p);
<>1277 -# endif
  1266+#endif
12781267 
 12791268         t = pstk->in_t/* type required */
 12801269         d = pstk->in_df;
     
 !
13011290         p->n_op = INIT;
 13021291 
 13031292         if( sz < SZINT ){ /* special case: bit fields, etc. */
<>1304 -                if (o != ICON || p->n_left->n_sp != NULL)
  1293+                if (o != ICON || p->n_left->n_sp != NULL) /* XXX 4.4 */
13051294                         uerror( "illegal initialization" );
 13061295                 else
 13071296                         incode( p->n_left, sz );
 13081297         } else if( o == FCON ){
 13091298                 fincode( p->n_left->n_fcon, sz );
<>1310 -        } else if( o == DCON ){
  1299+        } else if( o == DCON ){ /* XXX 4.4 */
13111300                 fincode( p->n_left->n_dcon, sz );
 13121301         } else {
 13131302                 p = optim(p);
<>1314 -                if( p->n_left->n_op != ICON )
  1303+                if( p->n_left->n_op != ICON )   /* XXX 4.4 */
13151304                         uerror( "illegal initialization" );
 13161305                 else
 13171306                         cinit( p, sz );
     
 !
13621351                         cerror("gotscal");
 13631352 
 13641353         }
<>1365 -        ifull = 1;
  1354+        ifull = 1;      /* XXX 4.4 */
13661355 }
 13671356 
 13681357 /*
     
 !
14041393 void
 14051394 irbrace()
 14061395 {
<>1407 -# ifndef BUG1
  1396+#ifdef PCC_DEBUG
14081397         if (idebug)
 14091398                 printf( "irbrace(): lparam = %p on entry\n", lparam);
<>1410 -# endif
  1399+#endif
14111400 
 14121401         if (ibseen) {
 14131402                 --ibseen;
     
 !
14261415         }
 14271416 
 14281417         /* these right braces match ignored left braces: throw out */
<>1429 -        ifull = 1;
  1418+        ifull = 1;      /* XXX 4.4 */
14301419 }
 14311420 
 14321421 /*
     
 !
14411430 
 14421431         off = *poff;
 14431432         SETOFF(off, alignment);
<>1444 -        if ((offsz-off) <  size) {
  1433+        if ((offsz-off) <  size) {      /* XXX 4.4 */
14451434                 if (instruct != INSTRUCT)
 14461435                         cerror("too many local variables");
 14471436                 else
     
 !
14651454         tsz = tsize(p->stype, p->sdf, p->ssue);
 14661455 #ifdef BACKAUTO
 14671456         if (p->sclass == AUTO) {
<>1468 -                if ((offsz-off) < tsz)
  1457+                if ((offsz-off) < tsz)  /* XXX 4.4 */
14691458                         cerror("too many local variables");
 14701459                 noff = off + tsz;
 14711460                 SETOFF(noff, al);
     
 !
14841473 
 14851474         } else
 14861475 #endif
<>1487 -        if (p->sclass == PARAM && (tsz < SZINT)) {
  1476+        if (p->sclass == PARAM && (tsz < SZINT)) {      /* XXX 4.4 */
14881477                 off = upoff(SZINT, ALINT, &noff);
 14891478 #ifndef RTOLBYTES
 14901479                 off = noff - tsz;
     
 !
16491638 
 16501639         if( strucoff%al + w > sz ) SETOFF( strucoff, al );
 16511640         if( new < 0 ) {
<>1652 -                if( (offsz-strucoff) < w )
  1641+                if( (offsz-strucoff) < w )      /* XXX 4.4 */
16531642                         cerror("structure too large");
 16541643                 strucoff += w/* we know it will fit */
 16551644                 return(0);
     
 !
16911680                                 commflag = 1;
 16921681                 }
 16931682         }
<>1694 -#ifdef LCOMM
  1683+#ifdef LCOMM    /* XXX 4.4 */
16951684         /* hack so stab will come out as LCSYM rather than STSYM */
 16961685         if (class == STATIC) {
 16971686                 extern int stabLCSYM;
     
 !
17021691         defid(p, class);
 17031692 
 17041693         /* if an array is not initialized, no empty dimension */
<>1705 -        if (class != EXTERN && class != TYPEDEF &&
  1694+        if (class != EXTERN && class != TYPEDEF &&      /* XXX 4.4 */
17061695             ISARY(p->n_type) && p->n_df->ddim == 0)
 17071696                 uerror("null storage definition");
 17081697 
<>1709 -#ifndef LCOMM
  1698+#ifndef LCOMM   /* XXX 4.4 */
17101699         if (class==EXTDEF || class==STATIC)
 17111700 #else
 17121701         if (class==STATIC) {
     
 !
18461835         return mkty(INT, 0, 0);
 18471836 }
 18481837 
<>1849 -static struct tylnk {
  1838+struct tylnk {
18501839         struct tylnk *next;
 18511840         union dimfun df;
<>1852 -} tylnk, *tylkp;
 1853 -static int ntdim;
  1841+};
18541842 
<> 1843+static void tyreduce(NODE *p, struct tylnk **, int *);
  1844+
18551845 static void
<>1856 -tylkadd(union dimfun dim)
  1846+tylkadd(union dimfun dim, struct tylnk **tylkp, int *ntdim)
18571847 {
<>1858 -        tylkp->next = tmpalloc(sizeof(struct tylnk));
 1859 -        tylkp = tylkp->next;
 1860 -        tylkp->next = NULL;
 1861 -        tylkp->df = dim;
 1862 -        ntdim++;
  1848+        (*tylkp)->next = tmpalloc(sizeof(struct tylnk));
  1849+        *tylkp = (*tylkp)->next;
  1850+        (*tylkp)->next = NULL;
  1851+        (*tylkp)->df = dim;
  1852+        (*ntdim)++;
18631853 }
 18641854 
 18651855 /* merge type typ with identifier idp  */
 18661856 NODE *
 18671857 tymerge(NODE *typ, NODE *idp)
 18681858 {
 18691859         union dimfun *j;
<>1870 -        struct tylnk *base;
  1860+        struct tylnk *base, tylnk, *tylkp;
18711861         unsigned int t;
<>1872 -        int i;
  1862+        int ntdim, i;
18731863 
 18741864         if (typ->n_op != TYPE)
 18751865                 cerror("tymerge: arg 1");
 18761866         if (idp == NIL)
 18771867                 return(NIL);
 18781868 
<>1879 -# ifndef BUG1
  1869+#ifdef PCC_DEBUG
18801870         if (ddebug > 2)
 18811871                 fwalk(idp, eprint, 0);
<>1882 -# endif
  1872+#endif
18831873 
 18841874         idp->n_type = typ->n_type;
 18851875 
 18861876         tylkp = &tylnk;
 18871877         tylkp->next = NULL;
 18881878         ntdim = 0;
 18891879 
<>1890 -        tyreduce(idp);
  1880+        tyreduce(idp, &tylkp, &ntdim);
18911881         idp->n_sue = typ->n_sue;
 18921882 
 18931883         for (t = typ->n_type, j = typ->n_df; t&TMASK; t = DECREF(t))
 18941884                 if (ISARY(t) || ISFTN(t))
<>1895 -                        tylkadd(*j++);
  1885+                        tylkadd(*j++, &tylkp, &ntdim);
18961886 
 18971887         if (ntdim) {
 18981888                 union dimfun *a = permalloc(sizeof(union dimfun) * ntdim);
     
 !
19191909  * the type is build top down, the dimensions bottom up
 19201910  */
 19211911 void
<>1922 -tyreduce(NODE *p)
  1912+tyreduce(NODE *p, struct tylnk **tylkp, int *ntdim)
19231913 {
 19241914         union dimfun dim;
 19251915         NODE *q;
     
 !
19591949         }
 19601950 
 19611951         p->n_left->n_type = t;
<>1962 -        tyreduce(p->n_left);
  1952+        tyreduce(p->n_left, tylkp, ntdim);
19631953 
 19641954         if (o == LB || o == (UNARY CALL))
<>1965 -                tylkadd(dim);
  1955+                tylkadd(dim, tylkp, ntdim);
19661956         if (o == RB) {
 19671957                 dim.ddim = -1;
<>1968 -                tylkadd(dim);
  1958+                tylkadd(dim, tylkp, ntdim);
19691959                 arrstk[arrstkp++] = q;
 19701960         }
 19711961 
     
 !
19971987                 }
 19981988 
 19991989         /* detect function arguments, watching out for structure declarations */
<>2000 -        /* for example, beware of f(x) struct { int a[10]; } *x; { ... } */
 2001 -        /* the danger is that "a" will be converted to a pointer */
20021990 
 20031991         if( class==SNULL && blevel==1 && !(instruct&(INSTRUCT|INUNION)) )
 20041992                 class = PARAM;
     
 !
20081996                 else if (ISARY(type)) {
 20091997                         ++p->n_df;
 20101998                         type += (PTR-ARY);
<>2011 -                } else if (ISFTN(type)) {
  1999+                } else if (ISFTN(type)) {       /* XXX 4.4 */
20122000                         werror("a function is declared as an argument");
 20132001                         type = INCREF(type);
 20142002                 }
     
 !
21152103                                 uerror( "fortran function has wrong type" );
 21162104                                 }
 21172105                         }
<>2118 -        case EXTERN:
 2119 -        case STATIC:
 2120 -        case EXTDEF:
 2121 -        case TYPEDEF:
 2122 -        case USTATIC:
 2123 -                if( blevel == 1 ){
  2106+        case EXTERN:    /* XXX 4.4 */
  2107+        case STATIC:    /* XXX 4.4 */
  2108+        case EXTDEF:    /* XXX 4.4 */
  2109+        case TYPEDEF:   /* XXX 4.4 */
  2110+        case USTATIC:   /* XXX 4.4 */
  2111+                if( blevel == 1 ){      /* XXX 4.4 */
21242112                         uerror( "illegal USTATIC class" );
<>2125 -                        return( PARAM );
  2113+                        return( PARAM );        /* XXX 4.4 */
<_21262114                         }
 21272115         case STNAME:
 21282116         case UNAME:
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-10-01 08:05 +0200