mirror of
https://github.com/golang/go.git
synced 2025-05-28 02:41:30 +00:00
cgo: fix enum const conflict
This change prevents enum consts from conflicting with themselves when loaded twice in different go files. Fixes #1400. R=rsc CC=golang-dev https://golang.org/cl/3849044
This commit is contained in:
parent
4bdaf59cc9
commit
02ff646fef
@ -372,8 +372,12 @@ func (p *Package) loadDWARF(f *File, names []*Name) {
|
||||
} else {
|
||||
n.Type = conv.Type(types[i])
|
||||
if enums[i] != 0 && n.Type.EnumValues != nil {
|
||||
k := fmt.Sprintf("__cgo_enum__%d", i)
|
||||
n.Kind = "const"
|
||||
n.Const = strconv.Itoa64(n.Type.EnumValues[fmt.Sprintf("__cgo_enum__%d", i)])
|
||||
n.Const = strconv.Itoa64(n.Type.EnumValues[k])
|
||||
// Remove injected enum to ensure the value will deep-compare
|
||||
// equally in future loads of the same constant.
|
||||
n.Type.EnumValues[k] = 0, false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user