OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [go/] [printer/] [testdata/] [statements.golden] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2009 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
package statements
6
 
7
var expr bool
8
 
9
func use(x interface{}) {}
10
 
11
// Formatting of if-statement headers.
12
func _() {
13
        if true {
14
        }
15
        if true {
16
        }       // no semicolon printed
17
        if expr {
18
        }
19
        if expr {
20
        }       // no semicolon printed
21
        if expr {
22
        }       // no parens printed
23
        if expr {
24
        }       // no semicolon and parens printed
25
        if x := expr; true {
26
                use(x)
27
        }
28
        if x := expr; expr {
29
                use(x)
30
        }
31
}
32
 
33
// Formatting of switch-statement headers.
34
func _() {
35
        switch {
36
        }
37
        switch {
38
        }       // no semicolon printed
39
        switch expr {
40
        }
41
        switch expr {
42
        }       // no semicolon printed
43
        switch expr {
44
        }       // no parens printed
45
        switch expr {
46
        }       // no semicolon and parens printed
47
        switch x := expr; {
48
        default:
49
                use(
50
                        x)
51
        }
52
        switch x := expr; expr {
53
        default:
54
                use(x)
55
        }
56
}
57
 
58
// Formatting of switch statement bodies.
59
func _() {
60
        switch {
61
        }
62
 
63
        switch x := 0; x {
64
        case 1:
65
                use(x)
66
                use(x)  // followed by an empty line
67
 
68
        case 2: // followed by an empty line
69
 
70
                use(x)  // followed by an empty line
71
 
72
        case 3: // no empty lines
73
                use(x)
74
                use(x)
75
        }
76
 
77
        switch x {
78
        case 0:
79
                use(x)
80
        case 1: // this comment should have no effect on the previous or next line
81
                use(x)
82
        }
83
 
84
        switch x := 0; x {
85
        case 1:
86
                x = 0
87
                // this comment should be indented
88
        case 2:
89
                x = 0
90
        // this comment should not be indented, it is aligned with the next case
91
        case 3:
92
                x = 0
93
                /* indented comment
94
                   aligned
95
                   aligned
96
                */
97
                // bla
98
                /* and more */
99
        case 4:
100
                x = 0
101
        /* not indented comment
102
           aligned
103
           aligned
104
        */
105
        // bla
106
        /* and more */
107
        case 5:
108
        }
109
}
110
 
111
// Formatting of selected select statements.
112
func _() {
113
        select {}
114
        select { /* this comment should not be tab-aligned because the closing } is on the same line */
115
        }
116
        select {        /* this comment should be tab-aligned */
117
        }
118
        select {        // this comment should be tab-aligned
119
        }
120
        select {
121
        case <-c:
122
        }
123
}
124
 
125
// Formatting of for-statement headers.
126
func _() {
127
        for {
128
        }
129
        for expr {
130
        }
131
        for expr {
132
        }       // no parens printed
133
        for {
134
        }       // no semicolons printed
135
        for x := expr; ; {
136
                use(x)
137
        }
138
        for expr {
139
        }       // no semicolons printed
140
        for expr {
141
        }       // no semicolons and parens printed
142
        for ; ; expr = false {
143
        }
144
        for x := expr; expr; {
145
                use(x)
146
        }
147
        for x := expr; ; expr = false {
148
                use(x)
149
        }
150
        for ; expr; expr = false {
151
        }
152
        for x := expr; expr; expr = false {
153
                use(x)
154
        }
155
        for x := range []int{} {
156
                use(x)
157
        }
158
        for x := range []int{} {
159
                use(x)
160
        }       // no parens printed
161
}
162
 
