Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.287
 
1.288
 
MAIN:ragge:20100811140844
 
pftn.c
_>8282 
 8383 struct params;
 8484 
<>85 -#define ISSTR(ty) (ty == STRTY || ty == UNIONTY)
 86 -#define ISSOU(ty) (ty == STRTY || ty == UNIONTY)
8785 #define MKTY(p, t, d, s) r = talloc(); *r = *p; \
 8886         r = argcast(r, t, d, s); *p = *r; nfree(r);
 8987 
     
 !
9694         int     rstr;
 9795         struct  symtab *rsym;
 9896         struct  symtab *rb;
<>99 -        NODE    *rgp;
  97+        struct  attr *ap;
10098         int     flags;
 10199 #define LASTELM 1
 102100 } *rpole;
     
 !
127125 static void lcommadd(struct symtab *sp);
 128126 static NODE *mkcmplx(NODE *p, TWORD dt);
 129127 extern int fun_inline;
<>130 -struct suedef *sueget(struct suedef *p);
131128 
 132129 int ddebug = 0;
 133130 
 134131 /*
 135132  * Declaration of an identifier.  Handles redeclarations, hiding,
 136133  * incomplete types and forward declarations.
<> 134+ *
  135+ * q is a TYPE node setup after parsing with n_type, n_df and n_ap.
  136+ * n_sp is a pointer to the not-yet initalized symbol table entry
  137+ * unless it's a redeclaration or supposed to hide a variable.
137138  */
 138139 
 139140 void
<>140 -defid(NODE *ap, int class)
  141+defid(NODE *q, int class)
141142 {
 142143         struct symtab *p;
 143144         TWORD type, qual;
 144145         TWORD stp, stq;
 145146         int scl;
 146147         union dimfun *dsym, *ddef;
 147148         int slev, temp, changed;
<>148 -        NODE *q = ap;
149149 
 150150         if (q == NIL)
 151151                 return/* an error was detected */
 152152 
 153153 #ifdef GCC_COMPAT
 154154         if (q->n_op == CM)
<>155 -                q = q->n_left;
  155+                cerror("defid0");
156156 #endif
 157157         p = q->n_sp;
 158158 
     
 !
163163         if (ddebug) {
 164164                 printf("defid(%s (%p), ", p->sname, p);
 165165                 tprint(stdout, q->n_type, q->n_qual);
<>166 -                printf(", %s, (%p,%p)), level %d\n", scnames(class),
 167 -                    q->n_df, q->n_sue, blevel);
  166+                printf(", %s, (%p)), level %d\n\t", scnames(class),
  167+                    q->n_df, blevel);
  168+                dump_attr(q->n_ap);
168169         }
 169170 #endif
 170171 
     
 !
186187                 printf("        previous def'n: ");
 187188                 tprint(stdout, stp, stq);
 188189                 printf(", %s, (%p,%p)), level %d\n",
<>189 -                    scnames(p->sclass), p->sdf, p->ssue, slev);
  190+                    scnames(p->sclass), p->sdf, p->sap, slev);
190191         }
 191192 #endif
 192193 
     
 !
249250 
 250251         /* check that redeclarations are to the same structure */
 251252         if (temp == STRTY || temp == UNIONTY) {
<>252 -                struct suedef *sue1, *sue2;
 253 -                GETSUE(sue1, p->ssue);
 254 -                GETSUE(sue2, q->n_sue);
 255 -                if (sue1 != sue2)
  253+                if (strmemb(p->sap) != strmemb(q->n_ap))
256254                         goto mismatch;
 257255         }
 258256 
     
 !
263261                 printf("        previous class: %s\n", scnames(scl));
 264262 #endif
 265263 
<>266 -#ifdef GCC_COMPAT
 267 -        /* Its allowed to add attributes to existing declarations */
 268 -        if (ap != q) {
 269 -                p->ssue = sueget(p->ssue);
 270 -                p->ssue->suega = gcc_attr_parse(ap->n_right);
 271 -                ap->n_right = bcon(0);
 272 -                if (pragma_renamed)
 273 -                        p->soname = pragma_renamed;
 274 -                pragma_renamed = NULL;
 275 -        }
 276 -#endif
  264+        /*
  265+         * Its allowed to add attributes to existing declarations.
  266+         * Be care ful though not to trash existing attributes.
  267+         */
  268+        if (p->sap->atype <= ATTR_MAX) {
  269+                /* nothing special, just overwrite */
  270+                p->sap = q->n_ap;
  271+        } else {
  272+                struct attr *ap;
  273+                for (ap = q->n_ap; ap; ap = ap->next) {
  274+                        if (ap->atype > ATTR_MAX)
  275+                                p->sap = attr_add(p->sap, attr_dup(ap, 3));
  276+                }
  277+        }
277278 
 278279         if (class & FIELD)
 279280                 return;
     
 !
350351                          * This is allowed if the previous declaration is of
 351352                          * type gnu_inline.
 352353                          */
<>353 -                        if (gcc_get_attr(p->ssue, GCC_ATYP_GNU_INLINE))
  354+                        if (attr_find(p->sap, GCC_ATYP_GNU_INLINE))
354355                                 goto done;
 355356                         break;
 356357                 }
     
 !
374375          */
 375376         if (blevel == slev || class == EXTERN || class == FORTRAN ||
 376377             class == UFORTRAN) {
<>377 -                if (ISSTR(class) && !ISSTR(p->sclass)) {
  378+                if (ISSOU(class) && !ISSOU(p->sclass)) {
378379 redec:                  uerror("redeclaration of %s", p->sname);
 379380                         return;
 380381                 }
     
 !
394395         p->sclass = (char)class;
 395396         p->slevel = (char)blevel;
 396397         p->soffset = NOOFFSET;
<>397 -        if (q->n_sue == NULL)
 398 -                cerror("q->n_sue == NULL");
 399 -#ifdef GCC_COMPAT
 400 -        if (ap != q) {
 401 -                struct gcc_attrib *ga;
 402 -                struct suedef *sue;
  398+        if (q->n_ap == NULL)
  399+                cerror("q->n_ap == NULL");
  400+        p->sap = q->n_ap;
403401 
<>404 -                sue = q->n_sue = sueget(q->n_sue);
 405 -                sue->suega = gcc_attr_parse(ap->n_right);
 406 -                if ((ga = gcc_get_attr(sue, GCC_ATYP_ALIGNED))) {
 407 -                        sue->suealign = ga->a1.iarg;
 408 -                        SETOFF(sue->suesize, sue->suealign);
 409 -                } else if ((ga = gcc_get_attr(sue, GCC_ATYP_MODE))) {
 410 -                        if (ga->a1.iarg)
 411 -                                p->stype = ga->a1.iarg;
 412 -                }
 413 -                ap->n_right = bcon(0);
 414 -        }
 415 -#endif
 416 -        p->ssue = q->n_sue;
 417 -
418402         /* copy dimensions */
 419403         p->sdf = q->n_df;
 420404         /* Do not save param info for old-style functions */
     
 !
486470         fixdef(p);      /* Leave last word to target */
 487471 #ifndef HAVE_WEAKREF
 488472         {
<>489 -                struct gcc_attrib *ga;
  473+                struct attr *at;
490474 
 491475                 /* Refer renamed function */
<>492 -                if ((ga = gcc_get_attr(p->ssue, GCC_ATYP_WEAKREF)))
 493 -                        p->soname = ga->a1.sarg;
  476+                if ((at = attr_find(p->sap, GCC_ATYP_WEAKREF)))
  477+                        p->soname = at->sarg(0);
494478         }
 495479 #endif
 496480 #ifdef PCC_DEBUG
<>497 -        if (ddebug)
 498 -                printf( "       sdf, ssue, offset: %p, %p, %d\n",
 499 -                    p->sdf, p->ssue, p->soffset);
  481+        if (ddebug) {
  482+                printf( "       sdf, offset: %p, %d\n\t",
  483+                    p->sdf, p->soffset);
  484+                dump_attr(p->sap);
  485+        }
500486 #endif
 501487 }
 502488 
     
 !
601587                 }
 602588                 if (p->stype == FARG) {
 603589                         p->stype = INT;
<>604 -                        p->ssue = MKSUE(INT);
  590+                        p->sap = MKAP(INT);
605591                 }
 606592                 if (ISARY(p->stype)) {
 607593                         p->stype += (PTR-ARY);
     
 !
623609                 for (i = 0; i < nparams; i++) {
 624610                         TWORD type = parr[i]->stype;
 625611                         (al2++)->type = type;
<>626 -                        if (ISSTR(BTYPE(type)))
 627 -                                (al2++)->sue = parr[i]->ssue;
  612+                        if (ISSOU(BTYPE(type)))
  613+                                (al2++)->sap = parr[i]->sap;
628614                         while (!ISFTN(type) && !ISARY(type) && type > BTMASK)
 629615                                 type = DECREF(type);
 630616                         if (type > BTMASK)
     
 !
653639         retlab = getlab();
 654640         bfcode(parr, nparams);
 655641         if (fun_inline &&
<>656 -            (xinline || gcc_get_attr(cftnsp->ssue, GCC_ATYP_ALW_INL)))
  642+            (xinline || attr_find(cftnsp->sap, GCC_ATYP_ALW_INL)))
657643                 inline_args(parr, nparams);
 658644         plabel(getlab()); /* used when spilling */
 659645         if (parlink)
     
 !
665651 }
 666652 
 667653 /*
<>668 - * Alloc sue from either perm or tmp memory, depending on blevel.
  654+ * basic attributes for structs and enums
669655  */
<>670 -struct suedef *
 671 -sueget(struct suedef *p)
  656+static struct attr *
  657+seattr(void)
