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 _ = /*@Load*/ (spilled)
12 _ = /*@Parameter*/ (unspilled)
13 _ = /*@nil*/ (1 + 2) // (constant)
16 f := func() (int, int) { return 0, 0 }
18 (print( /*@BinOp*/ (i + 1)))
19 _, _ = /*@Call*/ (f())
20 ch := /*@MakeChan*/ (make(chan int))
25 case /*@Extract*/ (<-ch):
26 case x := /*@Extract*/ (<-ch):
29 defer /*@Function*/ (func() {
31 go /*@Function*/ (func() {
34 if true && /*@BinOp*/ (bool(y > 0)) {
38 map1 := /*@MakeMap*/ (make(map[string]string))
40 _ = /*@Slice*/ (make([]int, 0))
41 _ = /*@MakeClosure*/ (func() { print(spilled) })
44 _ = /*@Slice*/ (sl[:0])
46 _ = /*@Alloc*/ (new(int))
47 tmp := /*@Alloc*/ (new(int))
50 _ = /*@TypeAssert*/ (iface.(int))
52 _ = /*@IndexAddr*/ (&sl[0])
53 _ = /*@Index*/ ([2]int{}[0])
57 _ = /*@Load*/ (global)
58 /*@Load*/ (global)[""] = ""
59 /*@Global*/ (global) = map[string]string{}
62 /*UnOp*/ (local.x) = 1
64 // Exercise corner-cases of lvalues vs rvalues.
67 /*@Load*/ (n) = /*@Load*/ (n)
68 /*@ChangeType*/ (n) = /*@Alloc*/ (&n)
69 /*@Load*/ (n) = /*@Load*/ (*n)
70 /*@Load*/ (n) = /*@Load*/ (**n)
74 // Composite literals.
75 // We get different results for
76 // - composite literal as value (e.g. operand to print)
77 // - composite literal initializer for addressable value
78 // - composite literal value assigned to blank var
81 print( /*@Slice*/ ([]int{}))
82 print( /*@Alloc*/ (&[]int{}))
83 print(& /*@Slice*/ ([]int{}))
85 sl1 := /*@Slice*/ ([]int{})
86 sl2 := /*@Alloc*/ (&[]int{})
87 sl3 := & /*@Slice*/ ([]int{})
88 _, _, _ = sl1, sl2, sl3
90 _ = /*@Slice*/ ([]int{})
91 _ = /*@Alloc*/ (& /*@Slice*/ ([]int{}))
92 _ = & /*@Slice*/ ([]int{})
95 print( /*@Load*/ ([1]int{}))
96 print( /*@Alloc*/ (&[1]int{}))
97 print(& /*@Alloc*/ ([1]int{}))
99 arr1 := /*@Alloc*/ ([1]int{})
100 arr2 := /*@Alloc*/ (&[1]int{})
101 arr3 := & /*@Alloc*/ ([1]int{})
102 _, _, _ = arr1, arr2, arr3
104 _ = /*@Load*/ ([1]int{})
105 _ = /*@Alloc*/ (& /*@Alloc*/ ([1]int{}))
106 _ = & /*@Alloc*/ ([1]int{})
110 print( /*@MakeMap*/ (M{}))
111 print( /*@Alloc*/ (&M{}))
112 print(& /*@MakeMap*/ (M{}))
114 m1 := /*@MakeMap*/ (M{})
115 m2 := /*@Alloc*/ (&M{})
116 m3 := & /*@MakeMap*/ (M{})
119 _ = /*@MakeMap*/ (M{})
120 _ = /*@Alloc*/ (& /*@MakeMap*/ (M{}))
121 _ = & /*@MakeMap*/ (M{})
124 print( /*@Load*/ (struct{}{}))
125 print( /*@Alloc*/ (&struct{}{}))
126 print(& /*@Alloc*/ (struct{}{}))
128 s1 := /*@Alloc*/ (struct{}{})
129 s2 := /*@Alloc*/ (&struct{}{})
130 s3 := & /*@Alloc*/ (struct{}{})
133 _ = /*@Load*/ (struct{}{})
134 _ = /*@Alloc*/ (& /*@Alloc*/ (struct{}{}))
135 _ = & /*@Alloc*/ (struct{}{})
138 type t struct{ x int }
140 // Ensure we can locate methods of named types.
141 func (t) f(param int) {
142 _ = /*@Parameter*/ (param)
145 // Ensure we can locate init functions.
147 m := /*@MakeMap*/ (make(map[string]string))
151 // Ensure we can locate variables in initializer expressions.
152 var global = /*@MakeMap*/ (make(map[string]string))