163
// Don't remove mandatory parentheses around composite literals in control clauses.
164
func _() {
165
        // strip parentheses - no composite literals or composite literals don't start with a type name
166
        if x {
167
        }
168
        if x {
169
        }
170
        if []T{} {
171
        }
172
        if []T{} {
173
        }
174
        if []T{} {
175
        }
176
 
177
        for x {
178
        }
179
        for x {
180
        }
181
        for []T{} {
182
        }
183
        for []T{} {
184
        }
185
        for []T{} {
186
        }
187
 
188
        switch x {
189
        }
190
        switch x {
191
        }
192
        switch []T{} {
193
        }
194
        switch []T{} {
195
        }
196
 
197
        for _ = range []T{T{42}} {
198
        }
199
 
200
        // leave parentheses - composite literals start with a type name
201
        if (T{}) {
202
        }
203
        if (T{}) {
204
        }
205
        if (T{}) {
206
        }
207
 
208
        for (T{}) {
209
        }
210
        for (T{}) {
211
        }
212
        for (T{}) {
213
        }
214
 
215
        switch (T{}) {
216
        }
217
        switch (T{}) {
218
        }
219
 
220
        for _ = range (T1{T{42}}) {
221
        }
222
 
223
        if x == (T{42}[0]) {
224
        }
225
        if (x == T{42}[0]) {
226
        }
227
        if x == (T{42}[0]) {
228
        }
229
        if x == (T{42}[0]) {
230
        }
231
        if x == (T{42}[0]) {
232
        }
233
        if x == a+b*(T{42}[0]) {
234
        }
235
        if (x == a+b*T{42}[0]) {
236
        }
237
        if x == a+b*(T{42}[0]) {
238
        }
239
        if x == a+(b * (T{42}[0])) {
240
        }
241
        if x == a+b*(T{42}[0]) {
242
        }
243
        if (a + b*(T{42}[0])) == x {
244
        }
245
        if (a + b*(T{42}[0])) == x {
246
        }
247
 
248
        if struct{ x bool }{false}.x {
249
        }
250
        if (struct{ x bool }{false}.x) == false {
251
        }
252
        if struct{ x bool }{false}.x == false {
253
        }
254
}
255
 
256
// Extra empty lines inside functions. Do respect source code line
257
// breaks between statement boundaries but print at most one empty
258
// line at a time.
259
func _() {
260
 
261
        const _ = 0
262
 
263
        const _ = 1
264
        type _ int
265
        type _ float
266
 
267
        var _ = 0
268
        var x = 1
269
 
270
        // Each use(x) call below should have at most one empty line before and after.
271
        // Known bug: The first use call may have more than one empty line before
272
        //            (see go/printer/nodes.go, func linebreak).
273
 
274
        use(x)
275
 
276
        if x < x {
277
 
278
                use(x)
279
 
280
        } else {
281
 
282
                use(x)
283
 
284
        }
285
}
286
 
287
// Formatting around labels.
288
func _() {
289
L:
290
}
291
 
292
func _() {
293
        // this comment should be indented
294
L:      // no semicolon needed
295
}
296
 
297
func _() {
298
        switch 0 {
299
        case 0:
300
        L0:
301
                ;       // semicolon required
302
        case 1:
303
        L1:
304
                ;       // semicolon required
305
        default:
306
        L2:     // no semicolon needed
307
        }
308
}
309
 
310
func _() {
311
        f()
312
L1:
313
        f()
314
L2:
315
        ;
316
L3:
317
}
318
 
319
func _() {
320
        // this comment should be indented
321
L:
322
}
323
 
324
func _() {
325
L:
326
        _ = 0
327
}
328
 
329
func _() {
330
        // this comment should be indented
331
L:
332
        _ = 0
333
}
334
 
335
func _() {
336
        for {
337
        L1:
338
                _ = 0
339
        L2:
340
                _ = 0
341
        }
342
}
343
 
344
func _() {
345
        // this comment should be indented
346
        for {
347
        L1:
348
                _ = 0
349
        L2:
350
                _ = 0
351
        }
352
}
353
 
354
func _() {
355
        if true {
356
                _ = 0
357
        }
358
        _ = 0   // the indentation here should not be affected by the long label name
359
AnOverlongLabel:
360
        _ = 0
361
 
362
        if true {
363
                _ = 0
364
        }
365
        _ = 0
366
 
367
L:
368
        _ = 0
369
}
370
 
371
func _() {
372
        for {
373
                goto L
374
        }
375
L:
376
 
377
        MoreCode()
378
}
379
 
380
func _() {
381
        for {
382
                goto L
383
        }
384
L:      // A comment on the same line as the label, followed by a single empty line.
385
        // Known bug: There may be more than one empty line before MoreCode()
386
        //            (see go/printer/nodes.go, func linebreak).
387
 
388
        MoreCode()
389
}
390
 
391
func _() {
392
        for {
393
                goto L
394
        }
395
L:
396
 
397
        // There should be a single empty line before this comment.
398
        MoreCode()
399
}
400
 
401
func _() {
402
        for {
403
                goto AVeryLongLabelThatShouldNotAffectFormatting
404
        }
405
AVeryLongLabelThatShouldNotAffectFormatting:
406
        // There should be a single empty line after this comment.
407
 
408
        // There should be a single empty line before this comment.
409
        MoreCode()
410
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.