shithub: mc

Download patch

ref: 4fa7514cc3af92e33262bde7860239d5e65ebbe2
parent: d0331c3cfb6f27afe416b9cdb7b15e18b9083e3e
author: Ori Bernstein <[email protected]>
date: Sat Sep 6 17:18:49 EDT 2014

Error on declared but unimplemented functions.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -955,14 +955,17 @@
         ng = getdcl(globls, k[i]);
         /* if an export has an initializer, it shouldn't be declared in the
          * body */
-        if (nx->decl.init && ng)
-            fatal(nx->line, "Export %s double-defined on line %d", ctxstr(st, nx), ng->line);
-        if (ng && nx->decl.isgeneric != ng->decl.isgeneric)
-            fatal(nx->line, "Export %s defined with different genericness on line %d", ctxstr(st, nx), ng->line);
-        if (!ng)
-            putdcl(globls, nx);
-        else
+        if (ng) {
+            if (nx->decl.init)
+                fatal(nx->line, "Export %s double-defined on line %d", ctxstr(st, nx), ng->line);
+            if (nx->decl.isgeneric != ng->decl.isgeneric)
+                fatal(nx->line, "Export %s defined with different genericness on line %d", ctxstr(st, nx), ng->line);
             unify(st, nx, type(st, ng), type(st, nx));
+        } else {
+            if (!nx->decl.isextern && !nx->decl.isimport && !nx->decl.init && (nx->decl.isconst || nx->decl.isgeneric))
+                fatal(nx->line, "Export %s defined but not implemented", ctxstr(st, nx));
+            putdcl(globls, nx);
+        }
     }
     free(k);
 
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -268,6 +268,7 @@
             char  isgeneric;
             char  isextern;
             char  ishidden;
+            char  isimport;
         } decl;
 
         struct {
--- a/parse/use.c
+++ b/parse/use.c
@@ -168,6 +168,7 @@
     n->decl.isconst = rdbool(fd);
     n->decl.isgeneric = rdbool(fd);
     n->decl.isextern = rdbool(fd);
+    n->decl.isimport = 1;
 
     if (n->decl.isgeneric && !ctx)
         n->decl.init = unpickle(fd);