Commit 50110c9f authored by Luuk van Dijk's avatar Luuk van Dijk

gc: clean up printing.

Got rid of all the magic mystery globals. Now
for %N, %T, and %S, the flags +,- and # set a sticky
debug, sym and export mode, only visible in the new fmt.c.
Default is error mode. Handle h and l flags consistently with
the least side effects, so we can now change
things without worrying about unrelated things
breaking.

fixes #2361

R=rsc
CC=golang-dev
https://golang.org/cl/5316043
parent 58423360
...@@ -24,6 +24,7 @@ OFILES=\ ...@@ -24,6 +24,7 @@ OFILES=\
dcl.$O\ dcl.$O\
esc.$O\ esc.$O\
export.$O\ export.$O\
fmt.$O\
gen.$O\ gen.$O\
init.$O\ init.$O\
lex.$O\ lex.$O\
...@@ -32,7 +33,6 @@ OFILES=\ ...@@ -32,7 +33,6 @@ OFILES=\
mparith2.$O\ mparith2.$O\
mparith3.$O\ mparith3.$O\
obj.$O\ obj.$O\
print.$O\
range.$O\ range.$O\
reflect.$O\ reflect.$O\
select.$O\ select.$O\
...@@ -62,7 +62,7 @@ subr.$O: yerr.h ...@@ -62,7 +62,7 @@ subr.$O: yerr.h
builtin.c: builtin.c.boot builtin.c: builtin.c.boot
cp builtin.c.boot builtin.c cp builtin.c.boot builtin.c
subr.$O: opnames.h fmt.$O: opnames.h
opnames.h: mkopnames go.h opnames.h: mkopnames go.h
./mkopnames go.h >opnames.h ./mkopnames go.h >opnames.h
......
...@@ -108,7 +108,7 @@ convlit1(Node **np, Type *t, int explicit) ...@@ -108,7 +108,7 @@ convlit1(Node **np, Type *t, int explicit)
if(t != T && t->etype == TIDEAL && n->val.ctype != CTINT) if(t != T && t->etype == TIDEAL && n->val.ctype != CTINT)
n->val = toint(n->val); n->val = toint(n->val);
if(t != T && !isint[t->etype]) { if(t != T && !isint[t->etype]) {
yyerror("invalid operation: %#N (shift of type %T)", n, t); yyerror("invalid operation: %N (shift of type %T)", n, t);
t = T; t = T;
} }
n->type = t; n->type = t;
...@@ -224,7 +224,7 @@ convlit1(Node **np, Type *t, int explicit) ...@@ -224,7 +224,7 @@ convlit1(Node **np, Type *t, int explicit)
bad: bad:
if(!n->diag) { if(!n->diag) {
yyerror("cannot convert %#N to type %T", n, t); yyerror("cannot convert %N to type %T", n, t);
n->diag = 1; n->diag = 1;
} }
if(isideal(n->type)) { if(isideal(n->type)) {
...@@ -939,7 +939,7 @@ defaultlit(Node **np, Type *t) ...@@ -939,7 +939,7 @@ defaultlit(Node **np, Type *t)
defaultlit(&n->left, t); defaultlit(&n->left, t);
t = n->left->type; t = n->left->type;
if(t != T && !isint[t->etype]) { if(t != T && !isint[t->etype]) {
yyerror("invalid operation: %#N (shift of type %T)", n, t); yyerror("invalid operation: %N (shift of type %T)", n, t);
t = T; t = T;
} }
n->type = t; n->type = t;
...@@ -991,7 +991,7 @@ defaultlit(Node **np, Type *t) ...@@ -991,7 +991,7 @@ defaultlit(Node **np, Type *t)
n->type = types[TSTRING]; n->type = types[TSTRING];
break; break;
} }
yyerror("defaultlit: unknown literal: %#N", n); yyerror("defaultlit: unknown literal: %N", n);
break; break;
case CTBOOL: case CTBOOL:
n->type = types[TBOOL]; n->type = types[TBOOL];
......
...@@ -473,7 +473,7 @@ colasdefn(NodeList *left, Node *defn) ...@@ -473,7 +473,7 @@ colasdefn(NodeList *left, Node *defn)
if(isblank(n)) if(isblank(n))
continue; continue;
if(!colasname(n)) { if(!colasname(n)) {
yyerror("non-name %#N on left side of :=", n); yyerror("non-name %N on left side of :=", n);
nerr++; nerr++;
continue; continue;
} }
...@@ -1086,10 +1086,11 @@ methodsym(Sym *nsym, Type *t0, int iface) ...@@ -1086,10 +1086,11 @@ methodsym(Sym *nsym, Type *t0, int iface)
suffix = "·i"; suffix = "·i";
} }
if(t0->sym == S && isptr[t0->etype]) if(t0->sym == S && isptr[t0->etype])
p = smprint("(%#hT).%s%s", t0, nsym->name, suffix); p = smprint("(%-hT).%s%s", t0, nsym->name, suffix);
else else
p = smprint("%#hT.%s%s", t0, nsym->name, suffix); p = smprint("%-hT.%s%s", t0, nsym->name, suffix);
s = pkglookup(p, s->pkg); s = pkglookup(p, s->pkg);
//print("methodsym:%s -> %+S\n", p, s);
free(p); free(p);
return s; return s;
......
...@@ -88,7 +88,7 @@ escapes(void) ...@@ -88,7 +88,7 @@ escapes(void)
if(debug['m']) { if(debug['m']) {
for(l=noesc; l; l=l->next) for(l=noesc; l; l=l->next)
if(l->n->esc == EscNone) if(l->n->esc == EscNone)
warnl(l->n->lineno, "%S %#hN does not escape", warnl(l->n->lineno, "%S %hN does not escape",
(l->n->curfn && l->n->curfn->nname) ? l->n->curfn->nname->sym : S, (l->n->curfn && l->n->curfn->nname) ? l->n->curfn->nname->sym : S,
l->n); l->n);
} }
...@@ -178,7 +178,7 @@ esc(Node *n) ...@@ -178,7 +178,7 @@ esc(Node *n)
loopdepth--; loopdepth--;
if(debug['m'] > 1) if(debug['m'] > 1)
print("%L:[%d] %#S esc: %#N\n", lineno, loopdepth, print("%L:[%d] %S esc: %N\n", lineno, loopdepth,
(curfn && curfn->nname) ? curfn->nname->sym : S, n); (curfn && curfn->nname) ? curfn->nname->sym : S, n);
switch(n->op) { switch(n->op) {
...@@ -331,7 +331,7 @@ escassign(Node *dst, Node *src) ...@@ -331,7 +331,7 @@ escassign(Node *dst, Node *src)
return; return;
if(debug['m'] > 1) if(debug['m'] > 1)
print("%L:[%d] %#S escassign: %hN = %hN\n", lineno, loopdepth, print("%L:[%d] %S escassign: %hN = %hN\n", lineno, loopdepth,
(curfn && curfn->nname) ? curfn->nname->sym : S, dst, src); (curfn && curfn->nname) ? curfn->nname->sym : S, dst, src);
setlineno(dst); setlineno(dst);
...@@ -609,7 +609,7 @@ escflood(Node *dst) ...@@ -609,7 +609,7 @@ escflood(Node *dst)
} }
if(debug['m']>1) if(debug['m']>1)
print("\nescflood:%d: dst %hN scope:%#S[%d]\n", walkgen, dst, print("\nescflood:%d: dst %hN scope:%S[%d]\n", walkgen, dst,
(dst->curfn && dst->curfn->nname) ? dst->curfn->nname->sym : S, (dst->curfn && dst->curfn->nname) ? dst->curfn->nname->sym : S,
dst->escloopdepth); dst->escloopdepth);
...@@ -630,7 +630,7 @@ escwalk(int level, Node *dst, Node *src) ...@@ -630,7 +630,7 @@ escwalk(int level, Node *dst, Node *src)
src->walkgen = walkgen; src->walkgen = walkgen;
if(debug['m']>1) if(debug['m']>1)
print("escwalk: level:%d depth:%d %.*s %hN scope:%#S[%d]\n", print("escwalk: level:%d depth:%d %.*s %hN scope:%S[%d]\n",
level, pdepth, pdepth, "\t\t\t\t\t\t\t\t\t\t", src, level, pdepth, pdepth, "\t\t\t\t\t\t\t\t\t\t", src,
(src->curfn && src->curfn->nname) ? src->curfn->nname->sym : S, src->escloopdepth); (src->curfn && src->curfn->nname) ? src->curfn->nname->sym : S, src->escloopdepth);
...@@ -643,7 +643,7 @@ escwalk(int level, Node *dst, Node *src) ...@@ -643,7 +643,7 @@ escwalk(int level, Node *dst, Node *src)
if(src->class == PPARAM && leaks && src->esc == EscNone) { if(src->class == PPARAM && leaks && src->esc == EscNone) {
src->esc = EscScope; src->esc = EscScope;
if(debug['m']) if(debug['m'])
warnl(src->lineno, "leaking param: %#hN", src); warnl(src->lineno, "leaking param: %hN", src);
} }
break; break;
...@@ -652,7 +652,7 @@ escwalk(int level, Node *dst, Node *src) ...@@ -652,7 +652,7 @@ escwalk(int level, Node *dst, Node *src)
src->esc = EscHeap; src->esc = EscHeap;
addrescapes(src->left); addrescapes(src->left);
if(debug['m']) if(debug['m'])
warnl(src->lineno, "%#hN escapes to heap", src); warnl(src->lineno, "%hN escapes to heap", src);
} }
escwalk(level-1, dst, src->left); escwalk(level-1, dst, src->left);
break; break;
...@@ -671,7 +671,7 @@ escwalk(int level, Node *dst, Node *src) ...@@ -671,7 +671,7 @@ escwalk(int level, Node *dst, Node *src)
if(leaks) { if(leaks) {
src->esc = EscHeap; src->esc = EscHeap;
if(debug['m']) if(debug['m'])
warnl(src->lineno, "%#hN escapes to heap", src); warnl(src->lineno, "%hN escapes to heap", src);
} }
break; break;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "y.tab.h" #include "y.tab.h"
static void dumpsym(Sym*); static void dumpsym(Sym*);
static void dumpexporttype(Sym*); static void dumpexporttype(Type*);
static void dumpexportvar(Sym*); static void dumpexportvar(Sym*);
static void dumpexportconst(Sym*); static void dumpexportconst(Sym*);
...@@ -89,25 +89,7 @@ dumppkg(Pkg *p) ...@@ -89,25 +89,7 @@ dumppkg(Pkg *p)
} }
static void static void
dumpprereq(Type *t)
{
if(t == T)
return;
if(t->printed || t == types[t->etype] || t == bytetype || t == runetype)
return;
t->printed = 1;
if(t->sym != S) {
dumppkg(t->sym->pkg);
if(t->etype != TFIELD)
dumpsym(t->sym);
}
dumpprereq(t->type);
dumpprereq(t->down);
}
static void
dumpexportconst(Sym *s) dumpexportconst(Sym *s)
{ {
Node *n; Node *n;
...@@ -119,37 +101,12 @@ dumpexportconst(Sym *s) ...@@ -119,37 +101,12 @@ dumpexportconst(Sym *s)
fatal("dumpexportconst: oconst nil: %S", s); fatal("dumpexportconst: oconst nil: %S", s);
t = n->type; // may or may not be specified t = n->type; // may or may not be specified
if(t != T) dumpexporttype(t);
dumpprereq(t);
Bprint(bout, "\t");
Bprint(bout, "const %#S", s);
if(t != T && !isideal(t)) if(t != T && !isideal(t))
Bprint(bout, " %#T", t); Bprint(bout, "\tconst %#S %#T = %#V\n", s, t, &n->val);
Bprint(bout, " = "); else
Bprint(bout, "\tconst %#S = %#V\n", s, &n->val);
switch(n->val.ctype) {
default:
fatal("dumpexportconst: unknown ctype: %S %d", s, n->val.ctype);
case CTINT:
Bprint(bout, "%B\n", n->val.u.xval);
break;
case CTBOOL:
if(n->val.u.bval)
Bprint(bout, "true\n");
else
Bprint(bout, "false\n");
break;
case CTFLT:
Bprint(bout, "%F\n", n->val.u.fval);
break;
case CTCPLX:
Bprint(bout, "(%F+%F)\n", &n->val.u.cval->real, &n->val.u.cval->imag);
break;
case CTSTR:
Bprint(bout, "\"%Z\"\n", n->val.u.sval);
break;
}
} }
static void static void
...@@ -166,31 +123,12 @@ dumpexportvar(Sym *s) ...@@ -166,31 +123,12 @@ dumpexportvar(Sym *s)
} }
t = n->type; t = n->type;
dumpprereq(t); dumpexporttype(t);
Bprint(bout, "\t");
if(t->etype == TFUNC && n->class == PFUNC) if(t->etype == TFUNC && n->class == PFUNC)
Bprint(bout, "func %#S %#hhT", s, t); Bprint(bout, "\tfunc %#S%#hT\n", s, t);
else else
Bprint(bout, "var %#S %#T", s, t); Bprint(bout, "\tvar %#S %#T\n", s, t);
Bprint(bout, "\n");
}
static void
dumpexporttype(Sym *s)
{
Type *t;
t = s->def->type;
dumpprereq(t);
Bprint(bout, "\t");
switch (t->etype) {
case TFORW:
yyerror("export of incomplete type %T", t);
return;
}
if(Bprint(bout, "type %#T %l#T\n", t, t) < 0)
fatal("Bprint failed for %T", t);
} }
static int static int
...@@ -204,12 +142,50 @@ methcmp(const void *va, const void *vb) ...@@ -204,12 +142,50 @@ methcmp(const void *va, const void *vb)
} }
static void static void
dumpsym(Sym *s) dumpexporttype(Type *t)
{ {
Type *f, *t; Type *f;
Type **m; Type **m;
int i, n; int i, n;
if(t == T)
return;
if(t->printed || t == types[t->etype] || t == bytetype || t == runetype)
return;
t->printed = 1;
if(t->sym != S && t->etype != TFIELD)
dumppkg(t->sym->pkg);
dumpexporttype(t->type);
dumpexporttype(t->down);
if (t->sym == S || t->etype == TFIELD)
return;
n = 0;
for(f=t->method; f!=T; f=f->down) {
dumpexporttype(f);
n++;
}
m = mal(n*sizeof m[0]);
i = 0;
for(f=t->method; f!=T; f=f->down)
m[i++] = f;
qsort(m, n, sizeof m[0], methcmp);
Bprint(bout, "\ttype %#S %#lT\n", t->sym, t);
for(i=0; i<n; i++) {
f = m[i];
Bprint(bout, "\tfunc (%#T) %#hS%#hT\n", getthisx(f->type)->type, f->sym, f->type);
}
}
static void
dumpsym(Sym *s)
{
if(s->flags & SymExported) if(s->flags & SymExported)
return; return;
s->flags |= SymExported; s->flags |= SymExported;
...@@ -229,24 +205,10 @@ dumpsym(Sym *s) ...@@ -229,24 +205,10 @@ dumpsym(Sym *s)
dumpexportconst(s); dumpexportconst(s);
break; break;
case OTYPE: case OTYPE:
t = s->def->type; if(s->def->type->etype == TFORW)
n = 0; yyerror("export of incomplete type %S", s);
for(f=t->method; f!=T; f=f->down) { else
dumpprereq(f); dumpexporttype(s->def->type);
n++;
}
m = mal(n*sizeof m[0]);
i = 0;
for(f=t->method; f!=T; f=f->down)
m[i++] = f;
qsort(m, n, sizeof m[0], methcmp);
dumpexporttype(s);
for(i=0; i<n; i++) {
f = m[i];
Bprint(bout, "\tfunc (%#T) %hS %#hhT\n",
f->type->type->type, f->sym, f->type);
}
break; break;
case ONAME: case ONAME:
dumpexportvar(s); dumpexportvar(s);
...@@ -254,20 +216,6 @@ dumpsym(Sym *s) ...@@ -254,20 +216,6 @@ dumpsym(Sym *s)
} }
} }
static void
dumptype(Type *t)
{
// no need to re-dump type if already exported
if(t->printed)
return;
// no need to dump type if it's not ours (was imported)
if(t->sym != S && t->sym->def == typenod(t) && !t->local)
return;
Bprint(bout, "type %#T %l#T\n", t, t);
}
void void
dumpexport(void) dumpexport(void)
{ {
...@@ -277,10 +225,7 @@ dumpexport(void) ...@@ -277,10 +225,7 @@ dumpexport(void)
lno = lineno; lno = lineno;
packagequotes = 1; Bprint(bout, "\n$$ // exports\n package %s", localpkg->name);
Bprint(bout, "\n$$ // exports\n");
Bprint(bout, " package %s", localpkg->name);
if(safemode) if(safemode)
Bprint(bout, " safe"); Bprint(bout, " safe");
Bprint(bout, "\n"); Bprint(bout, "\n");
...@@ -295,15 +240,7 @@ dumpexport(void) ...@@ -295,15 +240,7 @@ dumpexport(void)
dumpsym(l->n->sym); dumpsym(l->n->sym);
} }
Bprint(bout, "\n$$ // local types\n"); Bprint(bout, "\n$$ // local types\n\n$$\n"); // 6l expects this. (see ld/go.c)
for(l=typelist; l; l=l->next) {
lineno = l->n->lineno;
dumptype(l->n->type);
}
Bprint(bout, "\n$$\n");
packagequotes = 0;
lineno = lno; lineno = lno;
} }
...@@ -346,7 +283,7 @@ pkgtype(Sym *s) ...@@ -346,7 +283,7 @@ pkgtype(Sym *s)
s->def = typenod(t); s->def = typenod(t);
} }
if(s->def->type == T) if(s->def->type == T)
yyerror("pkgtype %lS", s); yyerror("pkgtype %S", s);
return s->def->type; return s->def->type;
} }
...@@ -400,8 +337,7 @@ importvar(Sym *s, Type *t, int ctxt) ...@@ -400,8 +337,7 @@ importvar(Sym *s, Type *t, int ctxt)
if(s->def != N && s->def->op == ONAME) { if(s->def != N && s->def->op == ONAME) {
if(eqtype(t, s->def->type)) if(eqtype(t, s->def->type))
return; return;
yyerror("inconsistent definition for var %S during import\n\t%T\n\t%T", yyerror("inconsistent definition for var %S during import\n\t%T\n\t%T", s, s->def->type, t);
s, s->def->type, t);
} }
n = newname(s); n = newname(s);
n->type = t; n->type = t;
......
This diff is collapsed.
...@@ -94,7 +94,7 @@ addrescapes(Node *n) ...@@ -94,7 +94,7 @@ addrescapes(Node *n)
if(!debug['s']) if(!debug['s'])
n->esc = EscHeap; n->esc = EscHeap;
if(debug['m']) if(debug['m'])
print("%L: moved to heap: %#hN\n", n->lineno, n); print("%L: moved to heap: %N\n", n->lineno, n);
curfn = oldfn; curfn = oldfn;
break; break;
} }
......
...@@ -846,14 +846,8 @@ EXTERN char* hunk; ...@@ -846,14 +846,8 @@ EXTERN char* hunk;
EXTERN int32 nhunk; EXTERN int32 nhunk;
EXTERN int32 thunk; EXTERN int32 thunk;
EXTERN int exporting;
EXTERN int erroring;
EXTERN int noargnames;
EXTERN int funcdepth; EXTERN int funcdepth;
EXTERN int typecheckok; EXTERN int typecheckok;
EXTERN int packagequotes;
EXTERN int longsymnames;
EXTERN int compiling_runtime; EXTERN int compiling_runtime;
EXTERN int rune32; EXTERN int rune32;
...@@ -986,6 +980,13 @@ void importtype(Type *pt, Type *t); ...@@ -986,6 +980,13 @@ void importtype(Type *pt, Type *t);
void importvar(Sym *s, Type *t, int ctxt); void importvar(Sym *s, Type *t, int ctxt);
Type* pkgtype(Sym *s); Type* pkgtype(Sym *s);
/*
* fmt.c
*/
void fmtinstallgo(void);
void dump(char *s, Node *n);
void dumplist(char *s, NodeList *l);
/* /*
* gen.c * gen.c
*/ */
...@@ -1095,12 +1096,6 @@ void dumpobj(void); ...@@ -1095,12 +1096,6 @@ void dumpobj(void);
void ieeedtod(uint64 *ieee, double native); void ieeedtod(uint64 *ieee, double native);
Sym* stringsym(char*, int); Sym* stringsym(char*, int);
/*
* print.c
*/
void exprfmt(Fmt *f, Node *n, int prec);
void exprlistfmt(Fmt *f, NodeList *l);
/* /*
* range.c * range.c
*/ */
...@@ -1134,15 +1129,6 @@ int stataddr(Node *nam, Node *n); ...@@ -1134,15 +1129,6 @@ int stataddr(Node *nam, Node *n);
/* /*
* subr.c * subr.c
*/ */
int Econv(Fmt *fp);
int Jconv(Fmt *fp);
int Lconv(Fmt *fp);
int Nconv(Fmt *fp);
int Oconv(Fmt *fp);
int Sconv(Fmt *fp);
int Tconv(Fmt *fp);
int Vconv(Fmt *fp);
int Zconv(Fmt *fp);
Node* adddot(Node *n); Node* adddot(Node *n);
int adddot1(Sym *s, Type *t, int d, Type **save, int ignorecase); int adddot1(Sym *s, Type *t, int d, Type **save, int ignorecase);
Type* aindex(Node *b, Type *t); Type* aindex(Node *b, Type *t);
...@@ -1157,8 +1143,6 @@ NodeList* concat(NodeList *a, NodeList *b); ...@@ -1157,8 +1143,6 @@ NodeList* concat(NodeList *a, NodeList *b);
int convertop(Type *src, Type *dst, char **why); int convertop(Type *src, Type *dst, char **why);
int count(NodeList *l); int count(NodeList *l);
int cplxsubtype(int et); int cplxsubtype(int et);
void dump(char *s, Node *n);
void dumplist(char *s, NodeList *l);
int eqtype(Type *t1, Type *t2); int eqtype(Type *t1, Type *t2);
int eqtypenoname(Type *t1, Type *t2); int eqtypenoname(Type *t1, Type *t2);
void errorexit(void); void errorexit(void);
...@@ -1347,6 +1331,7 @@ void zname(Biobuf *b, Sym *s, int t); ...@@ -1347,6 +1331,7 @@ void zname(Biobuf *b, Sym *s, int t);
#pragma varargck type "lD" Addr* #pragma varargck type "lD" Addr*
#pragma varargck type "E" int #pragma varargck type "E" int
#pragma varargck type "F" Mpflt* #pragma varargck type "F" Mpflt*
#pragma varargck type "H" NodeList*
#pragma varargck type "J" Node* #pragma varargck type "J" Node*
#pragma varargck type "L" int #pragma varargck type "L" int
#pragma varargck type "L" uint #pragma varargck type "L" uint
......
...@@ -426,7 +426,7 @@ simple_stmt: ...@@ -426,7 +426,7 @@ simple_stmt:
if($1->next != nil) if($1->next != nil)
yyerror("argument count mismatch: %d = %d", count($1), 1); yyerror("argument count mismatch: %d = %d", count($1), 1);
else if($1->n->op != ONAME && $1->n->op != OTYPE && $1->n->op != ONONAME) else if($1->n->op != ONAME && $1->n->op != OTYPE && $1->n->op != ONONAME)
yyerror("invalid variable name %#N in type switch", $1->n); yyerror("invalid variable name %N in type switch", $1->n);
else else
n = $1->n; n = $1->n;
$$ = nod(OTYPESW, n, $3->n->right); $$ = nod(OTYPESW, n, $3->n->right);
......
...@@ -253,18 +253,7 @@ main(int argc, char *argv[]) ...@@ -253,18 +253,7 @@ main(int argc, char *argv[])
*p = '/'; *p = '/';
} }
fmtinstall('O', Oconv); // node opcodes fmtinstallgo();
fmtinstall('E', Econv); // etype opcodes
fmtinstall('J', Jconv); // all the node flags
fmtinstall('S', Sconv); // sym pointer
fmtinstall('T', Tconv); // type pointer
fmtinstall('V', Vconv); // Val pointer
fmtinstall('N', Nconv); // node pointer
fmtinstall('Z', Zconv); // escaped string
fmtinstall('L', Lconv); // line number
fmtinstall('B', Bconv); // big numbers
fmtinstall('F', Fconv); // big float numbers
betypeinit(); betypeinit();
if(widthptr == 0) if(widthptr == 0)
fatal("betypeinit failed"); fatal("betypeinit failed");
......
...@@ -52,7 +52,7 @@ dumpglobls(void) ...@@ -52,7 +52,7 @@ dumpglobls(void)
continue; continue;
if(n->type == T) if(n->type == T)
fatal("external %#N nil type\n", n); fatal("external %N nil type\n", n);
if(n->class == PFUNC) if(n->class == PFUNC)
continue; continue;
if(n->sym->pkg != localpkg) if(n->sym->pkg != localpkg)
......
This diff is collapsed.
...@@ -32,7 +32,7 @@ typecheckrange(Node *n) ...@@ -32,7 +32,7 @@ typecheckrange(Node *n)
switch(t->etype) { switch(t->etype) {
default: default:
yyerror("cannot range over %+N", n->right); yyerror("cannot range over %lN", n->right);
goto out; goto out;
case TARRAY: case TARRAY:
...@@ -71,12 +71,12 @@ typecheckrange(Node *n) ...@@ -71,12 +71,12 @@ typecheckrange(Node *n)
if(v1->defn == n) if(v1->defn == n)
v1->type = t1; v1->type = t1;
else if(v1->type != T && assignop(t1, v1->type, &why) == 0) else if(v1->type != T && assignop(t1, v1->type, &why) == 0)
yyerror("cannot assign type %T to %+N in range%s", t1, v1, why); yyerror("cannot assign type %T to %lN in range%s", t1, v1, why);
if(v2) { if(v2) {
if(v2->defn == n) if(v2->defn == n)
v2->type = t2; v2->type = t2;
else if(v2->type != T && assignop(t2, v2->type, &why) == 0) else if(v2->type != T && assignop(t2, v2->type, &why) == 0)
yyerror("cannot assign type %T to %+N in range%s", t2, v2, why); yyerror("cannot assign type %T to %lN in range%s", t2, v2, why);
} }
out: out:
......
...@@ -592,9 +592,8 @@ dcommontype(Sym *s, int ot, Type *t) ...@@ -592,9 +592,8 @@ dcommontype(Sym *s, int ot, Type *t)
if(!haspointers(t)) if(!haspointers(t))
i |= KindNoPointers; i |= KindNoPointers;
ot = duint8(s, ot, i); // kind ot = duint8(s, ot, i); // kind
longsymnames = 1; p = smprint("%-uT", t);
p = smprint("%-T", t); //print("dcommontype: %s\n", p);
longsymnames = 0;
ot = dgostringptr(s, ot, p); // string ot = dgostringptr(s, ot, p); // string
free(p); free(p);
...@@ -614,8 +613,9 @@ typesym(Type *t) ...@@ -614,8 +613,9 @@ typesym(Type *t)
char *p; char *p;
Sym *s; Sym *s;
p = smprint("%#-T", t); p = smprint("%-T", t);
s = pkglookup(p, typepkg); s = pkglookup(p, typepkg);
//print("typesym: %s -> %+S\n", p, s);
free(p); free(p);
return s; return s;
} }
...@@ -662,8 +662,9 @@ weaktypesym(Type *t) ...@@ -662,8 +662,9 @@ weaktypesym(Type *t)
weak->prefix = "weak.type"; // not weak%2etype weak->prefix = "weak.type"; // not weak%2etype
} }
p = smprint("%#-T", t); p = smprint("%-T", t);
s = pkglookup(p, weak); s = pkglookup(p, weak);
//print("weaktypesym: %s -> %+S\n", p, s);
free(p); free(p);
return s; return s;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -80,7 +80,7 @@ no: ...@@ -80,7 +80,7 @@ no:
return N; return N;
bad: bad:
yyerror("invalid expression %#N", nn); yyerror("invalid expression %N", nn);
v = 0; v = 0;
goto ret; goto ret;
......
...@@ -284,7 +284,7 @@ walkstmt(Node **np) ...@@ -284,7 +284,7 @@ walkstmt(Node **np)
// OAS2FUNC in disguise // OAS2FUNC in disguise
f = n->list->n; f = n->list->n;
if(f->op != OCALLFUNC && f->op != OCALLMETH && f->op != OCALLINTER) if(f->op != OCALLFUNC && f->op != OCALLMETH && f->op != OCALLINTER)
fatal("expected return of call, have %#N", f); fatal("expected return of call, have %N", f);
n->list = concat(list1(f), ascompatet(n->op, rl, &f->type, 0, &n->ninit)); n->list = concat(list1(f), ascompatet(n->op, rl, &f->type, 0, &n->ninit));
break; break;
} }
...@@ -2189,7 +2189,7 @@ vmkcall(Node *fn, Type *t, NodeList **init, va_list va) ...@@ -2189,7 +2189,7 @@ vmkcall(Node *fn, Type *t, NodeList **init, va_list va)
NodeList *args; NodeList *args;
if(fn->type == T || fn->type->etype != TFUNC) if(fn->type == T || fn->type->etype != TFUNC)
fatal("mkcall %#N %T", fn, fn->type); fatal("mkcall %N %T", fn, fn->type);
args = nil; args = nil;
n = fn->type->intuple; n = fn->type->intuple;
......
...@@ -356,7 +356,7 @@ var fmttests = []struct { ...@@ -356,7 +356,7 @@ var fmttests = []struct {
{"%#v", map[string]int{"a": 1}, `map[string] int{"a":1}`}, {"%#v", map[string]int{"a": 1}, `map[string] int{"a":1}`},
{"%#v", map[string]B{"a": {1, 2}}, `map[string] fmt_test.B{"a":fmt_test.B{I:1, j:2}}`}, {"%#v", map[string]B{"a": {1, 2}}, `map[string] fmt_test.B{"a":fmt_test.B{I:1, j:2}}`},
{"%#v", []string{"a", "b"}, `[]string{"a", "b"}`}, {"%#v", []string{"a", "b"}, `[]string{"a", "b"}`},
{"%#v", SI{}, `fmt_test.SI{I:interface { }(nil)}`}, {"%#v", SI{}, `fmt_test.SI{I:interface {}(nil)}`},
// slices with other formats // slices with other formats
{"%#x", []int{1, 2, 15}, `[0x1 0x2 0xf]`}, {"%#x", []int{1, 2, 15}, `[0x1 0x2 0xf]`},
......
...@@ -434,7 +434,7 @@ func TestInterfaceGet(t *testing.T) { ...@@ -434,7 +434,7 @@ func TestInterfaceGet(t *testing.T) {
inter.E = 123.456 inter.E = 123.456
v1 := ValueOf(&inter) v1 := ValueOf(&inter)
v2 := v1.Elem().Field(0) v2 := v1.Elem().Field(0)
assert(t, v2.Type().String(), "interface { }") assert(t, v2.Type().String(), "interface {}")
i2 := v2.Interface() i2 := v2.Interface()
v3 := ValueOf(i2) v3 := ValueOf(i2)
assert(t, v3.Type().String(), "float64") assert(t, v3.Type().String(), "float64")
...@@ -447,7 +447,7 @@ func TestInterfaceValue(t *testing.T) { ...@@ -447,7 +447,7 @@ func TestInterfaceValue(t *testing.T) {
inter.E = 123.456 inter.E = 123.456
v1 := ValueOf(&inter) v1 := ValueOf(&inter)
v2 := v1.Elem().Field(0) v2 := v1.Elem().Field(0)
assert(t, v2.Type().String(), "interface { }") assert(t, v2.Type().String(), "interface {}")
v3 := v2.Elem() v3 := v2.Elem()
assert(t, v3.Type().String(), "float64") assert(t, v3.Type().String(), "float64")
......
...@@ -15,7 +15,7 @@ var ( ...@@ -15,7 +15,7 @@ var (
_ = sum() _ = sum()
_ = sum(1.0, 2.0) _ = sum(1.0, 2.0)
_ = sum(1.5) // ERROR "integer" _ = sum(1.5) // ERROR "integer"
_ = sum("hello") // ERROR ".hello. .type string. as type int|incompatible" _ = sum("hello") // ERROR ".hello. .type ideal string. as type int|incompatible"
_ = sum([]int{1}) // ERROR "\[\]int literal.*as type int|incompatible" _ = sum([]int{1}) // ERROR "\[\]int literal.*as type int|incompatible"
) )
......
...@@ -12,6 +12,6 @@ func main() { ...@@ -12,6 +12,6 @@ func main() {
var x interface{} var x interface{}
switch t := x.(type) { // GC_ERROR "0 is not a type" switch t := x.(type) { // GC_ERROR "0 is not a type"
case 0: // GCCGO_ERROR "expected type" case 0: // GCCGO_ERROR "expected type"
t.x = 1 // ERROR "type interface \{ \}|reference to undefined field or method" t.x = 1 // ERROR "type interface \{\}|reference to undefined field or method"
} }
} }
...@@ -37,7 +37,7 @@ func main() { ...@@ -37,7 +37,7 @@ func main() {
asBool(true) asBool(true)
asBool(*&b) asBool(*&b)
asBool(Bool(true)) asBool(Bool(true))
asBool(1 != 2) // ERROR "cannot use.*type bool.*as type Bool" asBool(1 != 2) // ERROR "cannot use.*type ideal bool.*as type Bool"
asBool(i < j) // ERROR "cannot use.*type bool.*as type Bool" asBool(i < j) // ERROR "cannot use.*type bool.*as type Bool"
_, b = m[2] // ERROR "cannot .* bool.*type Bool" _, b = m[2] // ERROR "cannot .* bool.*type Bool"
......
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