blob: cccae48910a70bfc86f044dae80edcca90edbed3 [file] [log] [blame]
Matthew Dempsky7f40e5e2014-08-15 11:33:31 -07001// errorcheck
2
3// Copyright 2014 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// Verify that pointers can't be used as constants.
8
9package main
10
11import "unsafe"
12
13type myPointer unsafe.Pointer
14
15const _ = unsafe.Pointer(uintptr(1)) // ERROR "is not (a )?constant"
16const _ = myPointer(uintptr(1)) // ERROR "is not (a )?constant"
17
18const _ = (*int)(unsafe.Pointer(uintptr(1))) // ERROR "is not (a )?constant"
19const _ = (*int)(myPointer(uintptr(1))) // ERROR "is not (a )?constant"
20
21const _ = uintptr(unsafe.Pointer(uintptr(1))) // ERROR "is not (a )?constant"
22const _ = uintptr(myPointer(uintptr(1))) // ERROR "is not (a )?constant"
23
24const _ = []byte("") // ERROR "is not (a )?constant"
25const _ = []rune("") // ERROR "is not (a )?constant"