672658 {
<>673 -        struct suedef *sue;
 674 -
 675 -        if (blevel == 0) {
 676 -                sue = permalloc(sizeof(struct suedef));
 677 -                suedefcnt++;
 678 -        } else
 679 -                sue = tmpalloc(sizeof(struct suedef));
 680 -        sue = memset(sue, 0, sizeof(struct suedef));
 681 -        sue->suep = p;
 682 -        return sue;
  659+        return attr_add(attr_new(ATTR_BASETYP, 4), attr_new(ATTR_STRUCT, 1));
683660 }
 684661 
 685662 /*
     
 !
688665 static void
 689666 defstr(struct symtab *sp, int class)
 690667 {
<>691 -        sp->ssue = permalloc(sizeof(struct suedef));
 692 -        memset(sp->ssue, 0, sizeof(struct suedef));
693668         sp->sclass = (char)class;
 694669         if (class == STNAME)
 695670                 sp->stype = STRTY;
     
 !
708683 {
 709684         struct symtab *sp;
 710685 
<>711 -        if ((sp = lookup(name, STAGNAME))->ssue == NULL) {
  686+        if ((sp = lookup(name, STAGNAME))->sap == NULL) {
712687                 /* New tag */
 713688                 defstr(sp, class);
 714689         } else if (sp->sclass != class)
     
 !
725700         struct symtab *sp;
 726701 
 727702         sp = deftag(tag, soru);
<>728 -        return mkty(sp->stype, 0, sp->ssue);
  703+        if (sp->sap == NULL)
  704+                sp->sap = seattr();
  705+        return mkty(sp->stype, 0, sp->sap);
729706 }
 730707 
 731708 static int enumlow, enumhigh;
     
 !
744721                 if (sp->stype != UNDEF)
 745722                         sp = hide(sp);
 746723                 sp->stype = INT; /* always */
<>747 -                sp->ssue = MKSUE(INT);
  724+                sp->sap = MKAP(INT);
748725                 sp->sclass = MOE;
 749726                 sp->soffset = enummer;
 750727         } else
     
 !
762739 struct symtab *
 763740 enumhd(char *name)
 764741 {
<> 742+        struct attr *ap;
765743         struct symtab *sp;
 766744 
 767745         enummer = enumlow = enumhigh = 0;
     
 !
775753                 sp = hide(sp);
 776754                 defstr(sp, ENAME);
 777755         }
<>778 -        sp->ssue->suem = sp;    /* ourselves XXX */
  756+        if (sp->sap == NULL)
  757+                sp->sap = seattr();
  758+        ap = attr_find(sp->sap, ATTR_STRUCT);
  759+        ap->amlist = sp;
779760         return sp;
 780761 }
 781762 
     
 !
785766 NODE *
 786767 enumdcl(struct symtab *sp)
 787768 {
<>788 -        struct suedef *sue;
  769+        struct attr *ap;
789770         NODE *p;
 790771         TWORD t;
 791772 
     
 !
799780         else
 800781                 t = ctype(INT);
 801782 #endif
<> 783+        
802784         if (sp) {
 803785                 sp->stype = t;
<>804 -                sue = sp->ssue;
 805 -                sue->suesize = (MKSUE(t))->suesize;
 806 -                sue->suealign = (MKSUE(t))->suealign;
  786+                ap = attr_find(sp->sap, ATTR_BASETYP);
  787+                ap->atypsz = (MKAP(t))->atypsz;
  788+                ap->aalign = (MKAP(t))->aalign;
  789+                ap = sp->sap;
807790         } else
<>808 -                sue = MKSUE(t);
 809 -        p = mkty(t, 0, sue);
  791+                ap = MKAP(t);
  792+        p = mkty(t, 0, ap);
810793         p->n_sp = sp;
 811794         return p;
 812795 }
     
 !
838821                 sp->stype = ENUMTY;
 839822         }
 840823 
<>841 -        p = mkty(sp->stype, 0, sp->ssue);
  824+        p = mkty(sp->stype, 0, sp->sap);
