From 387e7c274249a307f62ed94c8dfdabfe42e3b01c Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sun, 22 Jan 2012 11:50:45 -0800 Subject: [PATCH] test: explicitly use variables to avoid gccgo "not used" error I haven't looked at the source, but the gc compiler appears to omit "not used" errors when there is an error in the initializer. This is harder to do in gccgo, and frankly I think the "not used" error is still useful even if the initializer has a problem. This CL tweaks some tests to avoid the error, which is not the point of these tests in any case. R=golang-dev, r CC=golang-dev https://golang.org/cl/5561059 --- test/blank1.go | 1 + test/fixedbugs/bug014.go | 1 + test/fixedbugs/bug108.go | 1 + test/fixedbugs/bug175.go | 2 +- test/fixedbugs/bug363.go | 2 +- test/func4.go | 1 + test/indirect1.go | 1 + 7 files changed, 7 insertions(+), 2 deletions(-) diff --git a/test/blank1.go b/test/blank1.go index 5bc1efce5fd..bcc78466dc2 100644 --- a/test/blank1.go +++ b/test/blank1.go @@ -9,4 +9,5 @@ package _ // ERROR "invalid package name _" func main() { _() // ERROR "cannot use _ as value" x := _+1 // ERROR "cannot use _ as value" + _ = x } diff --git a/test/fixedbugs/bug014.go b/test/fixedbugs/bug014.go index dac2ce5174a..38a6e51abcb 100644 --- a/test/fixedbugs/bug014.go +++ b/test/fixedbugs/bug014.go @@ -11,4 +11,5 @@ func main() { var c01 uint8 = '\07'; // ERROR "oct|char" var cx0 uint8 = '\x0'; // ERROR "hex|char" var cx1 uint8 = '\x'; // ERROR "hex|char" + _, _, _, _ = c00, c01, cx0, cx1 } diff --git a/test/fixedbugs/bug108.go b/test/fixedbugs/bug108.go index 5c7649f0819..10e406de6ea 100644 --- a/test/fixedbugs/bug108.go +++ b/test/fixedbugs/bug108.go @@ -7,4 +7,5 @@ package main func f() { v := 1 << 1025; // ERROR "overflow|stupid shift" + _ = v } diff --git a/test/fixedbugs/bug175.go b/test/fixedbugs/bug175.go index a8f6e3ca406..1ca14150765 100644 --- a/test/fixedbugs/bug175.go +++ b/test/fixedbugs/bug175.go @@ -10,5 +10,5 @@ func f() (int, bool) { return 0, true } func main() { x, y := f(), 2; // ERROR "multi" + _, _ = x, y } - diff --git a/test/fixedbugs/bug363.go b/test/fixedbugs/bug363.go index 04fcfe1a875..9347ec28b62 100644 --- a/test/fixedbugs/bug363.go +++ b/test/fixedbugs/bug363.go @@ -17,5 +17,5 @@ func main() { println(b) var c int64 = (1<