Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.55
 
1.56
 
MAIN:ragge:20030616222950
 
pftn.c
_>126126         }
 127127 #endif
 128128 
<>129 -        if (stp == FTN && p->sclass == SNULL)   /* XXX 4.4 */
 130 -                goto enter;
 131 -
 132 -        if (blevel==1 && stp!=FARG)
  129+        if (blevel == 1) {
133130                 switch (class) {
 134131                 default:
 135132                         if (!(class&FIELD))
<>136 -                                uerror( "declared argument %s is missing",
  133+                                uerror("declared argument %s missing",
137134                                     p->sname );
 138135                 case MOS:
 139136                 case STNAME:
     
 !
143140                 case ENAME:
 144141                 case TYPEDEF:
 145142                         ;
<> 143+                }
146144         }
<>147 -        if (stp == UNDEF|| stp == FARG/* XXX 4.4 */
 148 -                goto enter;
149145 
<> 146+        if (stp == UNDEF)
  147+                goto enter; /* New symbol */
  148+
150149         if (type != stp)
 151150                 goto mismatch;
 152151 
     
 !
300299                         return/* previous entry just a mention */
 301300                 break;
 302301 
<>303 -        case PARAM:
304302         case AUTO:
 305303         case REGISTER:
 306304                 ;  /* mismatch.. */
     
 !
326324         if(ddebug)
 327325                 printf("        new entry made\n");
 328326 #endif
<>329 -        if (type == UNDEF)      /* XXX 4.4 */
 330 -                uerror("void type for %s", p->sname);
331327         p->stype = type;
 332328         p->sclass = class;
 333329         p->slevel = blevel;
     
 !
402398                 break;
 403399         }
 404400 
<>405 -        if (p->slevel > 0 && (p->sflags & SMASK) == SNORMAL)
 406 -                schedremove(p);
 407 -
408401         /* user-supplied routine to fix up new definitions */
 409402         FIXDEF(p);
 410403 
     
 !
474467 {
 475468         struct params *a;
 476469         struct symtab *p, **parr;
<>477 -        NODE *q;
478470         int i;
 479471 
<> 472+        blevel = 1;
480473         argoff = ARGINIT;
 481474 #ifdef PCC_DEBUG
 482475         if (ddebug > 2)
 483476                 printf("dclargs()\n");
 484477 #endif
 485478 
<>486 -        /* Generate a list for bfcode() */
  479+        /*
  480+         * Generate a list for bfcode().
  481+         * Parameters were pushed in reverse order.
  482+         */
487483         parr = tmpalloc(sizeof(struct symtab *) * nparams);
<> 484+
488485         for (a = lparam, i = 0; a != NULL && a != (struct params *)&lpole;
 489486             a = a->prev) {
<>490 -                p = parr[i++] = a->sym;
  487+
  488+                /*
  489+                 * Enter function args into the symbol table.
  490+                 */
  491+                p = lookup(a->sym->sname, 0);
  492+                if (p->stype != UNDEF)
  493+                        p = hide(p);
  494+
  495+                p->stype = a->sym->stype;
  496+                p->soffset = NOOFFSET;
  497+                p->sclass = PARAM;
  498+                p->sdf = a->sym->sdf;
  499+                p->ssue = a->sym->ssue;
  500+
  501+                parr[i++] = p;
491502 #ifdef PCC_DEBUG
 492503                 if (ddebug > 2) {       /* XXX 4.4 */
 493504                         printf("\t%s (%p) ",p->sname, p);
 494505                         tprint(p->stype);
 495506                         printf("\n");
 496507                 }
 497508 #endif
<>498 -                if (p->stype == FARG) {
 499 -                        q = block(FREE, NIL, NIL, INT, 0, MKSUE(INT));
 500 -                        q->n_sp = p;
 501 -                        defid(q, PARAM);
 502 -                }
 503 -/* XXX 4.4 */           FIXARG(p); /* local arg hook, eg. for sym. debugger */
 504 -          /* always set aside space, even for register arguments */
  509+                /* always set aside space, even for register arguments */
505510                 oalloc(p, &argoff);
 506511         }
 507512         cendarg();
     
 !
741746         ftnend();
 742747 }
 743748 
<>744 -void    /* XXX 4.4  hela funktionen */
 745 -ftnarg(char *name)
  749+/*
  750+ * p is top of type list given to tymerge later.
  751+ * Find correct CALL node and declare parameters from there.
  752+ */
  753+void
  754+ftnarg(NODE *p)
746755 {
<>747 -        struct symtab *s = lookup(name, 0);
  756+        NODE *q;
  757+        struct symtab *s;
748758 
<>749 -        blevel = 1; /* Always */
 750 -
 751 -        switch (s->stype) {
 752 -        case UNDEF:
 753 -                /* this parameter, entered at scan */
 754 -                break;
 755 -        case FARG:
 756 -                uerror("redeclaration of formal parameter, %s", s->sname);
 757 -                /* fall thru */
 758 -        case FTN:
 759 -                /* the name of this function matches parm */
 760 -                /* fall thru */
 761 -        default:
 762 -                s = hide(s);
 763 -                break;
 764 -        case TNULL:
 765 -                /* unused entry, fill it */
 766 -                ;
  759+#ifdef PCC_DEBUG
  760+        if (ddebug > 2)
  761+                printf("ftnarg(%p)\n", p);
  762+#endif
  763+        /*
  764+         * Enter argument into param stack.
  765+         * Do not declare parameters until later (in dclargs);
  766+         * the function must be declared first.
  767+         * put it on the param stack in reverse order, due to the
  768+         * nature of the stack it will be reclaimed correct.
  769+         */
  770+        for (; p->n_op != NAME; p = p->n_left) {
  771+                if (p->n_op == (UNARY CALL) && p->n_left->n_op == NAME)
  772+                        return/* Nothing to enter */
  773+                if (p->n_op == CALL && p->n_left->n_op == NAME)
  774+                        break;
767775         }
<>768 -        s->stype = FARG;
 769 -        s->sclass = PARAM;
770776 
<> 777+        p = p->n_right;
  778+
  779+        while (p->n_op == CM) {
  780+                q = p->n_right;
  781+                if (q->n_op != ELLIPSIS) {
  782+                        s = getsymtab((char *)q->n_sp, STEMP);
  783+                        s->stype = q->n_type;
  784+                        s->sdf = q->n_df;
  785+                        s->ssue = q->n_sue;
  786+                        ssave(s);
  787+                        nparams++;
  788+#ifdef PCC_DEBUG
  789+                        if (ddebug > 2)
  790+                                printf("        saving sym %s (%p) from (%p)\n",
  791+                                    s->sname, s, q);
  792+#endif
  793+                }
  794+                p = p->n_left;
  795+        }
  796+        s = getsymtab((char *)p->n_sp, STEMP);
  797+        s->stype = p->n_type;
  798+        s->sdf = p->n_df;
  799+        s->ssue = p->n_sue;
771800         ssave(s);
 772801         nparams++;
<> 802+#ifdef PCC_DEBUG
  803+        if (ddebug > 2)
  804+                printf("        saving sym %s (%p) from (%p)\n",
  805+                    s->sname, s, p);
  806+#endif
773807 }
 774808 
 775809 /*
     
 !
18661900 
 18671901 static void tyreduce(NODE *p, struct tylnk **, int *);
 18681902 
<> 1903+#define TELLIPSIS INCREF(INCREF(MOETY))
  1904+
18691905 static void
 18701906 tylkadd(union dimfun dim, struct tylnk **tylkp, int *ntdim)
 18711907 {
     
 !
18911927                 return(NIL);
 18921928 
 18931929 #ifdef PCC_DEBUG
<>1894 -        if (ddebug > 2)
  1930+        if (ddebug > 2) {
  1931+                printf("tymerge(%p,%p)\n", typ, idp);
  1932+                fwalk(typ, eprint, 0);
18951933                 fwalk(idp, eprint, 0);
<> 1934+        }
18961935 #endif
 18971936 
 18981937         idp->n_type = typ->n_type;
     
 !
19752014 
 19762015         /* Third: Create actual arg list */
 19772016         for (k = 0, j = i; j >= 0; j--) {
<> 2017+                if (ap[j]->n_op == ELLIPSIS) {
  2018+                        al[k++].type = TELLIPSIS;
  2019+                        ap[j]->n_op = ICON; /* for tfree() */
  2020+                        continue;
  2021+                }
19782022                 ty = ap[j]->n_type;
 19792023                 al[k++].type = ty;
 19802024                 if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY ||
     
 !
19862030                         al[k++].df = ap[j]->n_df;
 19872031         }
 19882032         al[k++].type = TNULL;
<> 2033+        tfree(n);
19892034         return al;
 19902035 }
 19912036 
     
 !
20722117 
 20732118         /* detect function arguments, watching out for structure declarations */
 20742119 
<>2075 -        if( class==SNULL && blevel==1 && !(instruct&(INSTRUCT|INUNION)) )
 2076 -                class = PARAM;
  2120+#if 0
20772121         if (class == PARAM || (class == REGISTER && blevel == 1)) {
 20782122                 if (type == FLOAT)
 20792123                         type = DOUBLE;
     
 !
20862130                 }
 20872131 
 20882132         }
