BSD 4_4 release
[unix-history] / usr / src / usr.bin / f77 / pass1.vax / exec.c
index a2c4413..1b61bfd 100644 (file)
@@ -1,12 +1,15 @@
-/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+/*-
+ * Copyright (c) 1980 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This module is believed to contain source code proprietary to AT&T.
+ * Use and redistribution is subject to the Berkeley Software License
+ * Agreement and your Software Agreement with AT&T (Western Electric).
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)exec.c     5.3 (Berkeley) %G%";
-#endif not lint
+static char sccsid[] = "@(#)exec.c     5.7 (Berkeley) 4/12/91";
+#endif /* not lint */
 
 /*
  * exec.c
 
 /*
  * exec.c
@@ -16,6 +19,24 @@ static char sccsid[] = "@(#)exec.c   5.3 (Berkeley) %G%";
  *
  * University of Utah CS Dept modification history:
  * 
  *
  * University of Utah CS Dept modification history:
  * 
+ * $Log:       exec.c,v $
+ * Revision 5.6  85/12/20  19:42:46  donn
+ * Change style of error reporting in last fix.
+ * 
+ * Revision 5.5  85/12/20  18:54:10  donn
+ * Complain about calls to things which aren't subroutines.
+ * 
+ * Revision 5.4  85/12/18  19:57:58  donn
+ * Assignment statements are executable statements -- advance the magic
+ * parser state to forbid DATA statements and statement functions.
+ * 
+ * Revision 5.3  85/11/25  00:23:49  donn
+ * 4.3 beta
+ * 
+ * Revision 5.2  85/08/10  04:07:36  donn
+ * Changed an error message to correct spelling and be more accurate.
+ * From Jerry Berkman.
+ * 
  * Revision 2.3  85/03/18  08:03:31  donn
  * Hacks for conversions from type address to numeric type -- prevent addresses
  * from being stored in shorts and prevent warnings about implicit conversions.
  * Revision 2.3  85/03/18  08:03:31  donn
  * Hacks for conversions from type address to numeric type -- prevent addresses
  * from being stored in shorts and prevent warnings about implicit conversions.
@@ -243,7 +264,7 @@ if(lp->tag != TPRIM)
 else if(lp->namep->vclass!=CLVAR && lp->argsp)
        {
        if(parstate >= INEXEC)
 else if(lp->namep->vclass!=CLVAR && lp->argsp)
        {
        if(parstate >= INEXEC)
-               err("assignment to an undimensioned array");
+               err("undimensioned array or statement function out of order");
        else
                mkstfunct(lp, rp);
        }
        else
                mkstfunct(lp, rp);
        }
@@ -258,6 +279,7 @@ else
                }
        if(parstate < INDATA)
                enddcl();
                }
        if(parstate < INDATA)
                enddcl();
+       parstate = INEXEC;
        if (optimflag)
                optbuff (SKEQ, mkexpr(OPASSIGN, mklhs(lp), fixtype(rp)), 0, 0);
        else
        if (optimflag)
                optbuff (SKEQ, mkexpr(OPASSIGN, mklhs(lp), fixtype(rp)), 0, 0);
        else
@@ -318,6 +340,17 @@ struct Labelblock *labels[ ];
 {
 register expptr p;
 
 {
 register expptr p;
 
+if (name->vdcldone)
+       if (name->vclass != CLPROC && name->vclass != CLENTRY)
+               {
+               dclerr("call to non-subroutine", name);
+               return;
+               }
+       else if (name->vtype != TYSUBR)
+               {
+               dclerr("subroutine invocation of function", name);
+               return;
+               }
 settype(name, TYSUBR, ENULL);
 p = mkfunct( mkprim(name, args, CHNULL) );
 p->exprblock.vtype = p->exprblock.leftp->headblock.vtype = TYINT;
 settype(name, TYSUBR, ENULL);
 p = mkfunct( mkprim(name, args, CHNULL) );
 p->exprblock.vtype = p->exprblock.leftp->headblock.vtype = TYINT;
@@ -353,11 +386,11 @@ if(p)
                }
        else if( ISINT(p->constblock.vtype) )
                {
                }
        else if( ISINT(p->constblock.vtype) )
                {
-               q = convic(p->constblock.const.ci);
+               q = convic(p->constblock.constant.ci);
                n = strlen(q);
                if(n > 0)
                        {
                n = strlen(q);
                if(n > 0)
                        {
-                       p->constblock.const.ccp = copyn(n, q);
+                       p->constblock.constant.ccp = copyn(n, q);
                        p->constblock.vtype = TYCHAR;
                        p->constblock.vleng = (expptr) ICON(n);
                        }
                        p->constblock.vtype = TYCHAR;
                        p->constblock.vleng = (expptr) ICON(n);
                        }
@@ -385,9 +418,9 @@ else
 #define DOLIMIT        par[1]
 #define DOINCR par[2]
 
 #define DOLIMIT        par[1]
 #define DOINCR par[2]
 
-#define CONSTINIT  const[0]
-#define CONSTLIMIT const[1]
-#define CONSTINCR  const[2]
+#define CONSTINIT  constant[0]
+#define CONSTLIMIT constant[1]
+#define CONSTINCR  constant[2]
 
 #define VARSTEP        0
 #define POSSTEP        1
 
 #define VARSTEP        0
 #define POSSTEP        1
@@ -407,7 +440,7 @@ chainp spec;
   int dotype, incsign;
   Addrp dovarp, dostgp;
   expptr par[3];
   int dotype, incsign;
   Addrp dovarp, dostgp;
   expptr par[3];
-  expptr const[3];
+  expptr constant[3];
   Slotp doslot;
 
   pushctl(CTLDO);
   Slotp doslot;
 
   pushctl(CTLDO);
@@ -441,11 +474,11 @@ chainp spec;
 
 
       if (ISCONST(q))
 
 
       if (ISCONST(q))
-       const[i] = mkconv(dotype, q);
+       constant[i] = mkconv(dotype, q);
       else
        {
          frexpr(q);
       else
        {
          frexpr(q);
-         const[i] = NULL;
+         constant[i] = NULL;
        }
 
       par[i++] = mkconv(dotype, p);
        }
 
       par[i++] = mkconv(dotype, p);