Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.167
 
1.168
 
MAIN:ragge:20070909100101
 
pftn.c
_>136136 void vfdalign(int n);
 137137 static void ssave(struct symtab *);
 138138 static void strprint(void);
<> 139+static void alprint(union arglist *al, int in);
  140+static void lcommadd(struct symtab *sp);
139141 
 140142 int ddebug = 0;
 141143 
<> 144+/*
  145+ * Declaration of an identifier.  Handles redeclarations, hiding,
  146+ * incomplete types and forward declarations.
  147+ */
  148+
142149 void
 143150 defid(NODE *q, int class)
 144151 {
     
 !
287294                         p->sclass = STATIC;
 288295                         return;
 289296                 }
<> 297+                if (changed || (scl == STATIC && blevel == slev))
  298+                        return; /* identical redeclaration */
290299                 break;
 291300 
 292301         case USTATIC:
     
 !
363372                         return;
 364373                 }
 365374         }
<> 375+        if (blevel == 0)
  376+                uerror("redeclaration of %s", p->sname);
366377         q->n_sp = p = hide(p);
 367378 
 368379         enter/* make a new entry */
     
 !
14191430 }
 14201431 
 14211432 /*
<>1422 - * handle unitialized declarations
 1423 - * assumed to be not functions
  1433+ * handle unitialized declarations assumed to be not functions:
  1434+ * int a;
  1435+ * extern int a;
  1436+ * static int a;
14241437  */
 14251438 void
 14261439 nidcl(NODE *p, int class)
     
 !
14351448                 else if (blevel != 0 || instruct)
 14361449                         cerror( "nidcl error" );
 14371450                 else /* blevel = 0 */
<>1438 -                        commflag = (class = noinit()) == EXTERN;
  1451+                        commflag = 1, class = EXTERN;
14391452         }
 14401453 
 14411454         defid(p, class);
     
 !
14451458         if (ISARY(sp->stype) && sp->sdf->ddim == 0)
 14461459                 return;
 14471460 
<> 1461+        if (sp->sflags & SASG)
  1462+                return; /* already initialized */
  1463+
14481464         switch (class) {
 14491465         case EXTDEF:
 14501466                 /* simulate initialization by 0 */
 14511467                 simpleinit(p->n_sp, bcon(0));
 14521468                 break;
 14531469         case EXTERN:
 14541470                 if (commflag)
<>1455 -                        commdec(p->n_sp);
  1471+                        lcommadd(p->n_sp);
14561472                 else
 14571473                         extdec(p->n_sp);
 14581474                 break;
 14591475         case STATIC:
<>1460 -                lcommdec(p->n_sp);
  1476+                if (blevel == 0)
  1477+                        lcommadd(p->n_sp);
  1478+                else
  1479+                        lcommdec(p->n_sp);
14611480                 break;
 14621481         }
 14631482 }
 14641483 
<> 1484+struct lcd {
  1485+        SLIST_ENTRY(lcd) next;
  1486+        struct symtab *sp;
  1487+};
  1488+
  1489+static SLIST_HEAD(, lcd) lhead = { NULL, &lhead.q_forw};
  1490+
14651491 /*
<> 1492+ * Add a local common statement to the printout list.
  1493+ */
  1494+void
  1495+lcommadd(struct symtab *sp)
  1496+{
  1497+        struct lcd *lc, *lcp;
  1498+
  1499+        lcp = NULL;
  1500+        SLIST_FOREACH(lc, &lhead, next) {
  1501+                if (lc->sp == sp)
  1502+                        return; /* already exists */
  1503+                if (lc->sp == NULL && lcp == NULL)
  1504+                        lcp = lc;
  1505+        }
  1506+        if (lcp == NULL) {
  1507+                lc = permalloc(sizeof(struct lcd));
  1508+                lc->sp = sp;
  1509+                SLIST_INSERT_LAST(&lhead, lc, next);
  1510+        } else
  1511+                lcp->sp = sp;
  1512+}
  1513+
  1514+/*
  1515+ * Delete a local common statement.
  1516+ */
  1517+void
  1518+lcommdel(struct symtab *sp)
  1519+{
  1520+        struct lcd *lc;
  1521+
  1522+        SLIST_FOREACH(lc, &lhead, next) {
  1523+                if (lc->sp == sp) {
  1524+                        lc->sp = NULL;
  1525+                        return;
  1526+                }
  1527+        }
  1528+}
  1529+
  1530+/*
  1531+ * Print out the remaining common statements.
  1532+ */
  1533+void
  1534+lcommprint(void)
  1535+{
  1536+        struct lcd *lc;
  1537+
  1538+        SLIST_FOREACH(lc, &lhead, next) {
  1539+                if (lc->sp != NULL) {
  1540+                        if (lc->sp->sclass == STATIC)
  1541+                                lcommdec(lc->sp);
  1542+                        else
  1543+                                commdec(lc->sp);
  1544+                }
  1545+        }
  1546+}
  1547+
  1548+/*
14661549  * Merges a type tree into one type. Returns one type node with merged types
 14671550  * and class stored in the su field. Frees all other nodes.
 14681551  * XXX - classes in typedefs?
     
 !
17191802         int num, cnt, i, j, k;
 17201803         TWORD ty;
 17211804 
<> 1805+#ifdef PCC_DEBUG
  1806+        if (pdebug) {
  1807+                printf("arglist %p\n", n);
  1808+                fwalk(n, eprint, 0);
  1809+        }
  1810+#endif
17221811         /* First: how much to allocate */
 17231812         for (num = cnt = 0, w = n; w->n_op == CM; w = w->n_left) {
 17241813                 cnt++;  /* Number of levels */
     
 !
17831872         if (k > num)
 17841873                 cerror("arglist: k%d > num%d", k, num);
 17851874         tfree(n);
<> 1875+        if (pdebug)
  1876+                alprint(al, 0);
17861877         return al;
 17871878 }
 17881879 
     
 !
19552046                 fwalk(a, eprint, 0);
 19562047         }
 19572048 #endif
<> 2049+
19582050         /* First let MD code do something */
 19592051         calldec(f, a);
<> 2052+/* XXX XXX hack */
  2053+        if ((f->n_op == CALL || f->n_op == CALL) &&
  2054+            f->n_left->n_op == ADDROF &&
  2055+            f->n_left->n_left->n_op == NAME &&
  2056+            (f->n_left->n_left->n_type & 0x7e0) == 0x4c0)
  2057+                goto build;
  2058+/* XXX XXX hack */
19602059 
 19612060 #ifndef NO_C_BUILTINS
 19622061         /* check for alloca */
     
 !
20002099         }
 20012100 #ifdef PCC_DEBUG
 20022101         if (pdebug) {
<>2003 -                printf("arglist for %s\n",
  2102+                printf("arglist for %p\n",
<_20042103                     f->n_sp != NULL ? f->n_sp->sname : "function pointer");
 20052104                 alprint(al, 0);
 20062105         }
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-16 17:31 +0200