5 // This file is the input to TestValueForExpr in source_test.go, which
6 // ensures that each expression e immediately following a /*@kind*/(x)
7 // annotation, when passed to Function.ValueForExpr(e), returns a
8 // non-nil Value of the same type as e and of kind 'kind'.
10 func f(spilled, unspilled int) {
11 _ = /*@UnOp*/ (spilled)
12 _ = /*@Parameter*/ (unspilled)
13 _ = /*@nil*/ (1 + 2) // (constant)
16 f := func() (int, int) { return 0, 0 }
19 (print( /*@BinOp*/ (i + 1)))
20 _, _ = /*@Call*/ (f())
21 ch := /*@MakeChan*/ (make(chan int))
26 case /*@Extract*/ (<-ch):
27 case x := /*@Extract*/ (<-ch):
30 defer /*@Function*/ (func() {
32 go /*@Function*/ (func() {
35 if true && /*@BinOp*/ (bool(y > 0)) {
39 map1 := /*@MakeMap*/ (make(map[string]string))
41 _ = /*@Slice*/ (make([]int, 0))
42 _ = /*@MakeClosure*/ (func() { print(spilled) })
45 _ = /*@Slice*/ (sl[:0])
47 _ = /*@nil*/ (new(int)) // optimized away
48 tmp := /*@Alloc*/ (new(int))
51 _ = /*@TypeAssert*/ (iface.(int))
53 _ = /*@IndexAddr*/ (&sl[0])
54 _ = /*@Index*/ ([2]int{}[0])
58 _ = /*@UnOp*/ (global)
59 /*@UnOp*/ (global)[""] = ""
60 /*@Global*/ (global) = map[string]string{}
63 /*UnOp*/ (local.x) = 1
65 // Exercise corner-cases of lvalues vs rvalues.
68 /*@UnOp*/ (n) = /*@UnOp*/ (n)
69 /*@ChangeType*/ (n) = /*@Alloc*/ (&n)
70 /*@UnOp*/ (n) = /*@UnOp*/ (*n)
71 /*@UnOp*/ (n) = /*@UnOp*/ (**n)
75 // Composite literals.
76 // We get different results for
77 // - composite literal as value (e.g. operand to print)
78 // - composite literal initializer for addressable value
79 // - composite literal value assigned to blank var
82 print( /*@Slice*/ ([]int{}))
83 print( /*@Alloc*/ (&[]int{}))
84 print(& /*@Slice*/ ([]int{}))
86 sl1 := /*@Slice*/ ([]int{})
87 sl2 := /*@Alloc*/ (&[]int{})
88 sl3 := & /*@Slice*/ ([]int{})
89 _, _, _ = sl1, sl2, sl3
91 _ = /*@Slice*/ ([]int{})
92 _ = /*@nil*/ (& /*@Slice*/ ([]int{})) // & optimized away
93 _ = & /*@Slice*/ ([]int{})
96 print( /*@UnOp*/ ([1]int{}))
97 print( /*@Alloc*/ (&[1]int{}))
98 print(& /*@Alloc*/ ([1]int{}))
100 arr1 := /*@Alloc*/ ([1]int{})
101 arr2 := /*@Alloc*/ (&[1]int{})
102 arr3 := & /*@Alloc*/ ([1]int{})
103 _, _, _ = arr1, arr2, arr3
105 _ = /*@UnOp*/ ([1]int{})
106 _ = /*@Alloc*/ (& /*@Alloc*/ ([1]int{}))
107 _ = & /*@Alloc*/ ([1]int{})
111 print( /*@MakeMap*/ (M{}))
112 print( /*@Alloc*/ (&M{}))
113 print(& /*@MakeMap*/ (M{}))
115 m1 := /*@MakeMap*/ (M{})
116 m2 := /*@Alloc*/ (&M{})
117 m3 := & /*@MakeMap*/ (M{})
120 _ = /*@MakeMap*/ (M{})
121 _ = /*@nil*/ (& /*@MakeMap*/ (M{})) // & optimized away
122 _ = & /*@MakeMap*/ (M{})
125 print( /*@UnOp*/ (struct{}{}))
126 print( /*@Alloc*/ (&struct{}{}))
127 print(& /*@Alloc*/ (struct{}{}))
129 s1 := /*@Alloc*/ (struct{}{})
130 s2 := /*@Alloc*/ (&struct{}{})
131 s3 := & /*@Alloc*/ (struct{}{})
134 _ = /*@UnOp*/ (struct{}{})
135 _ = /*@Alloc*/ (& /*@Alloc*/ (struct{}{}))
136 _ = & /*@Alloc*/ (struct{}{})
139 type t struct{ x int }
141 // Ensure we can locate methods of named types.
142 func (t) f(param int) {
143 _ = /*@Parameter*/ (param)
146 // Ensure we can locate init functions.
148 m := /*@MakeMap*/ (make(map[string]string))
152 // Ensure we can locate variables in initializer expressions.
153 var global = /*@MakeMap*/ (make(map[string]string))