842825         p->n_sp = sp;
 843826         return p;
 844827 }
 845828 
 846829 /*
 847830  * begining of structure or union declaration
<> 831+ * It's an error if this routine is called twice with the same struct.
848832  */
 849833 struct rstack *
 850834 bstruct(char *name, int soru, NODE *gp)
 851835 {
 852836         struct rstack *r;
 853837         struct symtab *sp;
<> 838+        struct attr *ap, *gap;
854839 
<> 840+        gap = gp ? gcc_attr_parse(gp) : NULL;
  841+
855842         if (name != NULL) {
 856843                 sp = deftag(name, soru);
<>857 -                if (sp->ssue->suealign != 0) {
  844+                if (sp->sap == NULL)
  845+                        sp->sap = seattr();
  846+                ap = attr_find(sp->sap, ATTR_BASETYP);
  847+                if (ap->aalign != 0) {
858848                         if (sp->slevel < blevel) {
 859849                                 sp = hide(sp);
 860850                                 defstr(sp, soru);
<> 851+                                sp->sap = seattr();
861852                         } else
 862853                                 uerror("%s redeclared", name);
 863854                 }
<>864 -        } else
  855+                gap = sp->sap = attr_add(sp->sap, gap);
  856+        } else {
  857+                gap = attr_add(seattr(), gap);
865858                 sp = NULL;
<> 859+        }
866860 
 867861         r = tmpcalloc(sizeof(struct rstack));
 868862         r->rsou = soru;
 869863         r->rsym = sp;
 870864         r->rb = NULL;
<>871 -        r->rgp = gp;
  865+        r->ap = gap;
872866         r->rnext = rpole;
 873867         rpole = r;
 874868 
     
 !
885879 dclstruct(struct rstack *r)
 886880 {
 887881         NODE *n;
<>888 -        struct suedef *sue;
  882+        struct attr *aps, *apb;
889883         struct symtab *sp;
 890884         int al, sa, sz, coff;
 891885 
<>892 -        sue = r->rsym ? r->rsym->ssue : sueget(NULL);
  886+        apb = attr_find(r->ap, ATTR_BASETYP);
  887+        aps = attr_find(r->ap, ATTR_STRUCT);
  888+        aps->amlist = r->rb;
893889 
 894890 #ifdef ALSTRUCT
 895891         al = ALSTRUCT;
     
 !
898894 #endif
 899895 
 900896         /*
<>901 -         * extract size and alignment, recalculate offsets
 902 -         * if struct should be packed.
  897+         * extract size and alignment, calculate offsets
903898          */
 904899         coff = 0;
<>905 -        sue->suem = r->rb;
906900         for (sp = r->rb; sp; sp = sp->snext) {
<>907 -                sa = talign(sp->stype, sp->ssue);
  901+                sa = talign(sp->stype, sp->sap);
908902                 if (sp->sclass & FIELD)
 909903                         sz = sp->sclass&FLDSIZ;
 910904                 else
<>911 -                        sz = (int)tsize(sp->stype, sp->sdf, sp->ssue);
  905+                        sz = (int)tsize(sp->stype, sp->sdf, sp->sap);
912906                 if (sz > rpole->rstr)
 913907                         rpole->rstr = sz/* for use with unions */
 914908                 /*
     
 !
920914 
 921915         SETOFF(rpole->rstr, al);
 922916 
<>923 -        sue->suesize = rpole->rstr;
 924 -        sue->suealign = al;
  917+        apb->atypsz = rpole->rstr;
  918+        apb->aalign = al;
925919 
 926920 #ifdef PCC_DEBUG
 927921         if (ddebug) {
 928922                 printf("dclstruct(%s): size=%d, align=%d\n",
 929923                     r->rsym ? r->rsym->sname : "??",
<>930 -                    sue->suesize, sue->suealign);
  924+                    apb->atypsz, apb->aalign);
931925         }
 932926         if (ddebug>1) {
 933927                 printf("\tsize %d align %d link %p\n",
<>934 -                    sue->suesize, sue->suealign, sue->suem);
 935 -                for (sp = sue->suem; sp != NULL; sp = sp->snext) {
  928+                    apb->atypsz, apb->aalign, aps->amlist);
  929+                for (sp = aps->amlist; sp != NULL; sp = sp->snext) {
936930                         printf("\tmember %s(%p)\n", sp->sname, sp);
 937931                 }
 938932         }
 939933 #endif
 940934 
 941935 #ifdef STABS
 942936         if (gflag)
<>943 -                stabs_struct(r->rsym, sue);
  937+                stabs_struct(r->rsym, r->ap);
944938 #endif
 945939 
 946940         rpole = r->rnext;
<>947 -        n = mkty(r->rsou == STNAME ? STRTY : UNIONTY, 0, sue);
 948 -        n->n_qual |= 1; /* definition place */
 949 -        n->n_left = r->rgp;
  941+        n = mkty(r->rsou == STNAME ? STRTY : UNIONTY, 0, r->ap);
  942+
  943+        n->n_qual |= 1; /* definition place XXX used by attributes */
950944         return n;
 951945 }
 952946 
     
 !
958952 {
 959953         struct symtab *sp, *lsp;
 960954         int incomp;
<> 955+        TWORD t;
961956  
 962957         if (rpole == NULL)
 963958                 cerror("soumemb");
     
 !
975970                 lsp->snext = sp;
 976971 #ifdef GCC_COMPAT
 977972         if (n->n_op == CM)
<>978 -                n->n_left->n_sp = sp;
 979 -        else
  973+                cerror("soumemb CM");
980974 #endif
<>981 -                n->n_sp = sp;
  975+        n->n_sp = sp;
982976         if ((class & FIELD) == 0)
 983977                 class = rpole->rsou == STNAME ? MOS : MOU;
 984978         defid(n, class);
     
 !
1002996          * "...such a structure shall not be a member of a structure
 1003997          *  or an element of an array."
 1004998          */
<>1005 -        if (rpole->rsou == STNAME && sp->ssue->suem && !ISPTR(sp->stype)) {
 1006 -                struct symtab *lnk;
  999+        t = sp->stype;
  1000+        if (rpole->rsou != STNAME || BTYPE(t) != STRTY)
  1001+                return; /* not for unions */
  1002+        while (ISARY(t))
  1003+                t = DECREF(t);
  1004+        if (ISPTR(t))
  1005+                return;
10071006 
<>1008 -                for (lnk = sp->ssue->suem; lnk->snext; lnk = lnk->snext)
  1007+        if ((lsp = strmemb(sp->sap)) != NULL) {
  1008+                for (; lsp->snext; lsp = lsp->snext)
10091009                         ;
<>1010 -                if (ISARY(lnk->stype) && lnk->sdf->ddim == NOOFFSET)
  1010+                if (ISARY(lsp->stype) && lsp->sdf->ddim == NOOFFSET)
10111011                         uerror("incomplete struct in struct");
 10121012         }
 10131013 }
     
 !
10811081  * compute the alignment of an object with type ty, sizeoff index s
 10821082  */
 10831083 int
<>1084 -talign(unsigned int ty, struct suedef *sue)
  1084+talign(unsigned int ty, struct attr *apl)
10851085 {
<> 1086+        struct attr *al;
10861087         int i;
 10871088 
 10881089         if (ISPTR(ty))
 10891090                 return(ALPOINT); /* shortcut */
 10901091 
<>1091 -        if(sue == NULL && ty!=INT && ty!=CHAR && ty!=SHORT &&
  1092+        if(apl == NULL && ty!=INT && ty!=CHAR && ty!=SHORT &&
10921093             ty!=UNSIGNED && ty!=UCHAR && ty!=USHORT) {
 10931094                 return(fldal(ty));
 10941095         }
     
 !
11071108                         }
 11081109                 }
 11091110 
<>1110 -        GETSUE(sue, sue)
 1111 -                if (sue->suealign)
 1112 -                        break;
 1113 -        if (sue->suealign == 0)
  1111+        
  1112+        if ((al = attr_find(apl, GCC_ATYP_ALIGNED)))
  1113+                return al->iarg(0);
  1114+        al = attr_find(apl, ATTR_BASETYP);
  1115+        if (al == NULL)
  1116+                cerror("no basetyp");
  1117+        if (al->aalign == 0)
11141118                 uerror("no alignment");
<>1115 -        return sue->suealign;
  1119+        return al->aalign;
11161120 }
 11171121 
 11181122 /* compute the size associated with type ty,
 11191123  *  dimoff d, and sizoff s */
 11201124 /* BETTER NOT BE CALLED WHEN t, d, and s REFER TO A BIT FIELD... */
 11211125 OFFSZ
<>1122 -tsize(TWORD ty, union dimfun *d, struct suedef *sue)
  1126+tsize(TWORD ty, union dimfun *d, struct attr *apl)
11231127 {
<>1124 -
 1125 -        int i;
  1128+        struct attr *ap;
11261129         OFFSZ mult, sz;
<> 1130+        int i;
11271131 
 11281132         mult = 1;
 11291133 
     
 !
11461150                         }
 11471151                 }
 11481152 
<>1149 -        if (sue == NULL)
 1150 -                cerror("bad tsize sue");
 1151 -        GETSUE(sue, sue);
 1152 -        sz = sue->suesize;
  1153+        ap = attr_find(apl, ATTR_BASETYP);
  1154+        sz = ap->atypsz;
  1155+        
11531156 #ifdef GCC_COMPAT
 11541157         if (ty == VOID)
 11551158                 sz = SZCHAR;
     
 !
11601163                         return(SZINT);
 11611164                 }
 11621165         } else {
<>1163 -                if (sue->suealign == 0)
  1166+                if (talign(ty, apl) == 0)
11641167                         uerror("unknown structure/union/enum");
 11651168         }
 11661169 
     
 !
11961199                 sp->sdf = permalloc(sizeof(union dimfun));
 11971200                 if (wide) {
 11981201                         sp->stype = WCHAR_TYPE+ARY;
<>1199 -                        sp->ssue = MKSUE(WCHAR_TYPE);
  1202+                        sp->sap = MKAP(WCHAR_TYPE);
12001203                 } else {
 12011204                         if (funsigned_char) {
 12021205                                 sp->stype = UCHAR+ARY;
<>1203 -                                sp->ssue = MKSUE(UCHAR);
  1206+                                sp->sap = MKAP(UCHAR);
12041207                         } else {
 12051208                                 sp->stype = CHAR+ARY;
<>1206 -                                sp->ssue = MKSUE(CHAR);
  1209+                                sp->sap = MKAP(CHAR);
12071210                         }
 12081211                 }
 12091212                 for (wr = sp->sname, i = 1; *wr; i++)
     
 !
