From 5fbadf0bc375d63049c210b640dd6384b7ca890b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 12 Mar 2009 19:57:30 -0700 Subject: [PATCH] warn -> yyerror in mparith. close two more bugs. R=ken OCL=26226 CL=26226 --- src/cmd/gc/go.y | 8 +------ src/cmd/gc/mparith1.c | 4 ++-- src/cmd/gc/mparith2.c | 34 +++++++++++++++--------------- src/cmd/gc/mparith3.c | 6 +++--- test/{bugs => fixedbugs}/bug108.go | 2 +- test/{bugs => fixedbugs}/bug125.go | 2 +- test/golden.out | 7 ------ 7 files changed, 25 insertions(+), 38 deletions(-) rename test/{bugs => fixedbugs}/bug108.go (80%) rename test/{bugs => fixedbugs}/bug125.go (89%) diff --git a/src/cmd/gc/go.y b/src/cmd/gc/go.y index bbffa34bbe9..fd347177f20 100644 --- a/src/cmd/gc/go.y +++ b/src/cmd/gc/go.y @@ -215,12 +215,6 @@ xdcl: autoexport($1->nname->sym); $$ = N; } -| LPACKAGE { warn("package is gone"); } xfndcl - { - if($3 != N && $3->nname != N) - packagesym($3->nname->sym); - $$ = N; - } | ';' { $$ = N; @@ -1660,7 +1654,7 @@ exprsym3_list_r: import_stmt_list_r: import_stmt -| import_stmt_list_r osemi import_stmt +| import_stmt_list_r ';' import_stmt hidden_import_list_r: | hidden_import_list_r hidden_import diff --git a/src/cmd/gc/mparith1.c b/src/cmd/gc/mparith1.c index c4dbf9f0866..8bf71315208 100644 --- a/src/cmd/gc/mparith1.c +++ b/src/cmd/gc/mparith1.c @@ -308,7 +308,7 @@ out: return; bad: - warn("set ovf in mpatof"); + yyerror("set ovf in mpatof"); mpmovecflt(a, 0.0); } @@ -396,7 +396,7 @@ out: return; bad: - warn("set ovf in mpatov: %s", as); + yyerror("set ovf in mpatov: %s", as); mpmovecfix(a, 0); } diff --git a/src/cmd/gc/mparith2.c b/src/cmd/gc/mparith2.c index 2765ff5c2c4..9be8a16b788 100644 --- a/src/cmd/gc/mparith2.c +++ b/src/cmd/gc/mparith2.c @@ -119,7 +119,7 @@ mpcmp(Mpint *a, Mpint *b) int i; if(a->ovf || b->ovf) { - warn("ovf in cmp"); + yyerror("ovf in cmp"); return 0; } @@ -194,7 +194,7 @@ mpaddfixfix(Mpint *a, Mpint *b) long x, *a1, *b1; if(a->ovf || b->ovf) { - warn("ovf in mpaddxx"); + yyerror("ovf in mpaddxx"); a->ovf = 1; return; } @@ -217,7 +217,7 @@ mpaddfixfix(Mpint *a, Mpint *b) } a->ovf = c; if(a->ovf) - warn("set ovf in mpaddxx"); + yyerror("set ovf in mpaddxx"); return; @@ -264,7 +264,7 @@ mpmulfixfix(Mpint *a, Mpint *b) Mpint s, q; if(a->ovf || b->ovf) { - warn("ovf in mpmulfixfix"); + yyerror("ovf in mpmulfixfix"); a->ovf = 1; return; } @@ -297,7 +297,7 @@ mpmulfixfix(Mpint *a, Mpint *b) q.neg = a->neg ^ b->neg; mpmovefixfix(a, &q); if(a->ovf) - warn("set ovf in mpmulfixfix"); + yyerror("set ovf in mpmulfixfix"); } void @@ -309,7 +309,7 @@ mpmulfract(Mpint *a, Mpint *b) Mpint s, q; if(a->ovf || b->ovf) { - warn("ovf in mpmulflt"); + yyerror("ovf in mpmulflt"); a->ovf = 1; return; } @@ -336,7 +336,7 @@ mpmulfract(Mpint *a, Mpint *b) q.neg = a->neg ^ b->neg; mpmovefixfix(a, &q); if(a->ovf) - warn("set ovf in mpmulflt"); + yyerror("set ovf in mpmulflt"); } void @@ -346,7 +346,7 @@ mporfixfix(Mpint *a, Mpint *b) long x, *a1, *b1; if(a->ovf || b->ovf) { - warn("ovf in mporfixfix"); + yyerror("ovf in mporfixfix"); mpmovecfix(a, 0); a->ovf = 1; return; @@ -380,7 +380,7 @@ mpandfixfix(Mpint *a, Mpint *b) long x, *a1, *b1; if(a->ovf || b->ovf) { - warn("ovf in mpandfixfix"); + yyerror("ovf in mpandfixfix"); mpmovecfix(a, 0); a->ovf = 1; return; @@ -414,7 +414,7 @@ mpandnotfixfix(Mpint *a, Mpint *b) long x, *a1, *b1; if(a->ovf || b->ovf) { - warn("ovf in mpandnotfixfix"); + yyerror("ovf in mpandnotfixfix"); mpmovecfix(a, 0); a->ovf = 1; return; @@ -448,7 +448,7 @@ mpxorfixfix(Mpint *a, Mpint *b) long x, *a1, *b1; if(a->ovf || b->ovf) { - warn("ovf in mporfixfix"); + yyerror("ovf in mporfixfix"); mpmovecfix(a, 0); a->ovf = 1; return; @@ -481,14 +481,14 @@ mplshfixfix(Mpint *a, Mpint *b) vlong s; if(a->ovf || b->ovf) { - warn("ovf in mporfixfix"); + yyerror("ovf in mporfixfix"); mpmovecfix(a, 0); a->ovf = 1; return; } s = mpgetfix(b); if(s < 0 || s >= Mpprec*Mpscale) { - warn("stupid shift: %lld", s); + yyerror("stupid shift: %lld", s); mpmovecfix(a, 0); return; } @@ -502,14 +502,14 @@ mprshfixfix(Mpint *a, Mpint *b) vlong s; if(a->ovf || b->ovf) { - warn("ovf in mprshfixfix"); + yyerror("ovf in mprshfixfix"); mpmovecfix(a, 0); a->ovf = 1; return; } s = mpgetfix(b); if(s < 0 || s >= Mpprec*Mpscale) { - warn("stupid shift: %lld", s); + yyerror("stupid shift: %lld", s); if(a->neg) mpmovecfix(a, -1); else @@ -532,7 +532,7 @@ mpgetfix(Mpint *a) vlong v; if(a->ovf) { - warn("ovf in mpgetfix"); + yyerror("ovf in mpgetfix"); return 0; } @@ -588,7 +588,7 @@ mpdivmodfixfix(Mpint *q, Mpint *r, Mpint *n, Mpint *d) if(i >= Mpprec*Mpscale) { q->ovf = 1; r->ovf = 1; - warn("set ovf in mpdivmodfixfix"); + yyerror("set ovf in mpdivmodfixfix"); return; } diff --git a/src/cmd/gc/mparith3.c b/src/cmd/gc/mparith3.c index 8e3da7a4b3a..f97d0b829d6 100644 --- a/src/cmd/gc/mparith3.c +++ b/src/cmd/gc/mparith3.c @@ -134,7 +134,7 @@ mpdivfltflt(Mpflt *a, Mpflt *b) a->exp = 0; a->val.neg = 0; a->val.ovf = 1; - warn("mpdivfltflt divide by zero"); + yyerror("mpdivfltflt divide by zero"); return; } if(sa == 0) { @@ -165,14 +165,14 @@ mpgetflt(Mpflt *a) double f; if(a->val.ovf) - warn("mpgetflt ovf"); + yyerror("mpgetflt ovf"); s = sigfig(a); if(s == 0) return 0; if(s != Mpnorm) { - warn("mpgetflt norm"); + yyerror("mpgetflt norm"); mpnorm(a); } diff --git a/test/bugs/bug108.go b/test/fixedbugs/bug108.go similarity index 80% rename from test/bugs/bug108.go rename to test/fixedbugs/bug108.go index b7350e72cb2..5c7649f0819 100644 --- a/test/bugs/bug108.go +++ b/test/fixedbugs/bug108.go @@ -6,5 +6,5 @@ package main func f() { - v := 1 << 1025; // ERROR "overflow" + v := 1 << 1025; // ERROR "overflow|stupid shift" } diff --git a/test/bugs/bug125.go b/test/fixedbugs/bug125.go similarity index 89% rename from test/bugs/bug125.go rename to test/fixedbugs/bug125.go index c8c5f7dfa39..5670ce028b7 100644 --- a/test/bugs/bug125.go +++ b/test/fixedbugs/bug125.go @@ -8,7 +8,7 @@ package main import ( OS "os" // should require semicolon here; this is no different from other decls - IO "io" // ERROR "missing" + IO "io" // ERROR "missing|syntax" ) func main() { diff --git a/test/golden.out b/test/golden.out index c91bb450f31..31ca675c13d 100644 --- a/test/golden.out +++ b/test/golden.out @@ -106,10 +106,6 @@ abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz =========== chan/nonblock.go PASS -=========== bugs/bug108.go -bugs/bug108.go:4: stupid shift: 1025 -BUG: errchk: command succeeded unexpectedly: 6g bugs/bug108.go - =========== bugs/bug115.go bugs/bug115.go:8: constant -1 overflows uint BUG: bug115 should compile @@ -120,9 +116,6 @@ bugs/bug117.go:9: illegal types for operand: RETURN int BUG: should compile -=========== bugs/bug125.go -BUG: errchk: command succeeded unexpectedly: 6g bugs/bug125.go - =========== bugs/bug131.go bugs/bug131.go:7: cannot convert uint64 constant to int64 bugs/bug131.go:7: illegal types for operand: AS