2018-01-24 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / go.test / test / undef.go
blob0a77e59370bc4116c848295e807a5c6ba2744fb1
1 // errorcheck
3 // Copyright 2010 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.
7 // Test line numbers in error messages.
8 // Does not compile.
10 package main
12 var (
13 _ = x // ERROR "undefined.*x"
14 _ = x // ERROR "undefined.*x"
15 _ = x // ERROR "undefined.*x"
18 type T struct {
19 y int
22 func foo() *T { return &T{y: 99} }
23 func bar() int { return y } // ERROR "undefined.*y"
25 type T1 struct {
26 y1 int
29 func foo1() *T1 { return &T1{y1: 99} }
30 var y1 = 2
31 func bar1() int { return y1 }
33 func f1(val interface{}) {
34 switch v := val.(type) {
35 default:
36 println(v)
40 func f2(val interface{}) {
41 switch val.(type) {
42 default:
43 println(v) // ERROR "undefined.*v"