Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.183
 
1.184
 
MAIN:ragge:20071118172457
 
pftn.c
_>8989 
 9090 struct params;
 9191 
<>92 -#define ISSTR(ty) (ty == STRTY || ty == UNIONTY || ty == ENUMTY)
  92+#define ISSTR(ty) (ty == STRTY || ty == UNIONTY)
9393 #define ISSOU(ty) (ty == STRTY || ty == UNIONTY)
 9494 #define MKTY(p, t, d, s) r = talloc(); *r = *p; \
 9595         r = argcast(r, t, d, s); *p = *r; nfree(r);
     
 !
204204                 case STNAME:
 205205                 case MOU:
 206206                 case UNAME:
<>207 -                case MOE:
 208 -                case ENAME:
209207                 case TYPEDEF:
 210208                         ;
 211209                 }
     
 !
254252 #endif
 255253 
 256254         /* check that redeclarations are to the same structure */
<>257 -        if ((temp == STRTY || temp == UNIONTY || temp == ENUMTY) &&
  255+        if ((temp == STRTY || temp == UNIONTY) &&
258256             p->ssue != q->n_sue &&
<>259 -            class != STNAME && class != UNAME && class != ENAME) {
  257+            class != STNAME && class != UNAME) {
260258                 goto mismatch;
 261259         }
 262260 
     
 !
334332                 }
 335333                 break;
 336334 
<>337 -        case MOE:
 338 -                break;
 339 -
340335         case EXTDEF:
 341336                 switch (scl) {
 342337                 case EXTERN:
     
 !
350345 
 351346         case STNAME:
 352347         case UNAME:
<>353 -        case ENAME:
354348                 if (scl != class)
 355349                         break;
 356350                 if (p->ssue->suesize == 0)
     
 !
390384         p->slevel = blevel;
 391385         p->soffset = NOOFFSET;
 392386         p->suse = lineno;
<>393 -        if (class == STNAME || class == UNAME || class == ENAME) {
  387+        if (class == STNAME || class == UNAME) {
394388                 p->ssue = permalloc(sizeof(struct suedef));
 395389                 suedefcnt++;
 396390                 p->ssue->suesize = 0;
 397391                 p->ssue->suelem = NULL;
 398392                 p->ssue->suealign = ALSTRUCT;
 399393         } else {
<> 394+                if (q->n_sue == NULL)
  395+                        cerror("q->n_sue == NULL");
  396+                p->ssue = q->n_sue;
  397+#if 0
400398                 switch (BTYPE(type)) {
 401399                 case STRTY:
 402400                 case UNIONTY:
<>403 -                case ENUMTY:
404401                         p->ssue = q->n_sue;
 405402                         break;
 406403                 default:
 407404                         p->ssue = MKSUE(BTYPE(type));
 408405                 }
<> 406+#endif
409407         }
 410408 
 411409         /* copy dimensions */
     
 !
464462                         strucoff = 0;
 465463                 ssave(p);
 466464                 break;
<>467 -
 468 -        case MOE:
 469 -                p->soffset = strucoff++;
 470 -                ssave(p);
 471 -                break;
 472 -
473465         }
 474466 
 475467 #ifdef STABS
     
 !
656648                 q = block(NAME, NIL, NIL, 0, 0, 0);
 657649                 q->n_sp = p;
 658650                 q->n_type = (soru&INSTRUCT) ? STRTY :
<>659 -                    ((soru&INUNION) ? UNIONTY : ENUMTY);
  651+                    ((soru&INUNION) ? UNIONTY : 0);
660652                 defid(q, (soru&INSTRUCT) ? STNAME :
<>661 -                    ((soru&INUNION) ? UNAME : ENAME));
  653+                    ((soru&INUNION) ? UNAME : 0));
662654                 nfree(q);
 663655                 break;
 664656 
     
 !
672664                         break;
 673665                 goto def;
 674666 
<>675 -        case ENUMTY:
 676 -                if (!(soru&(INUNION|INSTRUCT)))
 677 -                        break;
 678 -                goto def;
 679 -
680667         }
 681668         q = mkty(p->stype, 0, p->ssue);
 682669         q->n_sue = p->ssue;
 683670         return q;
 684671 }
 685672 
<> 673+/*
  674+ * Declare a struct/union/enum tag.
  675+ * If not found, create a new tag with UNDEF type.
  676+ */
  677+static struct symtab *
  678+deftag(char *name, int class)
  679+{
  680+        struct symtab *sp;
  681+
  682+        sp = lookup(name, STAGNAME);
  683+        if (sp->ssue == NULL)
  684+                sp->ssue = permalloc(sizeof(struct suedef));
  685+        if (sp->sclass == SNULL) {
  686+                /* New tag */
  687+                sp->sclass = class;
  688+        } else if (sp->slevel < blevel) {
  689+                /* declared at different block level, hide it */
  690+                sp = hide(sp);
  691+                sp->sclass = class;
  692+        } else if (sp->sclass != class) {
  693+                /* redeclaration of tag */
  694+                uerror("tag %s redeclared", name);
  695+        }
  696+        return sp;
  697+}
  698+
  699+static int enumlow, enumhigh;
  700+int enummer;
  701+
  702+/*
  703+ * Declare a member of enum.
  704+ */
