1// 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|invalid constant type" 16const _ = myPointer(uintptr(1)) // ERROR "is not (a )?constant|invalid constant type" 17 18const _ = (*int)(unsafe.Pointer(uintptr(1))) // ERROR "is not (a )?constant|invalid constant type" 19const _ = (*int)(myPointer(uintptr(1))) // ERROR "is not (a )?constant|invalid constant type" 20 21const _ = uintptr(unsafe.Pointer(uintptr(1))) // ERROR "is not (a )?constant|expression is not constant" 22const _ = uintptr(myPointer(uintptr(1))) // ERROR "is not (a )?constant|expression is no constant" 23 24const _ = []byte("") // ERROR "is not (a )?constant|invalid constant type" 25const _ = []rune("") // ERROR "is not (a )?constant|invalid constant type" 26