Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.192
 
1.193
 
MAIN:ragge:20080129215030
 
pftn.c
_>7373 
 7474 struct symtab *spname;
 7575 struct symtab *cftnsp;
<>76 -static int strunem;             /* currently parsed member type */
7776 int arglistcnt, dimfuncnt;      /* statistics */
 7877 int symtabcnt, suedefcnt;       /* statistics */
 7978 int autooff,            /* the next unused automatic offset */
     
 !
9796 /*
 9897  * Linked list stack while reading in structs.
 9998  */
<>100 -struct rstack {
  99+static struct rstack {
101100         struct  rstack *rnext;
 102101         int     rinstruct;
<>103 -        int     rclass;
104102         int     rstrucoff;
 105103         struct  params *rlparam;
 106104         struct  symtab *rsym;
<>107 -};
  105+} *rpole;
108106 
 109107 /*
 110108  * Linked list for parameter (and struct elements) declaration.
     
 !
192190                                 uerror("declared argument %s missing",
 193191                                     p->sname );
 194192                 case MOS:
<>195 -                case STNAME:
196193                 case MOU:
<>197 -                case UNAME:
198194                 case TYPEDEF:
 199195                 case PARAM:
 200196                         ;
     
 !
244240 #endif
 245241 
 246242         /* check that redeclarations are to the same structure */