686705 void
 687706 moedef(char *name)
 688707 {
<>689 -        NODE *q;
  708+        struct symtab *sp;
690709 
<>691 -        q = block(NAME, NIL, NIL, MOETY, 0, 0);
 692 -        q->n_sp = lookup(name, 0);
 693 -        defid(q, MOE);
 694 -        nfree(q);
  710+        sp = lookup(name, SNORMAL);
  711+        if (sp->stype == UNDEF || (sp->slevel < blevel)) {
  712+                if (sp->stype != UNDEF)
  713+                        sp = hide(sp);
  714+                sp->stype = INT; /* always */
  715+                sp->ssue = MKSUE(INT);
  716+                sp->sclass = MOE;
  717+                sp->soffset = enummer;
  718+        } else
  719+                uerror("%s redeclared", name);
  720+        if (enummer < enumlow)
  721+                enumlow = enummer;
  722+        if (enummer > enumhigh)
  723+                enumhigh = enummer;
  724+        enummer++;
695725 }
 696726 
 697727 /*
<> 728+ * Declare an enum tag.  Complain if already defined.
  729+ */
  730+struct symtab *
  731+enumhd(char *name)
  732+{
  733+        struct symtab *sp;
  734+
  735+        enummer = enumlow = enumhigh = 0;
  736+        if (name == NULL)
  737+                return NULL;
  738+
  739+        sp = deftag(name, ENAME);
  740+        if (sp->stype != UNDEF) /* enum type already declared */
  741+                uerror("%s redeclared", name);
  742+        return sp;
  743+}
  744+
  745+/*
  746+ * finish declaration of an enum
  747+ */
  748+NODE *
  749+enumdcl(struct symtab *sp)
  750+{
  751+        TWORD t;
  752+
  753+#ifdef ENUMSIZE
  754+        t = ENUMSIZE(enumhigh, enumlow);
  755+#else
  756+        if (enumhigh <= MAX_CHAR && enumlow >= MIN_CHAR)
  757+                t = ctype(CHAR);
  758+        else if (enumhigh <= MAX_SHORT && enumlow >= MIN_SHORT)
  759+                t = ctype(SHORT);
  760+        else
  761+                t = ctype(INT);
  762+#endif
  763+        if (sp) {
  764+                sp->stype = t;
  765+                sp->ssue = MKSUE(t);
  766+        }
  767+        return mkty(t, 0, MKSUE(t));
  768+}
  769+
  770+/*
  771+ * Handle reference to an enum
  772+ */
  773+NODE *
  774+enumref(char *name)
  775+{
  776+        struct symtab *sp;
  777+
  778+        sp = lookup(name, STAGNAME);
  779+        if (sp->sclass != ENAME)
  780+                uerror("enum %s undeclared", name);
  781+
  782+        return mkty(sp->stype, 0, sp->ssue);
  783+}
  784+
  785+/*
698786  * begining of structure or union declaration
 699787  */
 700788 struct rstack *
     
 !
728816                 q->n_type = UNIONTY;
 729817                 if (s != NULL)
 730818                         defid(q, UNAME);
<>731 -        } else { /* enum */
 732 -                strunem = MOE;
 733 -                q->n_type = ENUMTY;
 734 -                if (s != NULL)
 735 -                        defid(q, ENAME);
  819+        } else {
  820+                cerror("bstruct");
736821         }
 737822         r->rsym = q->n_sp;
 738823         r->rlparam = lparam;
     
 !
767852         if (ddebug)
 768853                 printf("dclstruct(%s)\n", r->rsym ? r->rsym->sname : "??");
 769854 #endif
<>770 -        temp = (instruct&INSTRUCT)?STRTY:((instruct&INUNION)?UNIONTY:ENUMTY);
  855+        temp = (instruct&INSTRUCT)?STRTY:((instruct&INUNION)?UNIONTY:0);
771856         instruct = r->rinstruct;
 772857         strunem = r->rclass;
 773858         al = ALSTRUCT;
     
 !
793878 
 794879                 if (p == NULL)
 795880                         cerror("gummy structure member");
<>796 -                if (temp == ENUMTY) {
 797 -                        if (p->soffset < low)
 798 -                                low = p->soffset;
 799 -                        if (p->soffset > high)
 800 -                                high = p->soffset;
 801 -                        p->ssue = sue;
 802 -                        continue;
 803 -                }
804881                 sa = talign(p->stype, p->ssue);
 805882                 if (p->sclass & FIELD)
 806883                         sz = p->sclass&FLDSIZ;
     
 !
827904         sue->suelem[i] = NULL;
 828905         SETOFF(strucoff, al);
 829906 
