diff options
| author | Aliaksandr Valialkin <valyala@gmail.com> | 2016-03-06 02:21:08 +0200 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2016-03-16 05:12:48 +0000 |
| commit | fee86e4aa81712596d2e6151dc85821953dde107 (patch) | |
| tree | 190ca5d04f8b439c6882becb86d6068ebcfe0700 /src/cmd/vet/testdata | |
| parent | 55567d37e9c0543347239df69888f5f321fc9d08 (diff) | |
| download | go-git-fee86e4aa81712596d2e6151dc85821953dde107.tar.gz | |
cmd/vet: added some missing copylock checks
Fixes #14664
Change-Id: I8bda2435857772f590859808904c48d768b87d46
Reviewed-on: https://go-review.googlesource.com/20254
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/cmd/vet/testdata')
| -rw-r--r-- | src/cmd/vet/testdata/copylock.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/cmd/vet/testdata/copylock.go b/src/cmd/vet/testdata/copylock.go index 03d0c33f36..2b8cec1420 100644 --- a/src/cmd/vet/testdata/copylock.go +++ b/src/cmd/vet/testdata/copylock.go @@ -7,6 +7,21 @@ func OkFunc() { p := x var y sync.Mutex p = &y + + var z = sync.Mutex{} + w := sync.Mutex{} + + w = sync.Mutex{} + q := struct{ L sync.Mutex }{ + L: sync.Mutex{}, + } + + yy := []Tlock{ + sync.Tlock{}, + sync.Tlock{ + once: sync.Once{}, + }, + } } type Tlock struct { @@ -25,4 +40,19 @@ func BadFunc() { tp = &t *tp = t // ERROR "assignment copies lock value to \*tp: testdata.Tlock contains sync.Once contains sync.Mutex" t = *tp // ERROR "assignment copies lock value to t: testdata.Tlock contains sync.Once contains sync.Mutex" + + y := *x // ERROR "assignment copies lock value to y: sync.Mutex" + var z = t // ERROR "variable declaration copies lock value to z: testdata.Tlock contains sync.Once contains sync.Mutex" + + w := struct{ L sync.Mutex }{ + L: *x, // ERROR "literal copies lock value from \*x: sync.Mutex" + } + var q = map[int]Tlock{ + 1: t, // ERROR "literal copies lock value from t: testdata.Tlock contains sync.Once contains sync.Mutex" + 2: *tp, // ERROR "literal copies lock value from \*tp: testdata.Tlock contains sync.Once contains sync.Mutex" + } + yy := []Tlock{ + t, // ERROR "literal copies lock value from t: testdata.Tlock contains sync.Once contains sync.Mutex" + *tp, // ERROR "literal copies lock value from \*tp: testdata.Tlock contains sync.Once contains sync.Mutex" + } } |
