diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2011-01-11 10:15:49 -0500 |
---|---|---|
committer | Gustavo Niemeyer <gustavo@niemeyer.net> | 2011-01-11 10:15:49 -0500 |
commit | d91ddacf6fc1374274bd548b43ddc487cb3e64bf (patch) | |
tree | 11ba8df3e402504d60bfcf2b5603d3a68081192c /src/cmd | |
parent | 1174b970ef3c0b31aa8589111b2bcae30a850c71 (diff) | |
download | go-d91ddacf6fc1374274bd548b43ddc487cb3e64bf.tar.gz |
cgo: fix enum const conflict
This change prevents enum consts from conflicting with themselves
when loaded twice in different go files.
Fixes issue 1400.
R=rsc
CC=golang-dev
http://codereview.appspot.com/3849044
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/cgo/gcc.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go index 7626038c4..be3b8fe64 100644 --- a/src/cmd/cgo/gcc.go +++ b/src/cmd/cgo/gcc.go @@ -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 } } } |