merge in latest Linton version
[unix-history] / usr / src / old / dbx / check.c
index becdd3a..ebcc542 100644 (file)
@@ -1,6 +1,14 @@
-/* Copyright (c) 1982 Regents of the University of California */
+/*
+ * Copyright (c) 1983 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[] = "@(#)check.c    5.2 (Berkeley) %G%";
+#endif not lint
 
 
-static char sccsid[] = "@(#)check.c    1.6 (Berkeley) %G%";
+static char rcsid[] = "$Header: check.c,v 1.5 84/12/26 10:38:35 linton Exp $";
 
 /*
  * Check a tree for semantic correctness.
 
 /*
  * Check a tree for semantic correctness.
@@ -16,6 +24,7 @@ static        char sccsid[] = "@(#)check.c    1.6 (Berkeley) %G%";
 #include "object.h"
 #include "mappings.h"
 #include "process.h"
 #include "object.h"
 #include "mappings.h"
 #include "process.h"
+#include <signal.h>
 
 #ifndef public
 #endif
 
 #ifndef public
 #endif
@@ -30,11 +39,56 @@ static      char sccsid[] = "@(#)check.c    1.6 (Berkeley) %G%";
 public check(p)
 register Node p;
 {
 public check(p)
 register Node p;
 {
+    Node p1, p2;
     Address addr;
     Symbol f;
 
     checkref(p);
     switch (p->op) {
     Address addr;
     Symbol f;
 
     checkref(p);
     switch (p->op) {
+       case O_ASSIGN:
+           p1 = p->value.arg[0];
+           p2 = p->value.arg[1];
+           if (varIsSet("$unsafeassign")) {
+               if (size(p1->nodetype) != size(p2->nodetype)) {
+                   error("incompatible sizes");
+               }
+           } else if (not compatible(p1->nodetype, p2->nodetype)) {
+               error("incompatible types");
+           }
+           break;
+
+       case O_CATCH:
+       case O_IGNORE:
+           if (p->value.lcon < 0 or p->value.lcon > NSIG) {
+               error("invalid signal number");
+           }
+           break;
+
+       case O_CONT:
+           if (p->value.lcon != DEFSIG and (
+               p->value.lcon < 0 or p->value.lcon > NSIG)
+           ) {
+               error("invalid signal number");
+           }
+           break;
+
+       case O_DUMP:
+           if (p->value.arg[0] != nil) {
+               if (p->value.arg[0]->op == O_SYM) {
+                   f = p->value.arg[0]->value.sym;
+                   if (not isblock(f)) {
+                       error("\"%s\" is not a block", symname(f));
+                   }
+               } else {
+                   beginerrmsg();
+                   fprintf(stderr, "expected a symbol, found \"");
+                   prtree(stderr, p->value.arg[0]);
+                   fprintf(stderr, "\"");
+                   enderrmsg();
+               }
+           }
+           break;
+
        case O_LIST:
            if (p->value.arg[0]->op == O_SYM) {
                f = p->value.arg[0]->value.sym;
        case O_LIST:
            if (p->value.arg[0]->op == O_SYM) {
                f = p->value.arg[0]->value.sym;
@@ -58,6 +112,7 @@ register Node p;
            chkstop(p);
            break;
 
            chkstop(p);
            break;
 
+       case O_CALLPROC:
        case O_CALL:
            if (not isroutine(p->value.arg[0]->nodetype)) {
                beginerrmsg();
        case O_CALL:
            if (not isroutine(p->value.arg[0]->nodetype)) {
                beginerrmsg();
@@ -68,6 +123,13 @@ register Node p;
            }
            break;
 
            }
            break;
 
+       case O_WHEREIS:
+           if (p->value.arg[0]->op == O_SYM and
+             p->value.arg[0]->value.sym == nil) {
+               error("symbol not defined");
+           }
+           break;
+
        default:
            break;
     }
        default:
            break;
     }
@@ -173,6 +235,12 @@ Node b;
                    b->value.sym = p;
                }
            }
                    b->value.sym = p;
                }
            }
+       } else if (
+           b->value.sym->class == VAR and
+           b->value.sym->name == b->value.sym->block->name and
+           b->value.sym->block->class == FUNC
+       ) {
+           b->value.sym = b->value.sym->block;
        } else if (not isblock(b->value.sym)) {
            error("\"%s\" is not a subprogram", symname(b->value.sym));
        }
        } else if (not isblock(b->value.sym)) {
            error("\"%s\" is not a subprogram", symname(b->value.sym));
        }