From b610a78b6ef2d06a2172f4e532813572f28da007 Mon Sep 17 00:00:00 2001 From: Eric Clark Date: Thu, 16 Sep 2010 13:38:23 -0400 Subject: [PATCH] cgo: show preamble gcc errors Fixes #1081 R=rsc CC=golang-dev https://golang.org/cl/2112046 --- src/cmd/cgo/gcc.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go index ae3e4de7406..46316ea7828 100644 --- a/src/cmd/cgo/gcc.go +++ b/src/cmd/cgo/gcc.go @@ -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] == ":" { + 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)