Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #7760. LGTM=iant R=iant, remyoudompheng CC=golang-codereviews https://golang.org/cl/130720043
- Loading branch information
1 parent
fb0b923
commit 7f40e5e
Showing
2 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// errorcheck | ||
|
||
// Copyright 2014 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// Verify that pointers can't be used as constants. | ||
|
||
package main | ||
|
||
import "unsafe" | ||
|
||
type myPointer unsafe.Pointer | ||
|
||
const _ = unsafe.Pointer(uintptr(1)) // ERROR "is not (a )?constant" | ||
const _ = myPointer(uintptr(1)) // ERROR "is not (a )?constant" | ||
|
||
const _ = (*int)(unsafe.Pointer(uintptr(1))) // ERROR "is not (a )?constant" | ||
const _ = (*int)(myPointer(uintptr(1))) // ERROR "is not (a )?constant" | ||
|
||
const _ = uintptr(unsafe.Pointer(uintptr(1))) // ERROR "is not (a )?constant" | ||
const _ = uintptr(myPointer(uintptr(1))) // ERROR "is not (a )?constant" | ||
|
||
const _ = []byte("") // ERROR "is not (a )?constant" | ||
const _ = []rune("") // ERROR "is not (a )?constant" |