Commit b6f59358 authored by Ken Thompson's avatar Ken Thompson

minor bugs

R=r
OCL=16163
CL=16163
parent 81672ef1
...@@ -176,6 +176,10 @@ dumpexporttype(Sym *s) ...@@ -176,6 +176,10 @@ dumpexporttype(Sym *s)
case TPTR64: case TPTR64:
if(t->type == T) if(t->type == T)
fatal("dumpexporttype: ptr %S", s); fatal("dumpexporttype: ptr %S", s);
if(t->type->etype == TFORW) {
yyerror("export of a undefined forward reference: %S", s);
break;
}
makeexportsym(t->type); makeexportsym(t->type);
ts = t->type->sym; ts = t->type->sym;
if(ts->exported == 0) if(ts->exported == 0)
......
...@@ -265,8 +265,7 @@ enum ...@@ -265,8 +265,7 @@ enum
ONAME, ONONAME, ONAME, ONONAME,
ODOT, ODOTPTR, ODOTMETH, ODOTINTER, ODOT, ODOTPTR, ODOTMETH, ODOTINTER,
ODCLFUNC, ODCLFIELD, ODCLARG, ODCLFUNC, ODCLFIELD, ODCLARG,
OLIST, OCMP, OLIST, OCMP, OPTR, OARRAY,
OPTR, OARRAY,
ORETURN, OFOR, OIF, OSWITCH, ORETURN, OFOR, OIF, OSWITCH,
OAS, OASOP, OCASE, OXCASE, OFALL, OXFALL, OAS, OASOP, OCASE, OXCASE, OFALL, OXFALL,
OGOTO, OPROC, ONEW, OEMPTY, OSELECT, OGOTO, OPROC, ONEW, OEMPTY, OSELECT,
......
...@@ -800,8 +800,11 @@ pexpr: ...@@ -800,8 +800,11 @@ pexpr:
} }
| convtype '{' keyexpr_list '}' | convtype '{' keyexpr_list '}'
{ {
// struct literal and conversions // composite literal
$$ = nod(OCONV, rev($3), N); $$ = rev($3);
if($$ == N)
$$ = nod(OEMPTY, N, N);
$$ = nod(OCONV, $$, N);
$$->type = $1; $$->type = $1;
} }
| fnliteral | fnliteral
...@@ -1266,11 +1269,6 @@ structdcl: ...@@ -1266,11 +1269,6 @@ structdcl:
$$->type = types[TINT32]; $$->type = types[TINT32];
}; };
} }
| LIMPORT structdcl
{
$$ = $2;
$$->etype = OIMPORT;
}
interfacedcl: interfacedcl:
new_name ',' interfacedcl new_name ',' interfacedcl
...@@ -1695,7 +1693,7 @@ hidden_importfield: ...@@ -1695,7 +1693,7 @@ hidden_importfield:
* to check whether the rest of the grammar is free of * to check whether the rest of the grammar is free of
* reduce/reduce conflicts, comment this section out by * reduce/reduce conflicts, comment this section out by
* removing the slash on the next line. * removing the slash on the next line.
* */
lpack: lpack:
LATYPE LATYPE
{ {
......
...@@ -287,11 +287,6 @@ loop: ...@@ -287,11 +287,6 @@ loop:
walkselect(n); walkselect(n);
goto ret; goto ret;
case OEMPTY:
if(top != Etop)
goto nottop;
goto ret;
case OIF: case OIF:
if(top != Etop) if(top != Etop)
goto nottop; goto nottop;
...@@ -500,16 +495,18 @@ loop: ...@@ -500,16 +495,18 @@ loop:
case OFALL: case OFALL:
case OINDREG: case OINDREG:
case OEMPTY:
goto ret; goto ret;
case OCONV: case OCONV:
if(top == Etop) if(top == Etop)
goto nottop; goto nottop;
walktype(n->left, Erv);
l = n->left; l = n->left;
if(l == N) if(l == N)
goto ret; goto ret;
walktype(l, Erv);
t = n->type; t = n->type;
if(t == T) if(t == T)
goto ret; goto ret;
...@@ -552,7 +549,6 @@ loop: ...@@ -552,7 +549,6 @@ loop:
// interface and structure // interface and structure
et = isandss(n->type, l); et = isandss(n->type, l);
if(et != Inone) { if(et != Inone) {
if(et == I2I) dump("conv", n);
indir(n, ifaceop(n->type, l, et)); indir(n, ifaceop(n->type, l, et));
goto ret; goto ret;
} }
...@@ -2980,14 +2976,10 @@ structlit(Node *n) ...@@ -2980,14 +2976,10 @@ structlit(Node *n)
l = structfirst(&savel, &n->type); l = structfirst(&savel, &n->type);
r = listfirst(&saver, &n->left); r = listfirst(&saver, &n->left);
if(r != N && r->op == OEMPTY)
r = N;
loop: loop:
if(l != T && l->etype == TFIELD && l->type->etype == TFUNC) {
// skip methods
l = structnext(&savel);
goto loop;
}
if(l == T || r == N) { if(l == T || r == N) {
if(l != T) if(l != T)
yyerror("struct literal expect expr of type %T", l); yyerror("struct literal expect expr of type %T", l);
...@@ -3027,6 +3019,8 @@ arraylit(Node *n) ...@@ -3027,6 +3019,8 @@ arraylit(Node *n)
// make it a closed array // make it a closed array
r = listfirst(&saver, &n->left); r = listfirst(&saver, &n->left);
if(r != N && r->op == OEMPTY)
r = N;
for(idx=0; r!=N; idx++) for(idx=0; r!=N; idx++)
r = listnext(&saver); r = listnext(&saver);
t->bound = idx; t->bound = idx;
...@@ -3037,6 +3031,8 @@ arraylit(Node *n) ...@@ -3037,6 +3031,8 @@ arraylit(Node *n)
idx = 0; idx = 0;
r = listfirst(&saver, &n->left); r = listfirst(&saver, &n->left);
if(r != N && r->op == OEMPTY)
r = N;
loop: loop:
if(r == N) if(r == N)
...@@ -3075,6 +3071,8 @@ maplit(Node *n) ...@@ -3075,6 +3071,8 @@ maplit(Node *n)
addtop = list(addtop, a); addtop = list(addtop, a);
r = listfirst(&saver, &n->left); r = listfirst(&saver, &n->left);
if(r != N && r->op == OEMPTY)
r = N;
loop: loop:
if(r == N) { if(r == N) {
......
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