Commit 30f2799f authored by Russ Cox's avatar Russ Cox

disable "any" except during canned imports.

new flag -A enables it during mkbuiltin.
avoids mysterious errors in programs
that refer to any accidentally.

R=ken
OCL=30763
CL=30763
parent ae11e9eb
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <ar.h> #include <ar.h>
extern int yychar; extern int yychar;
Sym *anysym;
#define DBG if(!debug['x']);else print #define DBG if(!debug['x']);else print
enum enum
...@@ -120,6 +121,7 @@ main(int argc, char *argv[]) ...@@ -120,6 +121,7 @@ main(int argc, char *argv[])
usage: usage:
print("flags:\n"); print("flags:\n");
// -A is allow use of "any" type, for bootstrapping
print(" -I DIR search for packages in DIR\n"); print(" -I DIR search for packages in DIR\n");
print(" -d print declarations\n"); print(" -d print declarations\n");
print(" -e no limit on number of errors printed\n"); print(" -e no limit on number of errors printed\n");
...@@ -325,6 +327,9 @@ unimportfile(void) ...@@ -325,6 +327,9 @@ unimportfile(void)
{ {
linehist(nil, 0, 0); linehist(nil, 0, 0);
if(!debug['A'])
anysym->def = nil;
if(curio.bin != nil) { if(curio.bin != nil) {
Bterm(curio.bin); Bterm(curio.bin);
curio.bin = nil; curio.bin = nil;
...@@ -341,6 +346,9 @@ cannedimports(char *file, char *cp) ...@@ -341,6 +346,9 @@ cannedimports(char *file, char *cp)
lineno++; // if sys.6 is included on line 1, lineno++; // if sys.6 is included on line 1,
linehist(file, 0, 0); // the debugger gets confused linehist(file, 0, 0); // the debugger gets confused
if(!debug['A'])
anysym->def = typenod(types[TANY]);
pushedio = curio; pushedio = curio;
curio.bin = nil; curio.bin = nil;
curio.peekc = 0; curio.peekc = 0;
...@@ -1296,6 +1304,11 @@ lexinit(void) ...@@ -1296,6 +1304,11 @@ lexinit(void)
types[etype] = t; types[etype] = t;
} }
s->def = typenod(t); s->def = typenod(t);
if(etype == TANY) {
anysym = s;
if(!debug['A'])
s->def = nil;
}
continue; continue;
} }
......
...@@ -15,7 +15,7 @@ gcc -o mkbuiltin1 mkbuiltin1.c ...@@ -15,7 +15,7 @@ gcc -o mkbuiltin1 mkbuiltin1.c
rm -f _builtin.c rm -f _builtin.c
for i in sys unsafe for i in sys unsafe
do do
$GC $i.go $GC -A $i.go
./mkbuiltin1 $i >>_builtin.c ./mkbuiltin1 $i >>_builtin.c
done done
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment