summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/gc/builtin.c.boot1
-rw-r--r--src/cmd/gc/dcl.c10
-rw-r--r--src/cmd/gc/go.y16
-rw-r--r--src/cmd/gc/sys.go1
-rw-r--r--src/runtime/string.c8
5 files changed, 19 insertions, 17 deletions
diff --git a/src/cmd/gc/builtin.c.boot b/src/cmd/gc/builtin.c.boot
index 81ec84c37..d935fc564 100644
--- a/src/cmd/gc/builtin.c.boot
+++ b/src/cmd/gc/builtin.c.boot
@@ -18,7 +18,6 @@ char *sysimport =
"func sys.slicestring (? string, ? int, ? int) (? string)\n"
"func sys.indexstring (? string, ? int) (? uint8)\n"
"func sys.intstring (? int64) (? string)\n"
- "func sys.byteastring (? *uint8, ? int) (? string)\n"
"func sys.arraystring (? []uint8) (? string)\n"
"func sys.stringiter (? string, ? int) (? int)\n"
"func sys.stringiter2 (? string, ? int) (retk int, retv int)\n"
diff --git a/src/cmd/gc/dcl.c b/src/cmd/gc/dcl.c
index d39b893a3..2426fcac0 100644
--- a/src/cmd/gc/dcl.c
+++ b/src/cmd/gc/dcl.c
@@ -38,7 +38,8 @@ dodclvar(Node *n, Type *t)
addvar(n, t, dclcontext);
autoexport(n->sym);
- addtop = list(addtop, nod(ODCL, n, N));
+ if(funcdepth > 0)
+ addtop = list(addtop, nod(ODCL, n, N));
}
void
@@ -1299,7 +1300,7 @@ fninit(Node *n)
Node *done;
Node *a, *fn, *r;
uint32 h;
- Sym *s;
+ Sym *s, *initsym;
if(strcmp(package, "PACKAGE") == 0) {
// sys.go or unsafe.go during compiler build
@@ -1329,7 +1330,8 @@ fninit(Node *n)
snprint(namebuf, sizeof(namebuf), "init");
fn = nod(ODCLFUNC, N, N);
- fn->nname = newname(lookup(namebuf));
+ initsym = lookup(namebuf);
+ fn->nname = newname(initsym);
fn->type = functype(N, N, N);
funchdr(fn);
@@ -1350,6 +1352,8 @@ fninit(Node *n)
continue;
if(s->oname == N)
continue;
+ if(s == initsym)
+ continue;
// could check that it is fn of no args/returns
a = nod(OCALL, s->oname, N);
diff --git a/src/cmd/gc/go.y b/src/cmd/gc/go.y
index 4c326f1e7..e5b808460 100644
--- a/src/cmd/gc/go.y
+++ b/src/cmd/gc/go.y
@@ -299,8 +299,12 @@ Avardcl:
$$ = rev($1);
dodclvar($$, $2);
- $$ = nod(OAS, $$, N);
- addtotop($$);
+ if(funcdepth == 0) {
+ $$ = N;
+ } else {
+ $$ = nod(OAS, $$, N);
+ addtotop($$);
+ }
}
Bvardcl:
@@ -309,8 +313,12 @@ Bvardcl:
$$ = rev($1);
dodclvar($$, $2);
- $$ = nod(OAS, $$, N);
- addtotop($$);
+ if(funcdepth == 0) {
+ $$ = N;
+ } else {
+ $$ = nod(OAS, $$, N);
+ addtotop($$);
+ }
}
| new_name_list_r type '=' expr_list
{
diff --git a/src/cmd/gc/sys.go b/src/cmd/gc/sys.go
index 6a0a6b349..9c2bc4d04 100644
--- a/src/cmd/gc/sys.go
+++ b/src/cmd/gc/sys.go
@@ -27,7 +27,6 @@ func cmpstring(string, string) int;
func slicestring(string, int, int) string;
func indexstring(string, int) byte;
func intstring(int64) string;
-func byteastring(*byte, int) string;
func arraystring([]byte) string;
func stringiter(string, int) int;
func stringiter2(string, int) (retk int, retv int);
diff --git a/src/runtime/string.c b/src/runtime/string.c
index c62731ea3..667828d66 100644
--- a/src/runtime/string.c
+++ b/src/runtime/string.c
@@ -174,14 +174,6 @@ sys·intstring(int64 v, String s)
}
void
-sys·byteastring(byte *a, int32 l, String s)
-{
- s = gostringsize(l);
- mcpy(s.str, a, l);
- FLUSH(&s);
-}
-
-void
sys·arraystring(Array b, String s)
{
s = gostringsize(b.nel);