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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [declbad.go] - Blame information for rev 700

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// errchk $G -e $F.go
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
// Incorrect short declarations and redeclarations.
8
 
9
package main
10
 
11
func f1() int                    { return 1 }
12
func f2() (float32, int)         { return 1, 2 }
13
func f3() (float32, int, string) { return 1, 2, "3" }
14
 
15
func main() {
16
        {
17
                // simple redeclaration
18
                i := f1()
19
                i := f1() // ERROR "redeclared|no new"
20
                _ = i
21
        }
22
        {
23
                // change of type for f
24
                i, f, s := f3()
25
                f, g, t := f3() // ERROR "redeclared|cannot assign|incompatible"
26
                _, _, _, _, _ = i, f, s, g, t
27
        }
28
        {
29
                // change of type for i
30
                i, f, s := f3()
31
                j, i, t := f3() // ERROR "redeclared|cannot assign|incompatible"
32
                _, _, _, _, _ = i, f, s, j, t
33
        }
34
        {
35
                // no new variables
36
                i, f, s := f3()
37
                i, f := f2() // ERROR "redeclared|no new"
38
                _, _, _ = i, f, s
39
        }
40
        {
41
                // single redeclaration
42
                i, f, s := f3()
43
                i := 1 // ERROR "redeclared|no new|incompatible"
44
                _, _, _ = i, f, s
45
        }
46
        // double redeclaration
47
        {
48
                i, f, s := f3()
49
                i, f := f2() // ERROR "redeclared|no new"
50
                _, _, _ = i, f, s
51
        }
52
        {
53
                // triple redeclaration
54
                i, f, s := f3()
55
                i, f, s := f3() // ERROR "redeclared|no new"
56
                _, _, _ = i, f, s
57
        }
58
}

powered by: WebSVN 2.1.0

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