Source file test/fixedbugs/issue31573.go

     1  // errorcheck -0 -m -l
     2  
     3  // Copyright 2019 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package p
     8  
     9  func f(...*int) {}
    10  
    11  func g() {
    12  	defer f()
    13  	defer f(new(int))           // ERROR "... argument does not escape$" "new\(int\) does not escape$"
    14  	defer f(new(int), new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$"
    15  
    16  	defer f(nil...)
    17  	defer f([]*int{}...)                   // ERROR "\[\]\*int{} does not escape$"
    18  	defer f([]*int{new(int)}...)           // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$"
    19  	defer f([]*int{new(int), new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$"
    20  
    21  	go f()
    22  	go f(new(int))           // ERROR "... argument does not escape$" "new\(int\) does not escape$"
    23  	go f(new(int), new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$"
    24  
    25  	go f(nil...)
    26  	go f([]*int{}...)                   // ERROR "\[\]\*int{} does not escape$"
    27  	go f([]*int{new(int)}...)           // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$"
    28  	go f([]*int{new(int), new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$"
    29  
    30  	for {
    31  		defer f()
    32  		defer f(new(int))           // ERROR "... argument does not escape$" "new\(int\) does not escape$"
    33  		defer f(new(int), new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$"
    34  
    35  		defer f(nil...)
    36  		defer f([]*int{}...)                   // ERROR "\[\]\*int{} does not escape$"
    37  		defer f([]*int{new(int)}...)           // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$"
    38  		defer f([]*int{new(int), new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$"
    39  
    40  		go f()
    41  		go f(new(int))           // ERROR "... argument does not escape$" "new\(int\) does not escape$"
    42  		go f(new(int), new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$"
    43  
    44  		go f(nil...)
    45  		go f([]*int{}...)                   // ERROR "\[\]\*int{} does not escape$"
    46  		go f([]*int{new(int)}...)           // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$"
    47  		go f([]*int{new(int), new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$"
    48  	}
    49  }
    50  

View as plain text