Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.54
 
1.55
 
MAIN:ragge:20030615212153
 
pftn.c
_>1010 
 1111 struct symtab *spname;
 1212 struct symtab *cftnsp;
<>13 -static int strunem;                     /* currently parsed member */
  13+static int strunem;     /* currently parsed member type */
1414 
 1515 struct params;
 1616 
 1717 /*
<> 18+ * Argument list member info when storing prototypes.
  19+ */
  20+union arglist {
  21+        TWORD type;
  22+        union dimfun *df;
  23+        struct suedef *sue;
  24+};
  25+
  26+/*
1827  * Linked list stack while reading in structs.
 1928  */
 2029 struct rstack {
     
 !
7988         int scl;
 8089         union dimfun *dsym, *ddef;
 8190         int slev, temp;
<>82 -        int changed;    /* XXX 4.4 */
8391 
 8492         if (q == NIL)
 8593                 return/* an error was detected */
     
 !
146154                 /* new scope */
 147155                 goto mismatch;
 148156 
<>149 -        /* test (and possibly adjust) dimensions */
  157+        /*
  158+         * test (and possibly adjust) dimensions.
  159+         * also check that prototypes are correct.
  160+         */
150161         dsym = p->sdf;
 151162         ddef = q->n_df;
<>152 -        changed = 0;    /* XXX 4.4 */
 153 -        for( temp=type; temp&TMASK; temp = DECREF(temp) ){
 154 -                if( ISARY(temp) ){
  163+        for (temp = type; temp & TMASK; temp = DECREF(temp)) {
  164+                if (ISARY(temp)) {
155165                         if (dsym->ddim == 0) {
 156166                                 dsym->ddim = ddef->ddim;
<>157 -                                changed = 1;
158167                         } else if (ddef->ddim != 0 && dsym->ddim!=ddef->ddim) {
 159168                                 goto mismatch;
 160169                         }
 161170                         ++dsym;
 162171                         ++ddef;
<> 172+                } else if (ISFTN(temp)) {
  173+                        union arglist *usym = dsym->dfun;
  174+                        union arglist *udef = ddef->dfun;
  175+                        while (usym->type != TNULL) {
  176+                                TWORD t2 = usym->type;
  177+                                if (usym->type != udef->type)
  178+                                        goto mismatch;
  179+                                while (t2 > BTMASK) {
  180+                                        /* XXX no multilevel checks */
  181+                                        if (ISFTN(t2))
  182+                                                usym++, udef++;
  183+                                        t2 = DECREF(t2);
  184+                                }
  185+                                usym++, udef++;
  186+                        }
  187+                        if (usym->type != udef->type)
  188+                                goto mismatch;
  189+                        dsym++, ddef++;
163190                 }
 164191         }
 165192 
<>166 -        if (changed) {
 167 -                FIXDEF(p);      /* XXX 4.4 */
 168 -        }
 169 -
170193         /* check that redeclarations are to the same structure */
 171194         if ((temp == STRTY || temp == UNIONTY || temp == ENUMTY) &&
 172195             p->ssue != q->n_sue &&
     
 !
285308 
 286309         mismatch:
 287310 
<>288 -        if (blevel > slev && class != EXTERN && class != FORTRAN &&
 289 -            class != UFORTRAN) {
 290 -                p = hide(p);
 291 -                q->n_sp = p;
 292 -                goto enter;
  311+        /*
  312+         * Only allowed for automatic variables.
  313+         */
  314+        if (blevel == slev || class == EXTERN || class == FORTRAN ||
  315+            class == UFORTRAN) {
  316+                uerror("redeclaration of %s", p->sname);
  317+                if (class == EXTDEF && ISFTN(type))
  318+                        cftnsp = p;
  319+                return;
293320         }
<>294 -        uerror("redeclaration of %s", p->sname);
 295 -        if (class==EXTDEF && ISFTN(type))
 296 -                cftnsp = p;
 297 -        return;
  321+        q->n_sp = p = hide(p);
298322 
 299323         enter/* make a new entry */
 300324 
     
 !
19041928 }
 19051929 
 19061930 /*
<> 1931+ * Retrieve all CM-separated argument types, sizes and dimensions and
  1932+ * put them in an array.
  1933+ */
  1934+static union arglist *
  1935+arglist(NODE *n)
  1936+{
  1937+        union arglist *al;
  1938+        NODE *w = n, **ap;
  1939+        int num, cnt, i, j, k;
  1940+        TWORD ty;
  1941+
  1942+        /* First: how much to allocate */
  1943+        for (num = cnt = 0, w = n; w->n_op == CM; w = w->n_left) {
  1944+                cnt++;  /* Number of levels */
  1945+                num++;  /* At least one per step */
  1946+                if (w->n_right->n_op == ELLIPSIS)
  1947+                        continue;
  1948+                ty = w->n_right->n_type;
  1949+                if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY ||
  1950+                    BTYPE(ty) == ENUMTY)
  1951+                        num++;
  1952+                while (ISFTN(ty) == 0 && ISARY(ty) == 0 && ty > BTMASK)
  1953+                        ty = DECREF(ty);
  1954+                if (ty > BTMASK)
  1955+                        num++;
  1956+        }
  1957+        cnt++;
  1958+        ty = w->n_type;
  1959+        if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY ||
  1960+            BTYPE(ty) == ENUMTY)
  1961+                num++;
  1962+        while (ISFTN(ty) == 0 && ISARY(ty) == 0 && ty > BTMASK)
  1963+                ty = DECREF(ty);
  1964+        if (ty > BTMASK)
  1965+                num++;
  1966+        num += 2; /* TEND + last arg type */
  1967+
  1968+        /* Second: Create list to work on */
  1969+        ap = tmpalloc(sizeof(NODE *) * cnt);
  1970+        al = permalloc(sizeof(union arglist) * num);
  1971+
  1972+        for (w = n, i = 0; w->n_op == CM; w = w->n_left)
  1973+                ap[i++] = w->n_right;
  1974+        ap[i] = w;
  1975+
  1976+        /* Third: Create actual arg list */
  1977+        for (k = 0, j = i; j >= 0; j--) {
  1978+                ty = ap[j]->n_type;
  1979+                al[k++].type = ty;
  1980+                if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY ||
  1981+                    BTYPE(ty) == ENUMTY)
  1982+                        al[k++].sue = ap[j]->n_sue;
  1983+                while (ISFTN(ty) == 0 && ISARY(ty) == 0 && ty > BTMASK)
  1984+                        ty = DECREF(ty);
  1985+                if (ty > BTMASK)
  1986+                        al[k++].df = ap[j]->n_df;
  1987+        }
  1988+        al[k++].type = TNULL;
  1989+        return al;
  1990+}
  1991+
  1992+/*
19071993  * build a type, and stash away dimensions,
 19081994  * from a parse tree of the declaration
 19091995  * the type is build top down, the dimensions bottom up
     
 !
19242010 
 19252011         t = INCREF(p->n_type);
 19262012         switch (o) {
<>1927 -#ifdef notyet
19282013         case CALL:
 19292014                 t += (FTN-PTR);
<>1930 -                dim.dfun = ???
  2015+                dim.dfun = arglist(p->n_right);
19312016                 break;
<>1932 -#endif
19332017         case UNARY CALL:
 19342018                 t += (FTN-PTR);
<>1935 -                dim.dfun = NULL; /* XXX */
  2019+                dim.dfun = NULL;
19362020                 break;
 19372021         case LB:
 19382022                 t += (ARY-PTR);
     
 !
19512035         p->n_left->n_type = t;
 19522036         tyreduce(p->n_left, tylkp, ntdim);
 19532037 
<>1954 -        if (o == LB || o == (UNARY CALL))
  2038+        if (o == LB || o == (UNARY CALL) || o == CALL)
<_19552039                 tylkadd(dim, tylkp, ntdim);
 19562040         if (o == RB) {
 19572041                 dim.ddim = -1;
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-21 15:27 +0100