~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to test/nilptr3.go

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-11-18 15:12:26 UTC
  • mfrom: (14.2.12 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20141118151226-zug7vn93mn3dtiz3
Tags: 2:1.3.2-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - Support co-installability with gccgo-go tool:
    - d/rules,golang-go.install: Rename bin/go -> bin/golang-go
    - d/golang-go.{postinst,prerm}: Install/remove /usr/bin/go using
      alternatives.
  - d/copyright: Amendments for full compiliance with copyright format.
  - d/control: Demote golang-go.tools to Suggests to support Ubuntu MIR.
  - dropped patches (now upstream):
    - d/p/issue27650045_40001_50001.diff
    - d/p/issue28050043_60001_70001.diff
    - d/p/issue54790044_100001_110001.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
type BigStruct struct {
18
18
        X int
19
19
        Y float64
20
 
        A [1<<20]int
 
20
        A [1 << 20]int
21
21
        Z string
22
22
}
23
23
 
29
29
}
30
30
 
31
31
var (
32
 
        intp *int
33
 
        arrayp *[10]int
34
 
        array0p *[0]int
35
 
        bigarrayp *[1<<26]int
36
 
        structp *Struct
 
32
        intp       *int
 
33
        arrayp     *[10]int
 
34
        array0p    *[0]int
 
35
        bigarrayp  *[1 << 26]int
 
36
        structp    *Struct
37
37
        bigstructp *BigStruct
38
 
        emptyp *Empty
39
 
        empty1p *Empty1
 
38
        emptyp     *Empty
 
39
        empty1p    *Empty1
40
40
)
41
41
 
42
42
func f1() {
43
43
        _ = *intp // ERROR "generated nil check"
44
 
        
 
44
 
45
45
        // This one should be removed but the block copy needs
46
46
        // to be turned into its own pseudo-op in order to see
47
47
        // the indirect.
48
48
        _ = *arrayp // ERROR "generated nil check"
49
 
        
50
 
        // 0-byte indirect doesn't suffice
51
 
        _ = *array0p // ERROR "generated nil check"
52
 
        _ = *array0p // ERROR "removed repeated nil check" 386
53
 
 
54
 
        _ = *intp // ERROR "removed repeated nil check"
55
 
        _ = *arrayp // ERROR "removed repeated nil check"
 
49
 
 
50
        // 0-byte indirect doesn't suffice.
 
51
        // we don't registerize globals, so there are no removed repeated nil checks.
 
52
        _ = *array0p // ERROR "generated nil check"
 
53
        _ = *array0p // ERROR "generated nil check"
 
54
 
 
55
        _ = *intp    // ERROR "generated nil check"
 
56
        _ = *arrayp  // ERROR "generated nil check"
56
57
        _ = *structp // ERROR "generated nil check"
57
 
        _ = *emptyp // ERROR "generated nil check"
58
 
        _ = *arrayp // ERROR "removed repeated nil check"
 
58
        _ = *emptyp  // ERROR "generated nil check"
 
59
        _ = *arrayp  // ERROR "generated nil check"
59
60
}
60
61
 
61
62
func f2() {
62
63
        var (
63
 
                intp *int
64
 
                arrayp *[10]int
65
 
                array0p *[0]int
66
 
                bigarrayp *[1<<20]int
67
 
                structp *Struct
 
64
                intp       *int
 
65
                arrayp     *[10]int
 
66
                array0p    *[0]int
 
67
                bigarrayp  *[1 << 20]int
 
68
                structp    *Struct
68
69
                bigstructp *BigStruct
69
 
                emptyp *Empty
70
 
                empty1p *Empty1
 
70
                emptyp     *Empty
 
71
                empty1p    *Empty1
71
72
        )
72
73
 
73
 
        _ = *intp // ERROR "generated nil check"
74
 
        _ = *arrayp // ERROR "generated nil check"
75
 
        _ = *array0p // ERROR "generated nil check"
76
 
        _ = *array0p // ERROR "removed repeated nil check"
77
 
        _ = *intp // ERROR "removed repeated nil check"
78
 
        _ = *arrayp // ERROR "removed repeated nil check"
79
 
        _ = *structp // ERROR "generated nil check"
80
 
        _ = *emptyp // ERROR "generated nil check"
81
 
        _ = *arrayp // ERROR "removed repeated nil check"
82
 
        _ = *bigarrayp // ERROR "generated nil check" ARM removed nil check before indirect!!
 
74
        _ = *intp       // ERROR "generated nil check"
 
75
        _ = *arrayp     // ERROR "generated nil check"
 
76
        _ = *array0p    // ERROR "generated nil check"
 
77
        _ = *array0p    // ERROR "removed repeated nil check"
 
78
        _ = *intp       // ERROR "removed repeated nil check"
 
79
        _ = *arrayp     // ERROR "removed repeated nil check"
 
80
        _ = *structp    // ERROR "generated nil check"
 
81
        _ = *emptyp     // ERROR "generated nil check"
 
82
        _ = *arrayp     // ERROR "removed repeated nil check"
 
83
        _ = *bigarrayp  // ERROR "generated nil check" ARM removed nil check before indirect!!
83
84
        _ = *bigstructp // ERROR "generated nil check"
84
 
        _ = *empty1p // ERROR "generated nil check"
 
85
        _ = *empty1p    // ERROR "generated nil check"
85
86
}
86
87
 
