1
0
mirror of https://github.com/golang/go synced 2024-10-03 03:11:21 -06:00

gc: fix line number for redundant print

R=ken2
CC=golang-dev
https://golang.org/cl/5434111
This commit is contained in:
Russ Cox 2011-12-02 14:58:26 -05:00
parent 434a6c85cb
commit 7a42dddbe6
2 changed files with 24 additions and 19 deletions

View File

@ -66,7 +66,7 @@ static void fixlbrace(int);
%type <node> pseudocall range_stmt select_stmt %type <node> pseudocall range_stmt select_stmt
%type <node> simple_stmt %type <node> simple_stmt
%type <node> switch_stmt uexpr %type <node> switch_stmt uexpr
%type <node> xfndcl typedcl %type <node> xfndcl typedcl start_complit
%type <list> xdcl fnbody fnres loop_body dcl_name_list %type <list> xdcl fnbody fnres loop_body dcl_name_list
%type <list> new_name_list expr_list keyval_list braced_keyval_list expr_or_type_list xdcl_list %type <list> new_name_list expr_list keyval_list braced_keyval_list expr_or_type_list xdcl_list
@ -900,29 +900,34 @@ pexpr_no_paren:
$$ = nod(OCALL, $1, N); $$ = nod(OCALL, $1, N);
$$->list = list1($3); $$->list = list1($3);
} }
| comptype lbrace braced_keyval_list '}' | comptype lbrace start_complit braced_keyval_list '}'
{ {
// composite expression $$ = $3;
$$ = nod(OCOMPLIT, N, $1); $$->right = $1;
$$->list = $3; $$->list = $4;
fixlbrace($2); fixlbrace($2);
} }
| pexpr_no_paren '{' braced_keyval_list '}' | pexpr_no_paren '{' start_complit braced_keyval_list '}'
{ {
// composite expression $$ = $3;
$$ = nod(OCOMPLIT, N, $1); $$->right = $1;
$$->list = $3; $$->list = $4;
} }
| '(' expr_or_type ')' '{' braced_keyval_list '}' | '(' expr_or_type ')' '{' start_complit braced_keyval_list '}'
{ {
yyerror("cannot parenthesize type in composite literal"); $$ = $5;
// composite expression $$->right = $2;
$$ = nod(OCOMPLIT, N, $2); $$->list = $6;
$$->list = $5;
} }
| fnliteral | fnliteral
start_complit:
{
// composite expression.
// make node early so we get the right line number.
$$ = nod(OCOMPLIT, N, N);
}
keyval: keyval:
expr ':' complitexpr expr ':' complitexpr
{ {
@ -931,10 +936,10 @@ keyval:
complitexpr: complitexpr:
expr expr
| '{' braced_keyval_list '}' | '{' start_complit braced_keyval_list '}'
{ {
$$ = nod(OCOMPLIT, N, N); $$ = $2;
$$->list = $2; $$->list = $3;
} }
pexpr: pexpr:

View File

@ -1994,7 +1994,7 @@ pushtype(Node *n, Type *t)
else if(debug['s']) { else if(debug['s']) {
typecheck(&n->right, Etype); typecheck(&n->right, Etype);
if(n->right->type != T && eqtype(n->right->type, t)) if(n->right->type != T && eqtype(n->right->type, t))
print("%lL: redundant type: %T\n", n->right->lineno, t); print("%lL: redundant type: %T\n", n->lineno, t);
} }
} }