BSD 4_3 release
[unix-history] / usr / src / usr.bin / f77 / src / f77pass1 / equiv.c
index 430261a..93deaa6 100644 (file)
@@ -1,3 +1,30 @@
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char *sccsid[] = "@(#)equiv.c   5.1 (Berkeley) 6/7/85";
+#endif not lint
+
+/*
+ * equiv.c
+ *
+ * Routines related to equivalence class processing, f77 compiler, 4.2 BSD.
+ *
+ * University of Utah CS Dept modification history:
+ * 
+ * Revision 3.2  85/01/14  00:14:12  donn
+ * Fixed bug in eqvcommon that was causing the calculations of multilevel
+ * equivalences to be screwed up.
+ * 
+ * Revision 3.1  84/10/13  01:16:08  donn
+ * Installed Jerry Berkman's version; added UofU comment header.
+ * 
+ */
+
+
 #include "defs.h"
 
 #ifdef SDB
 #include "defs.h"
 
 #ifdef SDB
@@ -7,8 +34,6 @@
 #      endif
 #endif
 
 #      endif
 #endif
 
-/* ROUTINES RELATED TO EQUIVALENCE CLASS PROCESSING */
-
 /* called at end of declarations section to process chains
    created by EQUIVALENCE statements
  */
 /* called at end of declarations section to process chains
    created by EQUIVALENCE statements
  */
@@ -26,6 +51,7 @@ expptr offp, suboffset();
 int ns, nsubs();
 chainp cp;
 char *memname();
 int ns, nsubs();
 chainp cp;
 char *memname();
+int doeqverr = 0;
 
 for(i = 0 ; i < nequiv ; ++i)
        {
 
 for(i = 0 ; i < nequiv ; ++i)
        {
@@ -37,6 +63,7 @@ for(i = 0 ; i < nequiv ; ++i)
                {
                offset = 0;
                itemp = q->eqvitem.eqvlhs;
                {
                offset = 0;
                itemp = q->eqvitem.eqvlhs;
+               if( itemp == NULL ) fatal("error processing equivalence");
                equivdcl = YES;
                vardcl(np = itemp->namep);
                equivdcl = NO;
                equivdcl = YES;
                vardcl(np = itemp->namep);
                equivdcl = NO;
@@ -58,9 +85,10 @@ for(i = 0 ; i < nequiv ; ++i)
                        if(ISICON(offp))
                                offset = offp->constblock.const.ci;
                        else    {
                        if(ISICON(offp))
                                offset = offp->constblock.const.ci;
                        else    {
-                               dclerr("nonconstant subscript in equivalence ",
+                               dclerr("illegal subscript in equivalence ",
                                        np);
                                np = NULL;
                                        np);
                                np = NULL;
+                               doeqverr = 1;
                                }
                        frexpr(offp);
                        }
                                }
                        frexpr(offp);
                        }
@@ -68,8 +96,9 @@ for(i = 0 ; i < nequiv ; ++i)
 
                if(np && (leng = iarrlen(np))<0)
                        {
 
                if(np && (leng = iarrlen(np))<0)
                        {
-                       dclerr("adjustable in equivalence", np);
+                       dclerr("argument in equivalence", np);
                        np = NULL;
                        np = NULL;
+                       doeqverr =1;
                        }
 
                if(np) switch(np->vstg)
                        }
 
                if(np) switch(np->vstg)
@@ -87,6 +116,7 @@ for(i = 0 ; i < nequiv ; ++i)
                        default:
                                dclerr("bad storage class in equivalence", np);
                                np = NULL;
                        default:
                                dclerr("bad storage class in equivalence", np);
                                np = NULL;
+                               doeqverr = 1;
                                break;
                        }
 
                                break;
                        }
 
@@ -111,6 +141,7 @@ for(i = 0 ; i < nequiv ; ++i)
                                        {
                                        if(np->voffset + q->eqvoffset != 0)
                                                dclerr("inconsistent equivalence", np);
                                        {
                                        if(np->voffset + q->eqvoffset != 0)
                                                dclerr("inconsistent equivalence", np);
+                                               doeqverr = 1;
                                        }
                                else    {
                                        offset = np->voffset;
                                        }
                                else    {
                                        offset = np->voffset;
@@ -127,7 +158,8 @@ for(i = 0 ; i < nequiv ; ++i)
                }
        }
 
                }
        }
 
-for(i = 0 ; i < nequiv ; ++i)
+if( !doeqverr )
+  for(i = 0 ; i < nequiv ; ++i)
        {
        p = & eqvclass[i];
        if(p->eqvbottom!=0 || p->eqvtop!=0)     /* a live chain */
        {
        p = & eqvclass[i];
        if(p->eqvbottom!=0 || p->eqvtop!=0)     /* a live chain */
@@ -201,7 +233,7 @@ for(q = p->equivs ; q ; q = q->eqvnextp)
                                offq = comoffset - q->eqvoffset - np->voffset;
                                np->vstg = STGCOMMON;
                                np->vardesc.varno = comno;
                                offq = comoffset - q->eqvoffset - np->voffset;
                                np->vstg = STGCOMMON;
                                np->vardesc.varno = comno;
-                               np->voffset = comoffset - q->eqvoffset;
+                               np->voffset = comoffset + q->eqvoffset;
                                if(ovarno != (p - eqvclass))
                                        eqvcommon(&eqvclass[ovarno], comno, offq);
 #ifdef SDB
                                if(ovarno != (p - eqvclass))
                                        eqvcommon(&eqvclass[ovarno], comno, offq);
 #ifdef SDB