12171220                         instring(sp);
 12181221         }
 12191222 
<>1220 -        p = block(NAME, NIL, NIL, sp->stype, sp->sdf, sp->ssue);
  1223+        p = block(NAME, NIL, NIL, sp->stype, sp->sdf, sp->sap);
12211224         p->n_sp = sp;
 12221225         return(clocal(p));
 12231226 }
     
 !
12381241                         p->n_lval = esccon(&s);
 12391242                 else
 12401243                         p->n_lval = (unsigned char)s[-1];
<>1241 -                ninval(0, (MKSUE(WCHAR_TYPE))->suesize, p);
  1244+                ninval(0, (MKAP(WCHAR_TYPE))->atypsz, p);
12421245         } while (s[-1] != 0);
 12431246         nfree(p);
 12441247 }
     
 !
12781281         if (xtemps && ((p->sclass == AUTO) || (p->sclass == REGISTER)) &&
 12791282             (p->stype < STRTY || ISPTR(p->stype)) &&
 12801283             !(cqual(p->stype, p->squal) & VOL) && cisreg(p->stype)) {
<>1281 -                NODE *tn = tempnode(0, p->stype, p->sdf, p->ssue);
  1284+                NODE *tn = tempnode(0, p->stype, p->sdf, p->sap);
12821285                 p->soffset = regno(tn);
 12831286                 p->sflags |= STNODE;
 12841287                 nfree(tn);
 12851288                 return 0;
 12861289         }
 12871290 
<>1288 -        al = talign(p->stype, p->ssue);
  1291+        al = talign(p->stype, p->sap);
12891292         noff = off = *poff;
<>1290 -        tsz = (int)tsize(p->stype, p->sdf, p->ssue);
  1293+        tsz = (int)tsize(p->stype, p->sdf, p->sap);
12911294 #ifdef BACKAUTO
 12921295         if (p->sclass == AUTO) {
 12931296                 noff = off + tsz;
     
 !
13731376         if (ISARY(t)) {
 13741377                 p->sflags |= (STNODE|SDYNARRAY);
 13751378                 p->stype = INCREF(p->stype); /* Make this an indirect pointer */
<>1376 -                tn = tempnode(0, p->stype, p->sdf, p->ssue);
  1379+                tn = tempnode(0, p->stype, p->sdf, p->sap);
13771380                 p->soffset = regno(tn);
 13781381         } else {
 13791382                 oalloc(p, poff);
     
 !
13891392                 if (df->ddim < 0) {
 13901393                         n = arrstk[astkp++];
 13911394                         do {
<>1392 -                                nn = tempnode(0, INT, 0, MKSUE(INT));
  1395+                                nn = tempnode(0, INT, 0, MKAP(INT));
13931396                                 no = regno(nn);
 13941397                         } while (no == -NOOFFSET);
 13951398                         edelay(buildtree(ASSIGN, nn, n));
 13961399 
 13971400                         df->ddim = -no;
<>1398 -                        n = tempnode(no, INT, 0, MKSUE(INT));
  1401+                        n = tempnode(no, INT, 0, MKAP(INT));
13991402                 } else
 14001403                         n = bcon(df->ddim);
 14011404 
     
 !
14121415                 if (pol == NIL)
 14131416                         uerror("aggregate dynamic array not allowed");
 14141417                 if (tn)
<>1415 -                        spalloc(tn, pol, tsize(t, 0, p->ssue));
  1418+                        spalloc(tn, pol, tsize(t, 0, p->sap));
14161419         }
 14171420         arrstkp = 0;
 14181421 }
     
 !
14331436                 type = INT;
 14341437         }
 14351438 
<>1436 -        al = btdims[type].suealign;
 1437 -        sz = btdims[type].suesize;
  1439+        al = btattr[type].aalign;
  1440+        sz = btattr[type].atypsz;