<>247 -        if ((temp == STRTY || temp == UNIONTY) &&
 248 -            p->ssue != q->n_sue &&
 249 -            class != STNAME && class != UNAME) {
  243+        if ((temp == STRTY || temp == UNIONTY) && p->ssue != q->n_sue) {
250244                 goto mismatch;
 251245         }
 252246 
     
 !
257251                 printf("        previous class: %s\n", scnames(scl));
 258252 #endif
 259253 
<>260 -        if (class&FIELD) {
 261 -                /* redefinition */
 262 -                if (!falloc(p, class&FLDSIZ, 1, NIL)) {
 263 -                        /* successful allocation */
 264 -                        ssave(p);
 265 -                        return;
 266 -                }
 267 -                /* blew it: resume at end of switch... */
 268 -        } else switch(class) {
  254+        if (class & FIELD)
  255+                return;
  256+        switch(class) {
269257 
 270258         case EXTERN:
 271259                 switch( scl ){
     
 !
314302 
 315303         case MOU:
 316304         case MOS:
<>317 -                if (scl == class) {
 318 -                        if (oalloc(p, &strucoff))
 319 -                                break;
 320 -                        if (class == MOU)
 321 -                                strucoff = 0;
 322 -                        ssave(p);
 323 -                        return;
 324 -                }
 325 -                break;
  305+                return;
326306 
 327307         case EXTDEF:
 328308                 switch (scl) {
     
 !
335315                 }
 336316                 break;
 337317 
<>338 -        case STNAME:
 339 -        case UNAME:
 340 -                if (scl != class)
 341 -                        break;
 342 -                if (p->ssue->suesize == 0)
 343 -                        return/* previous entry just a mention */
 344 -                break;
 345 -
346318         case AUTO:
 347319         case REGISTER:
 348320                 if (blevel == slev)
     
 !
377349         p->sclass = class;
 378350         p->slevel = blevel;
 379351         p->soffset = NOOFFSET;
<>380 -        if (class == STNAME || class == UNAME) {
 381 -                p->ssue = permalloc(sizeof(struct suedef));
 382 -                suedefcnt++;
 383 -                p->ssue->suesize = 0;
 384 -                p->ssue->suelem = NULL;
 385 -                p->ssue->suealign = ALSTRUCT;
 386 -        } else {
 387 -                if (q->n_sue == NULL)
 388 -                        cerror("q->n_sue == NULL");
 389 -                p->ssue = q->n_sue;
 390 -#if 0
 391 -                switch (BTYPE(type)) {
 392 -                case STRTY:
 393 -                case UNIONTY:
 394 -                        p->ssue = q->n_sue;
 395 -                        break;
 396 -                default:
 397 -                        p->ssue = MKSUE(BTYPE(type));
 398 -                }
 399 -#endif
 400 -        }
  352+        if (q->n_sue == NULL)
  353+                cerror("q->n_sue == NULL");
  354+        p->ssue = q->n_sue;
401355 
 402356         /* copy dimensions */
 403357         p->sdf = q->n_df;
     
 !
469423         p->next = NULL;
 470424         p->sym = sym;
 471425 
<>472 -        if (lparam == NULL) {
 473 -                p->prev = (struct params *)&lpole;
  426+        if ((p->prev = lparam) == NULL)
474427                 lpole = p;
<>475 -        } else {
  428+        else
476429                 lparam->next = p;
<>477 -                p->prev = lparam;
 478 -        }
479430         lparam = p;
 480431 }
 481432 
     
 !
545496                 parr = tmpalloc(sizeof(struct symtab *) * nparams);
 546497 
 547498         if (nparams)
<>548 -            for (a = lparam, i = 0; a != NULL && a != (struct params *)&lpole;
 549 -            a = a->prev) {
 550 -
  499+            for (a = lparam, i = 0; a != NULL; a = a->prev) {
551500                 p = a->sym;
 552501                 parr[i++] = p;
 553502                 if (p == NULL) {
     
 !
606555 }
 607556 
 608557 /*
<>609 - * reference to a structure or union, with no definition
 610 - */
 611 -NODE *
 612 -rstruct(char *tag, int soru)
 613 -{
 614 -        struct symtab *p;
 615 -        NODE *q;
 616 -
 617 -        p = (struct symtab *)lookup(tag, STAGNAME);
 618 -        switch (p->stype) {
 619 -
 620 -        case UNDEF:
 621 -        def:
 622 -                q = block(NAME, NIL, NIL, 0, 0, 0);
 623 -                q->n_sp = p;
 624 -                q->n_type = (soru&INSTRUCT) ? STRTY :
 625 -                    ((soru&INUNION) ? UNIONTY : 0);
 626 -                defid(q, (soru&INSTRUCT) ? STNAME :
 627 -                    ((soru&INUNION) ? UNAME : 0));
 628 -                nfree(q);
 629 -                break;
 630 -
 631 -        case STRTY:
 632 -                if (soru & INSTRUCT)
 633 -                        break;
 634 -                goto def;
 635 -
 636 -        case UNIONTY:
 637 -                if (soru & INUNION)
 638 -                        break;
 639 -                goto def;
 640 -
 641 -        }
 642 -        q = mkty(p->stype, 0, p->ssue);
 643 -        q->n_sue = p->ssue;
 644 -        return q;
 645 -}
 646 -
 647 -/*
648558  * Declare a struct/union/enum tag.
 649559  * If not found, create a new tag with UNDEF type.
 650560  */
     
 !
653563 {
 654564         struct symtab *sp;
 655565 
<>656 -        sp = lookup(name, STAGNAME);
 657 -        if (sp->ssue == NULL)
 658 -                sp->ssue = permalloc(sizeof(struct suedef));
 659 -        if (sp->sclass == SNULL) {
  566+        if ((sp = lookup(name, STAGNAME))->ssue == NULL) {
660567                 /* New tag */
<> 568+                sp->ssue = permalloc(sizeof(struct suedef));
  569+                sp->ssue->suesize = 0;
  570+                sp->ssue->suelem = NULL;
  571+                sp->ssue->suealign = ALSTRUCT;
661572                 sp->sclass = class;
<>662 -        } else if (sp->slevel < blevel) {
 663 -                /* declared at different block level, hide it */
 664 -                sp = hide(sp);
 665 -                sp->sclass = class;
666573         } else if (sp->sclass != class) {
 667574                 /* redeclaration of tag */
 668575                 uerror("tag %s redeclared", name);
 669576         }
 670577         return sp;
 671578 }
 672579 
<> 580+/*
  581+ * reference to a structure or union, with no definition
  582+ */
  583+NODE *
  584+rstruct(char *tag, int soru)
  585+{
  586+        struct symtab *sp;
  587+        TWORD t;
  588+
  589+        sp = deftag(tag, soru);
  590+        t = sp->stype != UNDEF ? sp->stype : soru == STNAME ? STRTY : UNIONTY;
  591+        return mkty(t, 0, sp->ssue);
  592+}
  593+
673594 static int enumlow, enumhigh;
 674595 int enummer;
 675596 
     
 !
769690 bstruct(char *name, int soru)
 770691 {
 771692         struct rstack *r;
<>772 -        struct symtab *s;
 773 -        NODE *q;
  693+        struct symtab *sp;
774694 
<>775 -        if (name != NULL)
 776 -                s = lookup(name, STAGNAME);
 777 -        else
 778 -                s = NULL;
  695+        if (name != NULL) {
  696+                sp = deftag(name, soru);
  697+                if (sp->stype != UNDEF)
  698+                        uerror("%s redeclared", name);
  699+        } else
  700+                sp = NULL;
779701 
<> 702+
780703         r = tmpalloc(sizeof(struct rstack));
 781704         r->rinstruct = instruct;
<>782 -        r->rclass = strunem;
783705         r->rstrucoff = strucoff;
<> 706+        r->rsym = sp;
  707+        r->rnext = rpole;
  708+        rpole = r;
784709 
 785710         strucoff = 0;
 786711         instruct = soru;
<>787 -        q = block(NAME, NIL, NIL, 0, 0, 0);
 788 -        q->n_sp = s;
 789 -        if (instruct==INSTRUCT) {
 790 -                strunem = MOS;
 791 -                q->n_type = STRTY;
 792 -                if (s != NULL)
 793 -                        defid(q, STNAME);
 794 -        } else if(instruct == INUNION) {
 795 -                strunem = MOU;
 796 -                q->n_type = UNIONTY;
 797 -                if (s != NULL)
 798 -                        defid(q, UNAME);
 799 -        } else {
 800 -                cerror("bstruct");
 801 -        }
 802 -        r->rsym = q->n_sp;
 803 -        r->rlparam = lparam;
 804 -        nfree(q);
  712+        if ((r->rlparam = lparam) == NULL)
  713+                lpole = NULL;
805714 
 806715         return r;
 807716 }
     
 !
832741         if (ddebug)
 833742                 printf("dclstruct(%s)\n", r->rsym ? r->rsym->sname : "??");
 834743 #endif
<>835 -        temp = (instruct&INSTRUCT)?STRTY:((instruct&INUNION)?UNIONTY:0);
  744+        temp = instruct == STNAME ? STRTY : instruct == UNAME ? UNIONTY : 0;
836745         instruct = r->rinstruct;
<>837 -        strunem = r->rclass;
838746         al = ALSTRUCT;
 839747 
 840748         high = low = 0;
     
 !
911819         strucoff = r->rstrucoff;
 912820         if ((lparam = r->rlparam) != NULL)
 913821                 lparam->next = NULL;
<> 822+        else
  823+                lpole = NULL;
  824+        rpole = r->rnext;
914825         n = mkty(temp, 0, sue);
 915826         return n;
 916827 }
 917828 
 918829 /*
<> 830+ * Add a new member to the current struct or union being declared.
  831+ */
  832+void
  833+soumemb(NODE *n, char *name, int class)
  834+{
  835+        struct params *l;
  836+ 
  837+        if (rpole == NULL || !instruct)
  838+                cerror("soumemb");
  839+        if ((l = rpole->rlparam) == NULL)
  840+                l = lpole;
  841+        else
  842+                l = l->next;
  843+ 
  844+        for (; l != NULL; l = l->next) {
  845+                if (l->sym->sname == name) {
  846+                        uerror("redeclaration of %s", name);
  847+                        return;
  848+                }
  849+        }
  850+        n->n_sp = getsymtab(name, SMOSNAME);
  851+        defid(n, class);
  852+}
  853+ 
  854+
  855+
  856+/*
919857  * error printing routine in parser
 920858  */
 921859 void yyerror(char *s);
     
 !
15201458         type = class = qual = sig = uns = 0;
 15211459         saved = NIL;
 15221460 
<>1523 -        if (strunem != 0)
 1524 -                class = strunem;
  1461+        if (instruct != 0)
  1462+                class = instruct == STNAME ? MOS : MOU;
15251463 
 15261464         for (q = p; p; p = p->n_left) {
 15271465                 switch (p->n_op) {
     
 !
24262364 {
 24272365         /* first, fix null class */
 24282366         if (class == SNULL) {
<>2429 -                if (instruct&INSTRUCT)
  2367+                if (instruct == STNAME)
24302368                         class = MOS;
<>2431 -                else if (instruct&INUNION)
  2369+                else if (instruct == UNAME)
24322370                         class = MOU;
 24332371                 else if (blevel == 0)
 24342372                         class = EXTDEF;
     
 !
24552393                         }
 24562394                 }
 24572395 
<>2458 -        if( class&FIELD ){
 2459 -                if( !(instruct&INSTRUCT) ) uerror( "illegal use of field" );
 2460 -                return( class );
 2461 -                }
  2396+        if (class & FIELD) {
  2397+                if (instruct != STNAME)
  2398+                        uerror("illegal use of field");
  2399+                return(class);
  2400+        }
24622401 
<>2463 -        switch( class ){
  2402+        switch (class) {
24642403 
 24652404         case MOU:
<>2466 -                if( !(instruct&INUNION) ) uerror( "illegal MOU class" );
 2467 -                return( class );
  2405+                if (instruct != UNAME)
  2406+                        uerror("illegal MOU class");
  2407+                return(class);
24682408 
 24692409         case MOS:
<>2470 -                if( !(instruct&INSTRUCT) ) uerror( "illegal MOS class" );
 2471 -                return( class );
  2410+                if (instruct != STNAME)
  2411+                        uerror("illegal MOS class");
  2412+                return(class);
24722413 
 24732414         case REGISTER:
 24742415                 if (blevel == 0)
<>2475 -                        uerror( "illegal register declaration" );
  2416+                        uerror("illegal register declaration");
24762417                 if (blevel == 1)
 24772418                         return(PARAM);
 24782419                 else
     
 !
24942435                                 uerror( "fortran function has wrong type" );
 24952436                                 }
 24962437                         }
<>2497 -        case STNAME:
 2498 -        case UNAME:
<_24992438         case EXTERN:
 25002439         case STATIC:
 25012440         case EXTDEF:
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-23 01:54 +0100