Reviewers: golang-dev_googlegroups.com,
Message:
Hello golang-dev@googlegroups.com,
I'd like you to review this change to
https://go.googlecode.com/hg/
Description:
cgo: process DWARF info even when debug data is used for value
Always process the DWARF info, even when the const value is determined
using the debug data block. This ensures that the injected enum is
removed and future loads of the same constant do not trigger
inconsistent definitions.
Fixes issue 4054.
Please review this at http://codereview.appspot.com/6501101/
Affected files:
M src/cmd/cgo/gcc.go
Index: src/cmd/cgo/gcc.go
===================================================================
--- a/src/cmd/cgo/gcc.go
+++ b/src/cmd/cgo/gcc.go
@@ -616,10 +616,7 @@
n.FuncType = conv.FuncType(f, pos)
} else {
n.Type = conv.Type(types[i], pos)
- // Prefer debug data over DWARF debug output, if we have it.
- if n.Kind == "const" && i < len(enumVal) {
- n.Const = fmt.Sprintf("%#x", enumVal[i])
- } else if enums[i] != 0 && n.Type.EnumValues != nil {
+ if enums[i] != 0 && n.Type.EnumValues != nil {
k := fmt.Sprintf("__cgo_enum__%d", i)
n.Kind = "const"
n.Const = fmt.Sprintf("%#x", n.Type.EnumValues[k])
@@ -627,6 +624,10 @@
// equally in future loads of the same constant.
delete(n.Type.EnumValues, k)
}
+ // Prefer debug data over DWARF debug output, if we have it.
+ if n.Kind == "const" && i < len(enumVal) {
+ n.Const = fmt.Sprintf("%#x", enumVal[i])
+ }
}
}