]> Cypherpunks repositories - gostls13.git/commitdiff
allow data statements for simple
authorKen Thompson <ken@golang.org>
Tue, 4 May 2010 05:51:30 +0000 (22:51 -0700)
committerKen Thompson <ken@golang.org>
Tue, 4 May 2010 05:51:30 +0000 (22:51 -0700)
external variable assignements.

R=rsc
CC=golang-dev
https://golang.org/cl/1094041

src/cmd/gc/init.c
src/cmd/gc/walk.c

index a89c0181fa8d05532874d678c357cdcbff2c6ee4..cdd462e55ed00bd3703d86f6cdac8597ca1271b9 100644 (file)
@@ -37,17 +37,14 @@ renameinit(Node *n)
  *                             return
  *                     throw();                        (5)
  *             }
- *             initdone.<file> += 1;                   (6)
+ *             initdone.<file> = 1;                    (6)
  *             // over all matching imported symbols
  *                     <pkg>.init·<file>()            (7)
  *             { <init stmts> }                        (8)
  *             init·<file>()  // if any               (9)
- *             initdone.<file> += 1;                   (10)
+ *             initdone.<file> = 2;                    (10)
  *             return                                  (11)
  *     }
- * note that this code cannot have an assignment
- * statement or, because of the initflag,  it will
- * be converted into a data statement.
  */
 int
 anyinit(NodeList *n)
@@ -120,7 +117,6 @@ fninit(NodeList *n)
        addvar(gatevar, types[TUINT8], PEXTERN);
 
        // (2)
-
        maxarg = 0;
        snprint(namebuf, sizeof(namebuf), "Init·");
 
index a79c75131f0ac39f355860d788f0a62ed67a60cd..86e45e12d37f337f5d91c9f01709cd670b67539f 100644 (file)
@@ -701,8 +701,10 @@ walkexpr(Node **np, NodeList **init)
                if(l == N || r == N)
                        goto ret;
                r = ascompatee1(n->op, l, r, init);
-               if(r != N)
+               if(r != N) {
+                       r->dodata = n->dodata;
                        n = r;
+               }
                goto ret;
 
        case OAS2: