Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.184
 
1.185
 
MAIN:ragge:20071123160006
 
pftn.c
_>748748 NODE *
 749749 enumdcl(struct symtab *sp)
 750750 {
<> 751+        NODE *p;
751752         TWORD t;
 752753 
 753754 #ifdef ENUMSIZE
     
 !
764765                 sp->stype = t;
 765766                 sp->ssue = MKSUE(t);
 766767         }
<>767 -        return mkty(t, 0, MKSUE(t));
  768+        p = mkty(t, 0, MKSUE(t));
  769+        p->n_sp = sp;
  770+        return p;
768771 }
 769772 
 770773 /*
     
 !
774777 enumref(char *name)
 775778 {
 776779         struct symtab *sp;
<> 780+        NODE *p;
777781 
 778782         sp = lookup(name, STAGNAME);
 779783         if (sp->sclass != ENAME)
 780784                 uerror("enum %s undeclared", name);
 781785 
<>782 -        return mkty(sp->stype, 0, sp->ssue);
  786+        p = mkty(sp->stype, 0, sp->ssue);
  787+        p->n_sp = sp;
  788+        return p;
783789 }
 784790 
 785791 /*
     
 !
15981604 }
 15991605 
 16001606 /*
<>1601 - * Merges a type tree into one type. Returns one type node with merged types
 1602 - * and class stored in the su field. Frees all other nodes.
 1603 - * XXX - classes in typedefs?
  1607+ * Merge given types to a single node.
  1608+ * Any type can end up here.
  1609+ * p is the old node, q is the old (if any).
  1610+ * CLASS is AUTO, EXTERN, REGISTER, STATIC or TYPEDEF.
  1611+ * QUALIFIER is VOL or CON
  1612+ * TYPE is CHAR, SHORT, INT, LONG, SIGNED, UNSIGNED, VOID, BOOL, FLOAT,
  1613+ *      DOUBLE, STRTY, UNIONTY.
16041614  */
 16051615 NODE *
 16061616 typenode(NODE *p)
 16071617 {
<>1608 -        NODE *l, *sp = NULL;
 1609 -        int class = 0, adj, noun, sign;
 1610 -        TWORD qual = 0;
  1618+        NODE *q, *saved;
  1619+        TWORD type;
  1620+        int class, qual;
  1621+        int sig, uns;
16111622 
<>1612 -        adj = INT;      /* INT, LONG or SHORT */
 1613 -        noun = UNDEF;   /* INT, CHAR or FLOAT */
 1614 -        sign = 0;       /* 0, SIGNED or UNSIGNED */
  1623+        type = class = qual = sig = uns = 0;
  1624+        saved = NIL;
16151625 
<>1616 -        /* Remove initial QUALIFIERs */
 1617 -        if (p && p->n_op == QUALIFIER) {
 1618 -                qual = p->n_type;
 1619 -                l = p->n_left;
 1620 -                nfree(p);
 1621 -                p = l;
 1622 -        }
  1626+        if (strunem != 0)
  1627+                class = strunem;
16231628 
<>1624 -        /* Handle initial classes special */
 1625 -        if (p && p->n_op == CLASS) {
 1626 -                class = p->n_type;
 1627 -                l = p->n_left;
 1628 -                nfree(p);
 1629 -                p = l;
 1630 -        }
 1631 -
 1632 -        /* Remove more QUALIFIERs */
 1633 -        if (p && p->n_op == QUALIFIER) {
 1634 -                qual |= p->n_type;
 1635 -                l = p->n_left;
 1636 -                nfree(p);
 1637 -                p = l;
 1638 -        }
 1639 -
 1640 -ag:     if (p && p->n_op == TYPE) {
 1641 -                if (p->n_left == NIL) {
 1642 -#ifdef CHAR_UNSIGNED
 1643 -                        if (p->n_type == CHAR)
 1644 -                                p->n_type = UCHAR;
 1645 -#endif
 1646 -                        if (p->n_type == SIGNED)
 1647 -                                p->n_type = INT;
 1648 -uni:                    p->n_lval = class;
 1649 -                        p->n_qual = qual >> TSHIFT;
 1650 -                        return p;
 1651 -                } else if (p->n_left->n_op == QUALIFIER) {
 1652 -                        qual |= p->n_left->n_type;
 1653 -                        l = p->n_left;
 1654 -                        p->n_left = l->n_left;
 1655 -                        nfree(l);
 1656 -                        goto ag;
 1657 -                } else if (ISSTR(p->n_type)) {
 1658 -                        /* Save node; needed for return */
 1659 -                        sp = p;
 1660 -                        p = p->n_left;
 1661 -                }
 1662 -        }
 1663 -
 1664 -        while (p != NIL) {
 1665 -                if (p->n_op == QUALIFIER) {
 1666 -                        qual |= p->n_type;
 1667 -                        goto next;
 1668 -                }
 1669 -                if (p->n_op == CLASS) {
 1670 -                        if (class != 0)
 1671 -                                uerror("too many storage classes");
  1629+        for (q = p; p; p = p->n_left) {
  1630+                switch (p->n_op) {
  1631+                case CLASS:
  1632+                        if (class)
  1633+                                goto bad; /* max 1 class */
16721634                         class = p->n_type;
<>1673 -                        goto next;
 1674 -                }
 1675 -                if (p->n_op != TYPE)
 1676 -                        cerror("typenode got notype %d", p->n_op);
 1677 -                switch (p->n_type) {
 1678 -                case UCHAR:
 1679 -                case USHORT: /* may come from typedef */
 1680 -                        if (sign != 0 || adj != INT)
 1681 -                                goto bad;
 1682 -                        noun = p->n_type;
16831635                         break;
<>1684 -                case SIGNED:
 1685 -                case UNSIGNED:
 1686 -                        if (sign != 0)
 1687 -                                goto bad;
 1688 -                        sign = p->n_type;
  1636+
  1637+                case QUALIFIER:
  1638+                        qual |= p->n_type >> TSHIFT;
16891639                         break;
<>1690 -                case LONG:
 1691 -                        if (adj == LONG) {
 1692 -                                adj = LONGLONG;
  1640+
  1641+                case TYPE:
  1642+                        if (p->n_sp != NULL || ISSOU(p->n_type)) {
  1643+                                /* typedef, enum or struct/union */
  1644+                                if (saved || type)
  1645+                                        goto bad;
  1646+                                saved = p;
16931647                                 break;
<>1694 -                        }
 1695 -                        /* FALLTHROUGH */
 1696 -                case SHORT:
 1697 -                        if (adj != INT)
  1648+                        } else if ((p->n_type == SIGNED && uns) ||
  1649+                            (p->n_type == UNSIGNED && sig))
16981650                                 goto bad;
<>1699 -                        adj = p->n_type;
 1700 -                        break;
 1701 -                case INT:
 1702 -                case CHAR:
 1703 -                case FLOAT:
 1704 -                case DOUBLE:
 1705 -                        if (noun != UNDEF)
 1706 -                                goto bad;
 1707 -                        noun = p->n_type;
 1708 -                        break;
 1709 -                case VOID:
 1710 -                        if (noun != UNDEF || adj != INT)
 1711 -                                goto bad;
 1712 -                        adj = noun = VOID;
 1713 -                        break;
 1714 -                case STRTY:
 1715 -                case UNIONTY:
 1716 -                        break;
 1717 -                default:
 1718 -                        goto bad;
  1651+
  1652+                        switch (p->n_type) {
  1653+                        case BOOL:
  1654+                        case CHAR:
  1655+                        case FLOAT:
  1656+                        case VOID:
  1657+                                if (type)
  1658+                                        goto bad;
  1659+                                type = p->n_type;
  1660+                                break;
  1661+                        case DOUBLE:
  1662+                                if (type == 0)
  1663+                                        type = DOUBLE;
  1664+                                else if (type == LONG)
  1665+                                        type = LDOUBLE;
  1666+                                else
  1667+                                        goto bad;
  1668+                                break;
  1669+                        case SHORT:
  1670+                                if (type == 0 || type == INT)
  1671+                                        type = SHORT;
  1672+                                else
  1673+                                        goto bad;
  1674+                                break;
  1675+                        case INT:
  1676+                                if (type == SHORT || type == LONG ||
  1677+                                    type == LONGLONG)
  1678+                                        break;
  1679+                                else if (type == 0)
  1680+                                        type = INT;
  1681+                                else
  1682+                                        goto bad;
  1683+                                break;
  1684+                        case LONG:
  1685+                                if (type == 0)
  1686+                                        type = LONG;
  1687+                                else if (type == INT)
  1688+                                        break;
  1689+                                else if (type == LONG)
  1690+                                        type = LONGLONG;
  1691+                                else if (type == DOUBLE)
  1692+                                        type = LDOUBLE;
  1693+                                else
  1694+                                        goto bad;
  1695+                                break;
  1696+                        case SIGNED:
  1697+                                if (sig || uns)
  1698+                                        goto bad;
  1699+                                sig = 1;
  1700+                                break;
  1701+                        case UNSIGNED:
  1702+                                if (sig || uns)
  1703+                                        goto bad;
  1704+                                uns = 1;
  1705+                                break;
  1706+                        default:
  1707+                                cerror("typenode");
  1708+                        }
17191709                 }
<>1720 -        next:
 1721 -                l = p->n_left;
 1722 -                nfree(p);
 1723 -                p = l;
17241710         }
<>1725 -
 1726 -        if (sp) {
 1727 -                p = sp;
 1728 -                goto uni;
  1711+        if (saved && type)
  1712+                goto bad;
  1713+        if (sig || uns) {
  1714+                if (type == 0)
  1715+                        type = sig ? INT : UNSIGNED;
  1716+                if (type > ULONGLONG)
  1717+                        goto bad;
  1718+                if (uns)
  1719+                        type = ENUNSIGN(type);
17291720         }
<>1730 -
17311721 #ifdef CHAR_UNSIGNED
<>1732 -        if (noun == CHAR && sign == 0)
 1733 -                sign = UNSIGNED;
  1722+        if (type == CHAR && sig == 0)
  1723+                type = UCHAR;
17341724 #endif
<>1735 -        if (noun == UNDEF) {
 1736 -                noun = INT;
 1737 -        } else if (noun == FLOAT) {
 1738 -                if (sign != 0 || adj == SHORT)
 1739 -                        goto bad;
 1740 -                noun = (adj == LONG ? DOUBLE : FLOAT);
 1741 -        } else if (noun == DOUBLE) {
 1742 -                if (sign != 0 || adj == SHORT)
 1743 -                        goto bad;
 1744 -                noun = (adj == LONG ? LDOUBLE : DOUBLE);
 1745 -        } else if (noun == CHAR && adj != INT)
 1746 -                goto bad;
17471725 
<>1748 -        if (adj != INT && (noun != DOUBLE && noun != LDOUBLE))
 1749 -                noun = adj;
 1750 -        if (sign == UNSIGNED)
 1751 -                noun += (UNSIGNED-INT);
  1726+        /* free the chain */
  1727+        while (q) {
  1728+                p = q->n_left;
  1729+                if (q != saved)
  1730+                        nfree(q);
  1731+                q = p;
  1732+        }
17521733 
<>1753 -        p = block(TYPE, NIL, NIL, noun, 0, 0);
 1754 -        p->n_qual = qual >> TSHIFT;
 1755 -        if (strunem != 0)
 1756 -                class = strunem;
  1734+        p = (saved ? saved : block(TYPE, NIL, NIL, type, 0, 0));
  1735+        p->n_qual = qual;
17571736         p->n_lval = class;
 17581737         return p;
 17591738 
     
 !
18001779 #endif
 18011780 
 18021781         idp->n_type = typ->n_type;
<>1803 -        idp->n_qual = (typ->n_qual << TSHIFT) | idp->n_qual; /* XXX ??? */
  1782+        idp->n_qual = typ->n_qual;
18041783 
 18051784         tylkp = &tylnk;
 18061785         tylkp->next = NULL;
     
 !
18251804         /* now idp is a single node: fix up type */
 18261805 
 18271806         idp->n_type = ctype(idp->n_type);
<>1828 -        idp->n_qual = DECQAL(idp->n_qual);
  1807+//      idp->n_qual = DECQAL(idp->n_qual);
<_18291808 
 18301809         /* in case ctype has rewritten things */
 18311810         if ((t = BTYPE(idp->n_type)) != STRTY && t != UNIONTY)
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-08-20 16:35 +0200