<> 2133+#endif
20892134 
 20902135         if (instruct && ISFTN(type)) {
 20912136                 uerror("function illegal in structure or union");
     
 !
21142159 fixclass(int class, TWORD type)
 21152160 {
 21162161         /* first, fix null class */
<>2117 -        if( class == SNULL ){
 2118 -                if( instruct&INSTRUCT ) class = MOS;
 2119 -                else if( instruct&INUNION ) class = MOU;
 2120 -                else if( blevel == 0 ) class = EXTDEF;
 2121 -                else if( blevel == 1 ) class = PARAM;
 2122 -                else class = AUTO;
  2162+        if (class == SNULL) {
  2163+                if (instruct&INSTRUCT)
  2164+                        class = MOS;
  2165+                else if (instruct&INUNION)
  2166+                        class = MOU;
  2167+                else if (blevel == 0)
  2168+                        class = EXTDEF;
  2169+#if 0
  2170+                else if (blevel == 1)
  2171+                        class = PARAM;
  2172+#endif
  2173+                else
  2174+                        class = AUTO;
  2175+        }
21232176 
<>2124 -                }
 2125 -
21262177         /* now, do general checking */
 21272178 
 21282179         if( ISFTN( type ) ){
     
 !
21712222                 if( blevel < 2 ) uerror( "illegal ULABEL class" );
 21722223                 return( class );
 21732224 
<>2174 -        case PARAM:
 2175 -                if( blevel != 1 ) uerror( "illegal PARAM class" );
 2176 -                return( class );
 2177 -
21782225         case UFORTRAN:
 21792226         case FORTRAN:
 21802227 # ifdef NOFORTRAN
<>2181 -                        NOFORTRAN;    /* a condition which can regulate the FORTRAN usage */
  2228+                NOFORTRAN;    /* a condition which can regulate the FORTRAN usage */
21822229 # endif
 21832230                 if( !ISFTN(type) ) uerror( "fortran declaration must apply to function" );
 21842231                 else {
     
 !
21872234                                 uerror( "fortran function has wrong type" );
 21882235                                 }
 21892236                         }
<>2190 -        case EXTERN:    /* XXX 4.4 */
 2191 -        case STATIC:    /* XXX 4.4 */
 2192 -        case EXTDEF:    /* XXX 4.4 */
 2193 -        case TYPEDEF:   /* XXX 4.4 */
 2194 -        case USTATIC:   /* XXX 4.4 */
 2195 -                if( blevel == 1 ){      /* XXX 4.4 */
 2196 -                        uerror( "illegal USTATIC class" );
 2197 -                        return( PARAM );        /* XXX 4.4 */
 2198 -                        }
21992237         case STNAME:
 22002238         case UNAME:
 22012239         case ENAME:
<> 2240+        case EXTERN:
  2241+        case STATIC:
  2242+        case EXTDEF:
  2243+        case TYPEDEF:
  2244+        case USTATIC:
22022245                 return( class );
 22032246 
 22042247         default:
     
 !
22932336         s->sclass = SNULL;
 22942337         s->sflags = flags & SMASK;
 22952338         s->soffset = 0;
<> 2339+        s->slevel = blevel;
<_22962340         s->s_argn = 0;
 22972341         return s;
 22982342 }
FishEye: Open Source License registered to PCC.
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-12-22 13:03 +0100