PR tree-optimization/86274 - SEGFAULT when logging std::to_string(NAN)
[official-gcc.git] / libgo / go / cmd / vet / testdata / copylock_range.go
blobf127381213cd7571e4d5ed350f615420be7279ad
1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // This file contains tests for the copylock checker's
6 // range statement analysis.
8 package testdata
10 import "sync"
12 func rangeMutex() {
13 var mu sync.Mutex
14 var i int
16 var s []sync.Mutex
17 for range s {
19 for i = range s {
21 for i := range s {
23 for i, _ = range s {
25 for i, _ := range s {
27 for _, mu = range s { // ERROR "range var mu copies lock: sync.Mutex"
29 for _, m := range s { // ERROR "range var m copies lock: sync.Mutex"
31 for i, mu = range s { // ERROR "range var mu copies lock: sync.Mutex"
33 for i, m := range s { // ERROR "range var m copies lock: sync.Mutex"
36 var a [3]sync.Mutex
37 for _, m := range a { // ERROR "range var m copies lock: sync.Mutex"
40 var m map[sync.Mutex]sync.Mutex
41 for k := range m { // ERROR "range var k copies lock: sync.Mutex"
43 for mu, _ = range m { // ERROR "range var mu copies lock: sync.Mutex"
45 for k, _ := range m { // ERROR "range var k copies lock: sync.Mutex"
47 for _, mu = range m { // ERROR "range var mu copies lock: sync.Mutex"
49 for _, v := range m { // ERROR "range var v copies lock: sync.Mutex"
52 var c chan sync.Mutex
53 for range c {
55 for mu = range c { // ERROR "range var mu copies lock: sync.Mutex"
57 for v := range c { // ERROR "range var v copies lock: sync.Mutex"
60 // Test non-idents in range variables
61 var t struct {
62 i int
63 mu sync.Mutex
65 for t.i, t.mu = range s { // ERROR "range var t.mu copies lock: sync.Mutex"