mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/cgo: don't ignore qualifiers, don't cast to void*
The cgo tool used to simply ignore C type qualifiers. To avoid problems when a C function expected a qualifier that was not present, cgo emitted a cast to void* around all pointer arguments. Unfortunately, that broke code that contains both a function declaration and a macro, when the macro required the argument to have the right type. To fix this problem, don't ignore qualifiers. They are easy enough to handle for the limited set of cases that matter for cgo, in which we don't care about array or function types. Fixes #17537. Change-Id: Ie2988d21db6ee016a3e99b07f53cfb0f1243a020 Reviewed-on: https://go-review.googlesource.com/33097 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
dc4a815d10
commit
fb8c896aff
4 changed files with 53 additions and 24 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue