OSDN Git Service

84ff59d2f5d2e3302a962d580c5cd69a547ffa46
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / go.test / test / fixedbugs / bug177.go
1 // $G $D/$F.go && $L $F.$A && ./$A.out
2
3 // Copyright 2009 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 main
8 import "reflect"
9 type S1 struct { i int }
10 type S2 struct { S1 }
11 func main() {
12         typ := reflect.Typeof(S2{}).(*reflect.StructType);
13         f := typ.Field(0);
14         if f.Name != "S1" || f.Anonymous != true {
15                 println("BUG: ", f.Name, f.Anonymous);
16                 return;
17         }
18         f, ok := typ.FieldByName("S1");
19         if !ok {
20                 println("BUG: missing S1");
21                 return;
22         }
23         if !f.Anonymous {
24                 println("BUG: S1 is not anonymous");
25                 return;
26         }
27 }