14381441 
 14391442         if (w > sz) {
 14401443                 uerror("field too big");
     
 !
14901493 
 14911494 #ifdef GCC_COMPAT
 14921495         if (p->n_op == CM)
<>1493 -                p = p->n_left;
  1496+                cerror("nidcl CM");
14941497 #endif
 14951498 
 14961499         sp = p->n_sp;
     
 !
15931596 struct typctx {
 15941597         int class, qual, sig, uns, cmplx, imag, err;
 15951598         TWORD type;
<>1596 -        NODE *saved, *prea, *posta;
  1599+        NODE *saved;
  1600+        struct attr *pre, *post;
15971601 };
 15981602 
 15991603 static void
 16001604 typwalk(NODE *p, void *arg)
 16011605 {
 16021606         struct typctx *tc = arg;
 16031607 
<>1604 -#define cmop(x,y) block(CM, x, y, INT, 0, MKSUE(INT))
  1608+#define cmop(x,y) block(CM, x, y, INT, 0, MKAP(INT))
16051609         switch (p->n_op) {
 16061610         case ATTRIB:
 16071611                 if (tc->saved && (tc->saved->n_qual & 1)) {
<>1608 -                        if (tc->posta == NULL)
 1609 -                                tc->posta = p->n_left;
 1610 -                        else
 1611 -                                tc->posta = cmop(tc->posta, p->n_left);
  1612+                        tc->post = attr_add(tc->post,gcc_attr_parse(p->n_left));
16121613                 } else {
<>1613 -                        if (tc->prea == NULL)
 1614 -                                tc->prea = p->n_left;
 1615 -                        else
 1616 -                                tc->prea = cmop(tc->prea, p->n_left);
  1614+                        tc->pre = attr_add(tc->pre, gcc_attr_parse(p->n_left));
16171615                 }
 16181616                 p->n_left = bcon(0); /* For tfree() */
 16191617                 break;
     
 !
16241622                 break;
 16251623 
 16261624         case QUALIFIER:
<>1627 -                tc->qual |= p->n_type >> TSHIFT;
  1625+                tc->qual |= p->n_qual >> TSHIFT;
16281626                 break;
 16291627 
 16301628         case TYPE:
     
 !
16341632                                 tc->err = 1;
 16351633 #ifdef GCC_COMPAT
 16361634                         if (ISSOU(p->n_type) && p->n_left) {
<>1637 -                                if (tc->posta)
  1635+                                if (tc->post)
16381636                                         cerror("typwalk");
<>1639 -                                tc->posta = p->n_left;
  1637+                                tc->post = gcc_attr_parse(p->n_left);
16401638                         }
 16411639 #endif
 16421640                         tc->saved = ccopy(p);
     
 !
17371735                             tc.type == FLOAT ? "0f" : "0l";
 17381736                         sp = lookup(addname(c), 0);
 17391737                         tc.type = STRTY;
<>1740 -                        tc.saved = mkty(tc.type, sp->sdf, sp->ssue);
  1738+                        tc.saved = mkty(tc.type, sp->sdf, sp->sap);
17411739                         tc.saved->n_sp = sp;
 17421740                         tc.type = 0;
 17431741                 } else
     
 !
17611759 #ifdef GCC_COMPAT
 17621760         if (pragma_packed) {
 17631761                 q = bdty(CALL, bdty(NAME, "packed"), bcon(pragma_packed));
<>1764 -                tc.posta = (tc.posta == NIL ? q : cmop(tc.posta, q));
  1762+                tc.post = attr_add(tc.post, gcc_attr_parse(q));
17651763         }
 17661764         if (pragma_aligned) {
 17671765                 /* Deal with relevant pragmas */
 17681766                 q = bdty(CALL, bdty(NAME, "aligned"), bcon(pragma_aligned));
<>1769 -                tc.posta = (tc.posta == NIL ? q : cmop(tc.posta, q));
  1767+                tc.post = attr_add(tc.post, gcc_attr_parse(q));
17701768         }
 17711769         pragma_aligned = pragma_packed = 0;
<>1772 -        if (tc.posta) {
  1770+#endif
  1771+        if ((q = tc.saved) == NULL) {
  1772+                TWORD t;
  1773+                if ((t = BTYPE(tc.type)) > LDOUBLE && t != VOID)
  1774+                        cerror("typenode2 t %x", tc.type);
  1775+                if (t == UNDEF) {
  1776+                        t = INT;
  1777+                        MODTYPE(tc.type, INT);
  1778+                }
  1779+                qmkty(tc.type, 0, MKAP(t));
  1780+        }
  1781+        q->n_ap = attr_add(q->n_ap, tc.post);
  1782+        q->n_qual = tc.qual;
  1783+        q->n_lval = tc.class;
  1784+#ifdef GCC_COMPAT
  1785+        if (tc.post) {
17731786                 /* Can only occur for TYPEDEF, STRUCT or UNION */
 17741787                 if (tc.saved == NULL)
 17751788                         cerror("typenode");
<>1776 -                gcc_tcattrfix(tc.saved, tc.posta);
  1789+                gcc_tcattrfix(q);
17771790         }
<> 1791+        if (tc.pre)
  1792+                q->n_ap = attr_add(q->n_ap, tc.pre);
17781793 #endif
<>1779 -        q = (tc.saved ? tc.saved : mkty(tc.type, 0, 0));
 1780 -        q->n_qual = tc.qual;
 1781 -        q->n_lval = tc.class;
 1782 -        if (BTYPE(q->n_type) == UNDEF)
 1783 -                MODTYPE(q->n_type, INT);
 1784 -#ifdef GCC_COMPAT
 1785 -        if (tc.prea)
 1786 -                q = cmop(q, tc.prea);
 1787 -#endif
17881794         return q;
 17891795 
 17901796 bad:    uerror("illegal type combination");
     
 !
18101816 
 18111817 /*
 18121818  * merge type typ with identifier idp.
<>1813 - * idp is returned as a NAME node with correct types.
 1814 - * typ is untouched.
  1819+ * idp is returned as a NAME node with correct types,
  1820+ * typ is untouched since multiple declarations uses it.
  1821+ * typ has type attributes, idp can never carry such attributes
  1822+ * so on return just a pointer to the typ attributes is returned.
18151823  */
 18161824 NODE *
 18171825 tymerge(NODE *typ, NODE *idp)
 18181826 {
<> 1827+        TWORD t;
18191828         NODE *p;
 18201829         union dimfun *j;
 18211830         struct tylnk *base, tylnk, *tylkp;
<>1822 -        struct suedef *sue;
 1823 -        unsigned int t;
  1831+        struct attr *ap, *bap;
18241832         int ntdim, i;
 18251833 
<>1826 -#ifdef GCC_COMPAT
 1827 -        NODE *gcs;
 1828 -
 1829 -        if (typ->n_op == CM) {
 1830 -                /* has storage attributes */
 1831 -                gcs = ccopy(typ->n_right);
 1832 -                typ = typ->n_left;
 1833 -        } else
 1834 -                gcs = NULL;
 1835 -        if (idp->n_op == CM) {
 1836 -                /* has type-specific attributes */
 1837 -                if (gcs != NIL) {
 1838 -                        p = idp->n_right;
 1839 -                        if (p->n_op != CM) {
 1840 -                                gcs = cmop(gcs, p);
 1841 -                        } else {
 1842 -                                while (p->n_left->n_op == CM)
 1843 -                                        p = p->n_left;
 1844 -                                p->n_left = cmop(gcs, p->n_left);
 1845 -                                gcs = idp->n_right;
 1846 -                        }
 1847 -                } else
 1848 -                        gcs = idp->n_right;
 1849 -                p = idp;
 1850 -                idp = idp->n_left;
 1851 -                nfree(p);
 1852 -        }
 1853 -#endif
 1854 -
 1855 -        if (typ->n_op != TYPE)
 1856 -                cerror("tymerge: arg 1");
 1857 -
18581834 #ifdef PCC_DEBUG
 18591835         if (ddebug > 2) {
 18601836                 printf("tymerge(%p,%p)\n", typ, idp);
     
 !
18631839         }
 18641840 #endif
 18651841 
<>1866 -//if (idp && idp->n_sue) { printf("idp "); dump_attr(idp->n_sue->suega); }
 1867 -//if (typ && typ->n_sue) { printf("typ "); dump_attr(typ->n_sue->suega); }
 1868 -        sue = idp->n_sue;
  1842+        if (typ->n_op == CM || idp->n_op == CM)
  1843+                cerror("tymerge CM");
18691844 
<> 1845+        if (typ->n_op != TYPE)
  1846+                cerror("tymerge: arg 1");
  1847+
  1848+        bap = typ->n_ap;
  1849+
18701850         idp->n_type = typ->n_type;
 18711851         idp->n_qual |= typ->n_qual;
 18721852 
     
 !
18751855         ntdim = 0;
 18761856 
 18771857         tyreduce(idp, &tylkp, &ntdim);
<>1878 -        idp->n_sue = typ->n_sue;
18791858 
 18801859         for (t = typ->n_type, j = typ->n_df; t&TMASK; t = DECREF(t))
 18811860                 if (ISARY(t) || ISFTN(t))
     
 !
18911870                 idp->n_df = NULL;
 18921871 
 18931872         /* now idp is a single node: fix up type */
<>1894 -
 1895 -/* Start: ensure that this des not cause any problem */
 1896 -        idp->n_type = ctype(idp->n_type);
 1897 -
 1898 -        /* in case ctype has rewritten things */
 1899 -        if ((t = BTYPE(idp->n_type)) != STRTY && t != UNIONTY && t != ENUMTY)
 1900 -                idp->n_sue = MKSUE(t);
 1901 -/* End: ensure that this des not cause any problem */
 1902 -
  1873+        if ((t = ctype(idp->n_type)) != idp->n_type) {
  1874+                idp->n_type = t;
  1875+                t = BTYPE(t);
  1876+                if (bap->atype == ATTR_BASETYP)
  1877+                        bap = MKAP(t);
  1878+                else {
  1879+                        for (ap = bap;
  1880+                            ap->next->atype != ATTR_BASETYP; ap = ap->next)
  1881+                                ;
  1882+                        ap->next = MKAP(t);
  1883+                }
  1884+        }
  1885+        
19031886         if (idp->n_op != NAME) {
 19041887                 for (p = idp->n_left; p->n_op != NAME; p = p->n_left)
 19051888                         nfree(p);
 19061889                 nfree(p);
 19071890                 idp->n_op = NAME;
 19081891         }
<> 1892+        idp->n_ap = bap;
19091893 
<>1910 -#ifdef GCC_COMPAT
 1911 -        if (sue && sue->suega) {
 1912 -                idp->n_sue = sueget(idp->n_sue);
 1913 -                idp->n_sue->suega = sue->suega;
 1914 -        }
 1915 -#endif
 1916 -
 1917 -//if (idp && idp->n_sue) { printf("residp ");
 1918 -//      GETSUE(sue, idp->n_sue) dump_attr(sue->suega); }
 1919 -
 1920 -#ifdef GCC_COMPAT
 1921 -        if (gcs)
 1922 -                idp = cmop(idp, gcs);
 1923 -#endif
 1924 -
19251894         return(idp);
 19261895 }
 19271896 
     
 !
19951964                 ty = ap[j]->n_type;
 19961965                 al[k++].type = ty;
 19971966                 if (BTYPE(ty) == STRTY || BTYPE(ty) == UNIONTY)
<>1998 -                        al[k++].sue = ap[j]->n_sue;
  1967+                        al[k++].sap = ap[j]->n_ap;
19991968                 while (ISFTN(ty) == 0 && ISARY(ty) == 0 && ty > BTMASK)
 20001969                         ty = DECREF(ty);
 20011970                 if (ty > BTMASK)
     
 !
20772046 }
 20782047 
 20792048 static NODE *
<>2080 -argcast(NODE *p, TWORD t, union dimfun *d, struct suedef *sue)
  2049+argcast(NODE *p, TWORD t, union dimfun *d, struct attr *ap)
20812050 {
 20822051         NODE *u, *r = talloc();
 20832052 
 20842053         r->n_op = NAME;
 20852054         r->n_type = t;
 20862055         r->n_qual = 0; /* XXX */
 20872056         r->n_df = d;
<>2088 -        r->n_sue = sue;
  2057+        r->n_ap = ap;
20892058 
 20902059         u = buildtree(CAST, r, p);
 20912060         nfree(u->n_left);
     
 !
21202089                         }
 21212090                         t = DECREF(t);
 21222091                 }
<>2123 -                if (ISSTR(t)) {
  2092+                if (ISSOU(t)) {
21242093                         al++;
<>2125 -                        printf(" (size %d align %d)", al->sue->suesize,
 2126 -                            al->sue->suealign);
  2094+                        struct attr *ap = attr_find(al->sap, ATTR_BASETYP);
  2095+                        printf(" (size %d align %d)", ap->atypsz,
  2096+                            ap->aalign);
21272097                 }
 21282098                 printf("\n");
 21292099         }
 21302100         if (in == 0)
 21312101                 printf("end arglist\n");
 21322102 }
 21332103 #endif
