]> Cypherpunks repositories - gostls13.git/commitdiff
disable "any" except during canned imports.
authorRuss Cox <rsc@golang.org>
Thu, 25 Jun 2009 23:22:46 +0000 (16:22 -0700)
committerRuss Cox <rsc@golang.org>
Thu, 25 Jun 2009 23:22:46 +0000 (16:22 -0700)
new flag -A enables it during mkbuiltin.
avoids mysterious errors in programs
that refer to any accidentally.

R=ken
OCL=30763
CL=30763

src/cmd/gc/lex.c
src/cmd/gc/mkbuiltin

index 2cad4310ebf461cdc658866e39fd7ccec3d01099..32a92984210e584b17f2945ee13890f6366db213 100644 (file)
@@ -9,6 +9,7 @@
 #include <ar.h>
 
 extern int yychar;
+Sym *anysym;
 
 #define        DBG     if(!debug['x']);else print
 enum
@@ -120,6 +121,7 @@ main(int argc, char *argv[])
 
 usage:
        print("flags:\n");
+       // -A is allow use of "any" type, for bootstrapping
        print("  -I DIR search for packages in DIR\n");
        print("  -d print declarations\n");
        print("  -e no limit on number of errors printed\n");
@@ -325,6 +327,9 @@ unimportfile(void)
 {
        linehist(nil, 0, 0);
 
+       if(!debug['A'])
+               anysym->def = nil;
+
        if(curio.bin != nil) {
                Bterm(curio.bin);
                curio.bin = nil;
@@ -341,6 +346,9 @@ cannedimports(char *file, char *cp)
        lineno++;               // if sys.6 is included on line 1,
        linehist(file, 0, 0);   // the debugger gets confused
 
+       if(!debug['A'])
+               anysym->def = typenod(types[TANY]);
+
        pushedio = curio;
        curio.bin = nil;
        curio.peekc = 0;
@@ -1296,6 +1304,11 @@ lexinit(void)
                                types[etype] = t;
                        }
                        s->def = typenod(t);
+                       if(etype == TANY) {
+                               anysym = s;
+                               if(!debug['A'])
+                                       s->def = nil;
+                       }
                        continue;
                }
 
index ba01cbb457e7147fd5eb27298600a164c7c87b86..b99752cc91b2bc1d7771ded4b4d31d42e2b64b7a 100755 (executable)
@@ -15,7 +15,7 @@ gcc -o mkbuiltin1 mkbuiltin1.c
 rm -f _builtin.c
 for i in sys unsafe
 do
-       $GC $i.go
+       $GC -A $i.go
        ./mkbuiltin1 $i >>_builtin.c
 done