diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/cgo/gcc.go | 10 | ||||
| -rw-r--r-- | src/cmd/cgo/out.go | 24 |
2 files changed, 10 insertions, 24 deletions
diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go index 8fd490ce95..812e315eaf 100644 --- a/src/cmd/cgo/gcc.go +++ b/src/cmd/cgo/gcc.go @@ -1702,9 +1702,13 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type { c.ptrs[dt.Type] = append(c.ptrs[dt.Type], t) case *dwarf.QualType: - // Ignore qualifier. - t = c.Type(dt.Type, pos) - c.m[dtype] = t + t1 := c.Type(dt.Type, pos) + t.Size = t1.Size + t.Align = t1.Align + t.Go = t1.Go + t.EnumValues = nil + t.Typedef = "" + t.C.Set("%s "+dt.Qual, t1.C) return t case *dwarf.StructType: diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go index 1940f9176c..e82ec375a2 100644 --- a/src/cmd/cgo/out.go +++ b/src/cmd/cgo/out.go @@ -355,11 +355,7 @@ func (p *Package) structType(n *Name) (string, int64) { fmt.Fprintf(&buf, "\t\tchar __pad%d[%d];\n", off, pad) off += pad } - qual := "" - if c := t.C.String(); c[len(c)-1] == '*' { - qual = "const " - } - fmt.Fprintf(&buf, "\t\t%s%s r;\n", qual, t.C) + fmt.Fprintf(&buf, "\t\t%s r;\n", t.C) off += t.Size } if off%p.PtrSize != 0 { @@ -620,20 +616,10 @@ func (p *Package) writeOutputFunc(fgcc *os.File, n *Name) { } } fmt.Fprintf(fgcc, "%s(", n.C) - for i, t := range n.FuncType.Params { + for i := range n.FuncType.Params { if i > 0 { fmt.Fprintf(fgcc, ", ") } - // We know the type params are correct, because - // the Go equivalents had good type params. - // However, our version of the type omits the magic - // words const and volatile, which can provoke - // C compiler warnings. Silence them by casting - // all pointers to void*. (Eventually that will produce - // other warnings.) - if c := t.C.String(); c[len(c)-1] == '*' { - fmt.Fprintf(fgcc, "(void*)") - } fmt.Fprintf(fgcc, "a->p%d", i) } fmt.Fprintf(fgcc, ");\n") @@ -693,14 +679,10 @@ func (p *Package) writeGccgoOutputFunc(fgcc *os.File, n *Name) { } } fmt.Fprintf(fgcc, "%s(", n.C) - for i, t := range n.FuncType.Params { + for i := range n.FuncType.Params { if i > 0 { fmt.Fprintf(fgcc, ", ") } - // Cast to void* to avoid warnings due to omitted qualifiers. - if c := t.C.String(); c[len(c)-1] == '*' { - fmt.Fprintf(fgcc, "(void*)") - } fmt.Fprintf(fgcc, "p%d", i) } fmt.Fprintf(fgcc, ");\n") |
