]> Cypherpunks repositories - gostls13.git/commitdiff
remove export name-list statement.
authorRuss Cox <rsc@golang.org>
Fri, 16 Jan 2009 00:16:52 +0000 (16:16 -0800)
committerRuss Cox <rsc@golang.org>
Fri, 16 Jan 2009 00:16:52 +0000 (16:16 -0800)
make package local the default.
warn about name case not matching export keyword.

R=ken
OCL=22881
CL=22886

src/cmd/6g/gsubr.c
src/cmd/gc/dcl.c
src/cmd/gc/export.c
src/cmd/gc/go.h
src/cmd/gc/go.y
src/run.bash

index 102e27d2e156e212140f6a0c9a8274ee27451ab7..6934c6f30cef423c37346e05063546cf286b6d87 100644 (file)
@@ -543,7 +543,6 @@ gmove(Node *f, Node *t)
                                dump("gmove", t);
                                fatal("gmove t %O class %d reg %R", t->op, t->class, t->val.u.reg);
                        case PEXTERN:
-                       case PSTATIC:
                                goto refcount;
                                break;
                        case PAUTO:
@@ -1072,9 +1071,6 @@ naddr(Node *n, Addr *a)
                case PPARAM:
                        a->type = D_PARAM;
                        break;
-               case PSTATIC:
-                       a->type = D_STATIC;
-                       break;
                }
                break;
 
index 162495e80e1c7979b51c46f8a89efef6fdec60e9..aab47b6539496d5ded2dfd5cf238d40a879cdd0e 100644 (file)
@@ -35,8 +35,7 @@ dodclvar(Node *n, Type *t)
                t = typ(TFORW);
 
        addvar(n, t, dclcontext);
-       if(dcladj)
-               dcladj(n->sym);
+       autoexport(n->sym);
 }
 
 void
@@ -49,8 +48,7 @@ dodclconst(Node *n, Node *e)
                dodclconst(n, e);
 
        addconst(n, e, dclcontext);
-       if(dcladj)
-               dcladj(n->sym);
+       autoexport(n->sym);
 }
 
 /*
@@ -79,8 +77,7 @@ dodcltype(Type *n)
 
 found:
        n->local = 1;
-       if(dcladj)
-               dcladj(n->sym);
+       autoexport(n->sym);
        return n;
 }
 
index 7b9fce63f8a1eec0df07bd3c54d8aeee30278ef3..e46276b118ada41b7fdb6c5cd649fea5f2364370 100644 (file)
@@ -53,6 +53,32 @@ packagesym(Sym *s)
        addexportsym(s);
 }
 
+int
+exportname(char *s)
+{
+       Rune r;
+
+       if((uchar)s[0] < Runeself)
+               return 'A' <= s[0] && s[0] <= 'Z';
+       chartorune(&r, s);
+       return isupperrune(r);
+}
+
+void
+autoexport(Sym *s)
+{
+       if(s == S)
+               return;
+       if(dclcontext != PEXTERN)
+               return;
+       if(exportname(s->name)) {
+               if(dcladj != exportsym)
+                       warn("uppercase missing export");
+               exportsym(s);
+       } else
+               packagesym(s);
+}
+
 void
 dumpprereq(Type *t)
 {
@@ -330,6 +356,7 @@ importconst(int export, Node *ss, Type *t, Val *v)
        Node *n;
        Sym *s;
 
+       export = exportname(ss->sym->name);
        if(export == 2 && !mypackage(ss))
                return;
 
@@ -337,14 +364,18 @@ importconst(int export, Node *ss, Type *t, Val *v)
        n->val = *v;
        n->type = t;
 
-       s = importsym(export, ss, LNAME);
+       s = importsym(export, ss, LACONST);
        if(s->oconst != N) {
                // TODO: check if already the same.
                return;
        }
 
+// fake out export vs upper checks until transition is over
+if(export == 1) dcladj = exportsym;
+
        dodclconst(newname(s), n);
 
+dcladj = nil;
        if(debug['e'])
                print("import const %S\n", s);
 }
index 19b44f90996c6328c31c8656a2f6a915564a5bc2..ff699059750d657fdd0857fa482befaa3c91bb05 100644 (file)
@@ -180,7 +180,7 @@ struct      Node
        uchar   addable;        // type of addressability - 0 is not addressable
        uchar   trecur;         // to detect loops
        uchar   etype;          // op for OASOP, etype for OTYPE, exclam for export
-       uchar   class;          // PPARAM, PAUTO, PEXTERN, PSTATIC
+       uchar   class;          // PPARAM, PAUTO, PEXTERN
        uchar   method;         // OCALLMETH name
        uchar   iota;           // OLITERAL made from iota
        uchar   embedded;       // ODCLFIELD embedded type
@@ -404,7 +404,6 @@ enum
        PEXTERN,        // declaration context
        PAUTO,
        PPARAM,
-       PSTATIC,
 };
 
 enum
@@ -741,6 +740,7 @@ void        constiter(Node*, Type*, Node*);
  *     export.c
  */
 void   renamepkg(Node*);
+void   autoexport(Sym*);
 void   exportsym(Sym*);
 void   packagesym(Sym*);
 void   dumpe(Sym*);
index db12ee08135da3cfc88a2137ccfc41eb6a1bd539..1dd55523c06e660bab1b5f789276e4906a205d23 100644 (file)
@@ -188,20 +188,15 @@ xdcl:
        {
                $$ = N;
        }
-|      LEXPORT export_list_r
-       {
-               $$ = N;
-       }
 |      LEXPORT { dcladj = exportsym; stksize = initstksize; } common_dcl
        {
                $$ = $3;
                dcladj = 0;
                initstksize = stksize;
        }
-|      LPACKAGE { dcladj = packagesym; stksize = initstksize; } common_dcl
+|      LPACKAGE { warn("package is gone"); stksize = initstksize; } common_dcl
        {
                $$ = $3;
-               dcladj = 0;
                initstksize = stksize;
        }
 |      LEXPORT '(' export_list_r ')'
@@ -214,10 +209,10 @@ xdcl:
                        exportsym($2->nname->sym);
                $$ = N;
        }
-|      LPACKAGE xfndcl
+|      LPACKAGE { warn("package is gone"); } xfndcl
        {
-               if($2 != N && $2->nname != N)
-                       packagesym($2->nname->sym);
+               if($3 != N && $3->nname != N)
+                       packagesym($3->nname->sym);
                $$ = N;
        }
 |      ';'
index 2c5d13dadd7a6733d01f9047dfb348ade642714d..90c9a7af1a9cab7bcde598a274222cf5cc128a80 100755 (executable)
@@ -52,11 +52,11 @@ time make
 make smoketest
 ) || exit $?
 
-(xcd ../usr/gri/gosrc
-make clean
-time make
-# make test
-) || exit $?
+(xcd ../usr/gri/gosrc
+make clean
+time make
+# make test
+) || exit $?
 
 (xcd ../doc/progs
 time ./run