<>830 -        if (temp == ENUMTY) {
 831 -                TWORD ty;
 832 -
 833 -#ifdef ENUMSIZE
 834 -                ty = ENUMSIZE(high,low);
 835 -#else
 836 -                if ((char)high == high && (char)low == low)
 837 -                        ty = ctype(CHAR);
 838 -                else if ((short)high == high && (short)low == low)
 839 -                        ty = ctype(SHORT);
 840 -                else
 841 -                        ty = ctype(INT);
 842 -#endif
 843 -                strucoff = tsize(ty, 0, MKSUE(ty));
 844 -                sue->suealign = al = talign(ty, MKSUE(ty));
 845 -        }
 846 -
847907         sue->suesize = strucoff;
 848908         sue->suealign = al;
 849909 
     
 !
10011061         switch( BTYPE(ty) ){
 10021062 
 10031063         case UNIONTY:
<>1004 -        case ENUMTY:
10051064         case STRTY:
 10061065                 return((unsigned int)sue->suealign);
 10071066         case BOOL:
     
 !
13661425         /* this must be fixed to use the current type in alignments */
 13671426         switch( new<0?pty->n_type:p->stype ){
 13681427 
<>1369 -        case ENUMTY: {
 1370 -                struct suedef *sue;
 1371 -                sue = new < 0 ? pty->n_sue : p->ssue;
 1372 -                al = sue->suealign;
 1373 -                sz = sue->suesize;
 1374 -                break;
 1375 -        }
 1376 -
13771428         case CHAR:
 13781429         case UCHAR:
 13791430                 al = ALCHAR;
     
 !
17771828         idp->n_qual = DECQAL(idp->n_qual);
 17781829 
 17791830         /* in case ctype has rewritten things */
<>1780 -        if ((t = BTYPE(idp->n_type)) != STRTY && t != UNIONTY && t != ENUMTY)
  1831+        if ((t = BTYPE(idp->n_type)) != STRTY && t != UNIONTY)
17811832                 idp->n_sue = MKSUE(t);
 17821833 
 17831834         if (idp->n_op != NAME) {
     
 !
18161867                 if (w->n_right->n_op == ELLIPSIS)
 18171868                         continue;
 18181869                 ty = w->n_right->n_type;
<>1819 -                if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY ||
 1820 -                    BTYPE(ty) == ENUMTY)
  1870+                if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY)
18211871                         num++;
 18221872                 while (ISFTN(ty) == 0 && ISARY(ty) == 0 && ty > BTMASK)
 18231873                         ty = DECREF(ty);
     
 !
18261876         }
 18271877         cnt++;
 18281878         ty = w->n_type;
<>1829 -        if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY ||
 1830 -            BTYPE(ty) == ENUMTY)
  1879+        if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY)
18311880                 num++;
 18321881         while (ISFTN(ty) == 0 && ISARY(ty) == 0 && ty > BTMASK)
 18331882                 ty = DECREF(ty);
     
 !
18611910                         ap[j]->n_type = INCREF(ap[j]->n_type);
 18621911                 ty = ap[j]->n_type;
 18631912                 al[k++].type = ty;
<>1864 -                if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY ||
 1865 -                    BTYPE(ty) == ENUMTY)
  1913+                if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY)
18661914                         al[k++].sue = ap[j]->n_sue;
 18671915                 while (ISFTN(ty) == 0 && ISARY(ty) == 0 && ty > BTMASK)
 18681916                         ty = DECREF(ty);
     
 !
21242172                 if (ISARY(al->type)) {
 21252173                         printf(" dim %d\n", al->df->ddim);
 21262174                 } else if (BTYPE(al->type) == STRTY ||
<>2127 -                    BTYPE(al->type) == UNIONTY || BTYPE(al->type) == ENUMTY) {
  2175+                    BTYPE(al->type) == UNIONTY) {
21282176                         al++;
 21292177                         printf(" (size %d align %d)", al->sue->suesize,
 21302178                             al->sue->suealign);
     
 !
23112359                         } else
 23122360                                 goto out;
 23132361                 }
<>2314 -                if (BTYPE(arrt) == ENUMTY && BTYPE(type) == INT &&
 2315 -                    (arrt & ~BTMASK) == (type & ~BTMASK))
 2316 -                        goto skip; /* XXX enumty destroyed in optim() */
23172362                 if (BTYPE(arrt) == VOID && type > BTMASK)
 23182363                         goto skip; /* void *f = some pointer */
 23192364                 if (arrt > BTMASK && BTYPE(type) == VOID)
     
 !
25462591                 if( !(instruct&INSTRUCT) ) uerror( "illegal MOS class" );
 25472592                 return( class );
 25482593 
<>2549 -        case MOE:
 2550 -                if( instruct & (INSTRUCT|INUNION) ) uerror( "illegal MOE class" );
 2551 -                return( class );
 2552 -
25532594         case REGISTER:
 25542595                 if (blevel == 0)
 25552596                         uerror( "illegal register declaration" );
     
 !
25762617                         }
 25772618         case STNAME:
 25782619         case UNAME:
<>2579 -        case ENAME:
<_25802620         case EXTERN:
 25812621         case STATIC:
 25822622         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-21 10:56 +0100