LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2013 The Go Authors. All rights reserved. | 1 // Copyright 2013 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // This file contains tests for the copylock checker. | 5 // This file contains tests for the copylock checker's |
| 6 // function declaration analysis. |
6 | 7 |
7 package testdata | 8 package testdata |
8 | 9 |
9 import "sync" | 10 import "sync" |
10 | 11 |
11 func OkFunc(*sync.Mutex) {} | 12 func OkFunc(*sync.Mutex) {} |
12 func BadFunc(sync.Mutex) {} // ERROR "BadFunc passes Lock by value: sync.Mutex" | 13 func BadFunc(sync.Mutex) {} // ERROR "BadFunc passes Lock by value: sync.Mutex" |
13 func OkRet() *sync.Mutex {} | 14 func OkRet() *sync.Mutex {} |
14 func BadRet() sync.Mutex {} // ERROR "BadRet returns Lock by value: sync.Mutex" | 15 func BadRet() sync.Mutex {} // ERROR "BadRet returns Lock by value: sync.Mutex" |
15 | 16 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 type LocalOnce sync.Once | 81 type LocalOnce sync.Once |
81 | 82 |
82 func (LocalOnce) Bad() {} // ERROR "Bad passes Lock by value: testdata.LocalOnce
contains sync.Mutex" | 83 func (LocalOnce) Bad() {} // ERROR "Bad passes Lock by value: testdata.LocalOnce
contains sync.Mutex" |
83 | 84 |
84 // False negative: | 85 // False negative: |
85 // LocalMutex doesn't have a Lock method. | 86 // LocalMutex doesn't have a Lock method. |
86 // Nevertheless, it is probably a bad idea to pass it by value. | 87 // Nevertheless, it is probably a bad idea to pass it by value. |
87 type LocalMutex sync.Mutex | 88 type LocalMutex sync.Mutex |
88 | 89 |
89 func (LocalMutex) Bad() {} // WANTED: An error here :( | 90 func (LocalMutex) Bad() {} // WANTED: An error here :( |
LEFT | RIGHT |