87
88
func fx10k() *[10000]int
 
89
 
88
90
var b bool
89
91
 
90
 
 
91
92
func f3(x *[10000]int) {
92
93
        // Using a huge type and huge offsets so the compiler
93
94
        // does not expect the memory hardware to fault.
94
95
        _ = x[9999] // ERROR "generated nil check"
95
 
        
 
96
 
96
97
        for {
97
98
                if x[9999] != 0 { // ERROR "generated nil check"
98
99
                        break
99
100
                }
100
101
        }
101
 
        
102
 
        x = fx10k() 
103
 
        _ = x[9999] // ERROR "generated nil check"
104
 
        if b {
105
 
                _ = x[9999] // ERROR "removed repeated nil check"
106
 
        } else {
107
 
                _ = x[9999] // ERROR "removed repeated nil check"
108
 
        }       
109
 
        _ = x[9999] // ERROR "generated nil check"
110
 
 
111
 
        x = fx10k() 
112
 
        if b {
113
 
                _ = x[9999] // ERROR "generated nil check"
114
 
        } else {
115
 
                _ = x[9999] // ERROR "generated nil check"
116
 
        }       
117
 
        _ = x[9999] // ERROR "generated nil check"
118
 
        
 
102
 
 
103
        x = fx10k()
 
104
        _ = x[9999] // ERROR "generated nil check"
 
105
        if b {
 
106
                _ = x[9999] // ERROR "removed repeated nil check"
 
107
        } else {
 
108
                _ = x[9999] // ERROR "removed repeated nil check"
 
109
        }
 
110
        _ = x[9999] // ERROR "generated nil check"
 
111
 
 
112
        x = fx10k()
 
113
        if b {
 
114
                _ = x[9999] // ERROR "generated nil check"
 
115
        } else {
 
116
                _ = x[9999] // ERROR "generated nil check"
 
117
        }
 
118
        _ = x[9999] // ERROR "generated nil check"
 
119
 
119
120
        fx10k()
120
121
        // This one is a bit redundant, if we figured out that
121
122
        // x wasn't going to change across the function call.
145
146
        _ = &x[9] // ERROR "removed repeated nil check"
146
147
}
147
148
 
148
 
func fx10() *[10]int 
 
149
func fx10() *[10]int
149
150
 
150
151
func f4(x *[10]int) {
151
152
        // Most of these have no checks because a real memory reference follows,
153
154
        // in the first unmapped page of memory.
154
155
 
155
156
        _ = x[9] // ERROR "removed nil check before indirect"
156
 
        
 
157
 
157
158
        for {
158
159
                if x[9] != 0 { // ERROR "removed nil check before indirect"
159
160
                        break
160
161
                }
161
162
        }
162
 
        
163
 
        x = fx10() 
 
163
 
 
164
        x = fx10()
164
165
        _ = x[9] // ERROR "removed nil check before indirect"
165
166
        if b {
166
167
                _ = x[9] // ERROR "removed nil check before indirect"
169
170
        }
170
171
        _ = x[9] // ERROR "removed nil check before indirect"
171
172
 
172
 
        x = fx10() 
 
173
        x = fx10()
173
174
        if b {
174
175
                _ = x[9] // ERROR "removed nil check before indirect"
175
176
        } else {
176
177
                _ = &x[9] // ERROR "generated nil check"
177
 
        }       
 
178
        }
178
179
        _ = x[9] // ERROR "removed nil check before indirect"
179
 
        
 
180
 
180
181
        fx10()
181
182
        _ = x[9] // ERROR "removed nil check before indirect"
182
 
        
 
183
 
183
184
        x = fx10()
184
185
        y := fx10()
185
186
        _ = &x[9] // ERROR "generated nil check"
188
189
        x = y
189
190
        _ = &x[9] // ERROR "removed repeated nil check"
190
191
}
191