<>2134 -static int
 2135 -suemeq(struct suedef *s1, struct suedef *s2)
  2104+int
  2105+suemeq(struct attr *s1, struct attr *s2)
21362106 {
 21372107 
<>2138 -        GETSUE(s1, s1);
 2139 -        GETSUE(s2, s2);
  2108+        return (strmemb(s1) == strmemb(s2));
  2109+}
21402110 
<>2141 -        return (s1->suem == s2->suem);
  2111+/*
  2112+ * Sanity-check old-style args.
  2113+ */
  2114+static NODE *
  2115+oldarg(NODE *p)
  2116+{
  2117+        if (p->n_op == TYPE)
  2118+                uerror("type is not an argument");
  2119+        if (p->n_type == FLOAT)
  2120+                return cast(p, DOUBLE, p->n_qual);
  2121+        return p;
21422122 }
 21432123 
 21442124 /*
     
 !
21882168         /* Check for undefined or late defined enums */
 21892169         if (BTYPE(f->n_type) == ENUMTY) {
 21902170                 /* not-yet check if declared enum */
<>2191 -                if (f->n_sue->suem->stype != ENUMTY)
 2192 -                        MODTYPE(f->n_type, f->n_sue->suem->stype);
  2171+                struct symtab *sq = strmemb(f->n_ap);
  2172+                if (sq->stype != ENUMTY)
  2173+                        MODTYPE(f->n_type, sq->stype);
21932174                 if (BTYPE(f->n_type) == ENUMTY)
<>2194 -                        uerror("enum %s not declared", f->n_sue->suem->sname);
  2175+                        uerror("enum %s not declared", sq->sname);
21952176         }
 21962177 
 21972178         /*
 21982179          * Do some basic checks.
 21992180          */
 22002181         if (f->n_df == NULL || (al = f->n_df[0].dfun) == NULL) {
<> 2182+                /*
  2183+                 * Handle non-prototype declarations.
  2184+                 */
22012185                 if (Wimplicit_function_declaration) {
 22022186                         if (f->n_sp != NULL) {
 22032187                                 if (strncmp(f->n_sp->sname,
     
 !
22112195                 /* floats must be cast to double */
 22122196                 if (a == NULL)
 22132197                         goto build;
<>2214 -                for (w = a; w->n_op == CM; w = w->n_left) {
 2215 -                        if (w->n_right->n_op == TYPE)
 2216 -                                uerror("type is not an argument");
 2217 -                        if (w->n_right->n_type != FLOAT)
 2218 -                                continue;
 2219 -                        w->n_right = argcast(w->n_right, DOUBLE,
 2220 -                            NULL, MKSUE(DOUBLE));
  2198+                if (a->n_op != CM) {
  2199+                        a = oldarg(a);
  2200+                } else {
  2201+                        for (w = a; w->n_left->n_op == CM; w = w->n_left)
  2202+                                w->n_right = oldarg(w->n_right);
  2203+                        w->n_left = oldarg(w->n_left);
22212204                 }
<>2222 -                if (a->n_op == TYPE)
 2223 -                        uerror("type is not an argument");
 2224 -                if (a->n_type == FLOAT) {
 2225 -                        MKTY(a, DOUBLE, 0, 0);
 2226 -                }
22272205                 goto build;
 22282206         }
 22292207         if (al->type == VOID) {
     
 !
23092287                                 }
 23102288 #ifndef NO_COMPLEX
 23112289                         } else if (type == STRTY &&
<>2312 -                            gcc_get_attr(apole->node->n_sue, ATTR_COMPLEX) &&
 2313 -                            gcc_get_attr(al[1].sue, ATTR_COMPLEX)) {
  2290+                            attr_find(apole->node->n_ap, ATTR_COMPLEX) &&
  2291+                            attr_find(al[1].sap, ATTR_COMPLEX)) {
23142292                                 /* Both are complex */
<>2315 -                                if (apole->node->n_sue->suem->stype !=
 2316 -                                    al[1].sue->suem->stype) {
  2293+                                if (strmemb(apole->node->n_ap)->stype !=
  2294+                                    strmemb(al[1].sap)->stype) {
23172295                                         /* must convert to correct type */
 23182296                                         w = talloc();
 23192297                                         *w = *apole->node;
<>2320 -                                        w = mkcmplx(w, al[1].sue->suem->stype);
  2298+                                        w = mkcmplx(w,
  2299+                                            strmemb(al[1].sap)->stype);
23212300                                         *apole->node = *w;
 23222301                                         nfree(w);
 23232302                                 }
 23242303                                 goto out;
 23252304 #endif
 23262305                         } else if (ISSOU(BTYPE(type))) {
<>2327 -                                if (!suemeq(apole->node->n_sue, al[1].sue))
  2306+                                if (!suemeq(apole->node->n_ap, al[1].sap))
23282307                                         goto incomp;
 23292308                         }
 23302309                         goto out;
     
 !
23442323                 /* Check for struct/union compatibility */
 23452324                 if (type == arrt) {
 23462325                         if (ISSOU(BTYPE(type))) {
<>2347 -                                if (suemeq(apole->node->n_sue, al[1].sue))
  2326+                                if (suemeq(apole->node->n_ap, al[1].sap))
23482327                                         goto out;
 23492328                         } else
 23502329                                 goto out;
     
 !
23662345                 werror("implicit conversion of argument %d due to prototype",
 23672346                     argidx);
 23682347 
<>2369 -skip:           if (ISSTR(BTYPE(arrt))) {
 2370 -                        MKTY(apole->node, arrt, 0, al[1].sue)
  2348+skip:           if (ISSOU(BTYPE(arrt))) {
  2349+                        MKTY(apole->node, arrt, 0, al[1].sap)
23712350                 } else {
<>2372 -                        MKTY(apole->node, arrt, 0, MKSUE(BTYPE(arrt)))
  2351+                        MKTY(apole->node, arrt, 0, MKAP(BTYPE(arrt)))
23732352                 }
 23742353 
 23752354 out:            al++;
<>2376 -                if (ISSTR(BTYPE(arrt)))
  2355+                if (ISSOU(BTYPE(arrt)))
23772356                         al++;
 23782357 #if 0
 23792358                 while (arrt > BTMASK && !ISFTN(arrt))
     
 !
24692448 
 24702449 done:           ty = BTYPE(usym->type);
 24712450                 t2 = usym->type;
<>2472 -                if (ISSTR(ty)) {
  2451+                if (ISSOU(ty)) {
24732452                         usym++, udef++;
<>2474 -                        if (usym->sue->suem != udef->sue->suem)
  2453+                        if (suemeq(usym->sap, udef->sap) == 0)
24752454                                 return 1;
 24762455                 }
 24772456 
     
 !
24972476         /* fix up the types, and check for legality */
 24982477 
 24992478         /* forward declared enums */
<>2500 -        if (BTYPE(p->n_sp->stype) == ENUMTY)
 2501 -                MODTYPE(p->n_sp->stype, p->n_sp->ssue->suem->stype);
  2479+        if (BTYPE(p->n_sp->stype) == ENUMTY) {
  2480+                MODTYPE(p->n_sp->stype, strmemb(p->n_sp->sap)->stype);
  2481+        }
25022482 
 25032483         if( (type = p->n_type) == UNDEF ) return;
 25042484         if ((mod2 = (type&TMASK))) {
     
 !
26812661         s->soffset = 0;
 26822662         s->slevel = (char)blevel;
 26832663         s->sdf = NULL;
<>2684 -        s->ssue = NULL;
  2664+        s->sap = NULL;
26852665         return s;
 26862666 }
 26872667 
     
 !
27432723 {
 27442724         NODE *p;
 27452725 
<>2746 -        p = block(NAME, NIL, NIL, FTN+VOID, 0, MKSUE(VOID));
  2726+        p = block(NAME, NIL, NIL, FTN+VOID, 0, MKAP(VOID));
27472727         p->n_sp = lookup(stack_chk_fail, SNORMAL);
 27482728         defid(p, EXTERN);
 27492729         nfree(p);
 27502730 
<>2751 -        p = block(NAME, NIL, NIL, INT, 0, MKSUE(INT));
  2731+        p = block(NAME, NIL, NIL, INT, 0, MKAP(INT));
27522732         p->n_sp = lookup(stack_chk_guard, SNORMAL);
 27532733         defid(p, EXTERN);
 27542734         nfree(p);
     
 !
27592739 {
 27602740         NODE *p, *q;
 27612741 
<>2762 -        q = block(NAME, NIL, NIL, INT, 0, MKSUE(INT));
  2742+        q = block(NAME, NIL, NIL, INT, 0, MKAP(INT));
27632743         q->n_sp = lookup(stack_chk_guard, SNORMAL);
 27642744         q = clocal(q);
 27652745 
 27662746         p = block(REG, NIL, NIL, INT, 0, 0);
 27672747         p->n_lval = 0;
 27682748         p->n_rval = FPREG;
<>2769 -        q = block(ER, p, q, INT, 0, MKSUE(INT));
  2749+        q = block(ER, p, q, INT, 0, MKAP(INT));
27702750         q = clocal(q);
 27712751 
<>2772 -        p = block(NAME, NIL, NIL, INT, 0, MKSUE(INT));
  2752+        p = block(NAME, NIL, NIL, INT, 0, MKAP(INT));
27732753         p->n_qual = VOL >> TSHIFT;
 27742754         p->n_sp = lookup(stack_chk_canary, SNORMAL);
 27752755         defid(p, AUTO);
     
 !
27952775                 t = BOOL_TYPE;
 27962776 
 27972777         if (t != VOID && !ISSOU(t)) {
<>2798 -                p = tempnode(0, t, cftnsp->sdf, cftnsp->ssue);
  2778+                p = tempnode(0, t, cftnsp->sdf, cftnsp->sap);
27992779                 tmpnr = regno(p);
<>2800 -                q = block(REG, NIL, NIL, t, cftnsp->sdf, cftnsp->ssue);
  2780+                q = block(REG, NIL, NIL, t, cftnsp->sdf, cftnsp->sap);
28012781                 q->n_rval = RETREG(t);
 28022782                 ecomp(buildtree(ASSIGN, p, q));
 28032783         }
 28042784 
<>2805 -        p = block(NAME, NIL, NIL, INT, 0, MKSUE(INT));
  2785+        p = block(NAME, NIL, NIL, INT, 0, MKAP(INT));
28062786         p->n_sp = lookup(stack_chk_canary, SNORMAL);
 28072787         p = clocal(p);
 28082788 
 28092789         q = block(REG, NIL, NIL, INT, 0, 0);
 28102790         q->n_lval = 0;
 28112791         q->n_rval = FPREG;
<>2812 -        q = block(ER, p, q, INT, 0, MKSUE(INT));
  2792+        q = block(ER, p, q, INT, 0, MKAP(INT));
28132793 
<>2814 -        p = block(NAME, NIL, NIL, INT, 0, MKSUE(INT));
  2794+        p = block(NAME, NIL, NIL, INT, 0, MKAP(INT));
28152795         p->n_sp = lookup(stack_chk_guard, SNORMAL);
 28162796         p = clocal(p);
 28172797 
 28182798         lab = getlab();
 28192799         cbranch(buildtree(EQ, p, q), bcon(lab));
 28202800 
<>2821 -        p = block(NAME, NIL, NIL, FTN+VOID, 0, MKSUE(VOID));
  2801+        p = block(NAME, NIL, NIL, FTN+VOID, 0, MKAP(VOID));
28222802         p->n_sp = lookup(stack_chk_fail, SNORMAL);
 28232803         p = clocal(p);
 28242804 
     
 !
28272807         plabel(lab);
 28282808 
 28292809         if (t != VOID && !ISSOU(t)) {
<>2830 -                p = tempnode(tmpnr, t, cftnsp->sdf, cftnsp->ssue);
 2831 -                q = block(REG, NIL, NIL, t, cftnsp->sdf, cftnsp->ssue);
  2810+                p = tempnode(tmpnr, t, cftnsp->sdf, cftnsp->sap);
  2811+                q = block(REG, NIL, NIL, t, cftnsp->sdf, cftnsp->sap);
28322812                 q->n_rval = RETREG(t);
 28332813                 ecomp(buildtree(ASSIGN, q, p));
 28342814         }
     
 !
28382818  * Allocate on the permanent heap for inlines, otherwise temporary heap.
 28392819  */
 28402820 void *
<> 2821+blkalloc(int size)
  2822+{
  2823+        return isinlining || blevel < 2permalloc(size) : tmpalloc(size);
  2824+}
  2825+
  2826+/*
  2827+ * Allocate on the permanent heap for inlines, otherwise temporary heap.
  2828+ */
  2829+void *
28412830 inlalloc(int size)
 28422831 {
 28432832         return isinliningpermalloc(size) : tmpalloc(size);
 28442833 }
 28452834 
<> 2835+struct attr *
  2836+attr_new(int type, int nelem)
  2837+{
  2838+        struct attr *ap;
  2839+        int sz;
  2840+
  2841+        sz = sizeof(struct attr) + nelem * sizeof(union aarg);
  2842+
  2843+        ap = memset(blkalloc(sz), 0, sz);
  2844+        ap->atype = type;
  2845+        return ap;
  2846+}
  2847+
  2848+/*
  2849+ * Add attribute list new before old and return new.
  2850+ */
  2851+struct attr *
  2852+attr_add(struct attr *old, struct attr *new)
  2853+{
  2854+        struct attr *ap;
  2855+
  2856+        if (new == NULL)
  2857+                return old; /* nothing to add */
  2858+
  2859+        for (ap = new; ap->next; ap = ap->next)
  2860+                ;
  2861+        ap->next = old;
  2862+        return new;
  2863+}
  2864+
  2865+/*
  2866+ * Search for attribute type in list ap.  Return entry or NULL.
  2867+ */
  2868+struct attr *
  2869+attr_find(struct attr *ap, int type)
  2870+{
  2871+
  2872+        for (; ap && ap->atype != type; ap = ap->next)
  2873+                ;
  2874+        return ap;
  2875+}
  2876+
  2877+/*
  2878+ * Copy an attribute struct.
  2879+ * Return destination.
  2880+ */
  2881+struct attr *
  2882+attr_copy(struct attr *aps, struct attr *apd, int n)
  2883+{
  2884+        int sz = sizeof(struct attr) + n * sizeof(union aarg);
  2885+        return memcpy(apd, aps, sz);
  2886+}
  2887+
  2888+/*
  2889+ * Duplicate an attribute, like strdup.
  2890+ */
  2891+struct attr *
  2892+attr_dup(struct attr *ap, int n)
  2893+{
  2894+        int sz = sizeof(struct attr) + n * sizeof(union aarg);
  2895+        ap = memcpy(blkalloc(sz), ap, sz);
  2896+        ap->next = NULL;
  2897+        return ap;
  2898+}
  2899+
  2900+/*
  2901+ * Fetch pointer to first member in a struct list.
  2902+ */
  2903+struct symtab *
  2904+strmemb(struct attr *ap)
  2905+{
  2906+
  2907+        if ((ap = attr_find(ap, ATTR_STRUCT)) == NULL)
  2908+                cerror("strmemb");
  2909+        return ap->amlist;
  2910+}
  2911+
28462912 #ifndef NO_COMPLEX
 28472913 
 28482914 static char *real, *imag;
     
 !
28542920 void
 28552921 complinit()
 28562922 {
<> 2923+        struct attr *ap;
28572924         struct rstack *rp;
 28582925         NODE *p, *q;
 28592926         char *n[] = { "0f", "0d", "0l" };
     
 !
28632930         ddebug = 0;
 28642931         real = addname("__real");
 28652932         imag = addname("__imag");
<>2866 -        p = block(NAME, NIL, NIL, FLOAT, 0, MKSUE(FLOAT));
  2933+        p = block(NAME, NIL, NIL, FLOAT, 0, MKAP(FLOAT));
28672934         for (i = 0; i < 3; i++) {
 28682935                 p->n_type = FLOAT+i;
<>2869 -                p->n_sue = MKSUE(FLOAT+i);
 2870 -                rp = bstruct(NULL, STNAME, NULL);
  2936+                p->n_ap = MKAP(FLOAT+i);
  2937+                rpole = rp = bstruct(NULL, STNAME, NULL);
28712938                 soumemb(p, real, 0);
 28722939                 soumemb(p, imag, 0);
 28732940                 q = dclstruct(rp);
 28742941                 cxsp[i] = q->n_sp = lookup(addname(n[i]), 0);
 28752942                 defid(q, TYPEDEF);
<>2876 -                q->n_sp->ssue->suega = permalloc(sizeof(struct gcc_attr_pack) +
 2877 -                    sizeof(struct gcc_attrib));
 2878 -                q->n_sp->ssue->suega->num = 1;
 2879 -                q->n_sp->ssue->suega->ga[0].atype = ATTR_COMPLEX;
  2943+                ap = attr_new(ATTR_COMPLEX, 0);
  2944+                q->n_sp->sap = attr_add(q->n_sp->sap, ap);
28802945                 nfree(q);
 28812946         }
 28822947         nfree(p);
     
 !
28922957 {
 28932958         TWORD tl, tr, t;
 28942959 
<>2895 -#define ANYCX(p) (p->n_type == STRTY && gcc_get_attr(p->n_sue, ATTR_COMPLEX))
 2896 -        tl = ANYCX(l) ? l->n_sue->suem->stype : l->n_type;
 2897 -        tr = ANYCX(r) ? r->n_sue->suem->stype : r->n_type;
  2960+        tl = ANYCX(l) ? strmemb(l->n_ap)->stype : l->n_type;
  2961+        tr = ANYCX(r) ? strmemb(r->n_ap)->stype : r->n_type;
28982962         if (ISITY(tl))
 28992963                 tl -= (FIMAG - FLOAT);
 29002964         if (ISITY(tr))
     
 !
29413005                 p = buildtree(ASSIGN, structref(ccopy(q), DOT, real), r);
 29423006                 p = comop(p, buildtree(ASSIGN, structref(ccopy(q), DOT, imag), i));
 29433007                 p = comop(p, q);
<>2944 -        } else if (p->n_sue->suem->stype != dt) {
 2945 -                q = cxstore(dt);
 2946 -                p = buildtree(ADDROF, p, NIL);
 2947 -                t = tempnode(0, p->n_type, p->n_df, p->n_sue);
 2948 -                p = buildtree(ASSIGN, ccopy(t), p);
 2949 -                p = comop(p, buildtree(ASSIGN, structref(ccopy(q), DOT, real),
 2950 -                    structref(ccopy(t), STREF, real)));
 2951 -                p = comop(p, buildtree(ASSIGN, structref(ccopy(q), DOT, imag),
 2952 -                    structref(t, STREF, imag)));
 2953 -                p = comop(p, q);
  3008+        } else {
  3009+                if (strmemb(p->n_ap)->stype != dt) {
  3010+                        q = cxstore(dt);
  3011+                        p = buildtree(ADDROF, p, NIL);
  3012+                        t = tempnode(0, p->n_type, p->n_df, p->n_ap);
  3013+                        p = buildtree(ASSIGN, ccopy(t), p);
  3014+                        p = comop(p, buildtree(ASSIGN,
  3015+                            structref(ccopy(q), DOT, real),
  3016+                            structref(ccopy(t), STREF, real)));
  3017+                        p = comop(p, buildtree(ASSIGN,
  3018+                            structref(ccopy(q), DOT, imag),
  3019+                            structref(t, STREF, imag)));
  3020+                        p = comop(p, q);
  3021+                }
29543022         }
 29553023         return p;
 29563024 }
 29573025 
 29583026 static NODE *
 29593027 cxasg(NODE *l, NODE *r)
 29603028 {
<> 3029+        TWORD tl, tr;
29613030 
<>2962 -        if (ANYCX(l) && ANYCX(r) &&
 2963 -            l->n_sue->suem->stype != r->n_sue->suem->stype) {
  3031+        tl = strmemb(l->n_ap)->stype;
  3032+        tr = strmemb(r->n_ap)->stype;
  3033+
  3034+        if (ANYCX(l) && ANYCX(r) && tl != tr) {
29643035                 /* different types in structs */
<>2965 -                r = mkcmplx(r, l->n_sue->suem->stype);
  3036+                r = mkcmplx(r, tl);
29663037         } else if (!ANYCX(l))
 29673038                 r = structref(r, DOT, ISITY(l->n_type) ? imag : real);
 29683039         else if (!ANYCX(r))
<>2969 -                r = mkcmplx(r, l->n_sue->suem->stype);
  3040+                r = mkcmplx(r, tl);
29703041         return buildtree(ASSIGN, l, r);
 29713042 }
 29723043 
     
 !
29933064 
 29943065         /* put a pointer to left and right elements in a TEMP */
 29953066         l = buildtree(ADDROF, l, NIL);
<>2996 -        ltemp = tempnode(0, l->n_type, l->n_df, l->n_sue);
  3067+        ltemp = tempnode(0, l->n_type, l->n_df, l->n_ap);
29973068         l = buildtree(ASSIGN, ccopy(ltemp), l);
 29983069 
 29993070         r = buildtree(ADDROF, r, NIL);
<>3000 -        rtemp = tempnode(0, r->n_type, r->n_df, r->n_sue);
  3071+        rtemp = tempnode(0, r->n_type, r->n_df, r->n_ap);
30013072         r = buildtree(ASSIGN, ccopy(rtemp), r);
 30023073 
 30033074         p = comop(l, r);
     
 !
31643235         NODE *q, *r;
 31653236 
 31663237         /* XXX side effects? */
<>3167 -        q = cxstore(p->n_sue->suem->stype);
  3238+        q = cxstore(strmemb(p->n_ap)->stype);
31683239         r = buildtree(ASSIGN, structref(ccopy(q), DOT, real),
 31693240             structref(ccopy(p), DOT, real));
 31703241         r = comop(r, buildtree(ASSIGN, structref(ccopy(q), DOT, imag),
     
 !
31793250 cxret(NODE *p, NODE *q)
 31803251 {
 31813252         /* XXX what if cast the other way? */
<>3182 -        return mkcmplx(p, q->n_sue->suem->stype);
  3253+        return mkcmplx(p, strmemb(q->n_ap)->stype);
<_31833254 }
 31843255 #endif
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-09-19 07:50 +0200