]> Cypherpunks repositories - gostls13.git/commitdiff
cgo: show preamble gcc errors
authorEric Clark <zerohp@gmail.com>
Thu, 16 Sep 2010 17:38:23 +0000 (13:38 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 16 Sep 2010 17:38:23 +0000 (13:38 -0400)
Fixes #1081

R=rsc
CC=golang-dev
https://golang.org/cl/2112046

src/cmd/cgo/gcc.go

index ae3e4de74068ee37acc87ba5de05f194eebdf421..46316ea782838396a627131e1eb9a34422e5b62c 100644 (file)
@@ -204,6 +204,9 @@ func (p *Package) guessKinds(f *File) []*Name {
 
        for _, line := range strings.Split(stderr, "\n", -1) {
                if len(line) < 9 || line[0:9] != "cgo-test:" {
+                       if len(line) > 8 && line[0:8] == "<stdin>:" {
+                               fatal("gcc produced unexpected output:\n%s\non input:\n%s", line, b.Bytes())
+                       }
                        continue
                }
                line = line[9:]
@@ -439,8 +442,9 @@ func (p *Package) rewriteRef(f *File) {
                case "type":
                        if r.Name.Kind != "type" {
                                error(r.Pos(), "expression C.%s used as type", r.Name.Go)
+                       } else {
+                               expr = r.Name.Type.Go
                        }
-                       expr = r.Name.Type.Go
                default:
                        if r.Name.Kind == "func" {
                                error(r.Pos(), "must call C.%s", r.Name.Go)