func Test28896(t *testing.T) { test28896(t) }
func Test30065(t *testing.T) { test30065(t) }
func Test32579(t *testing.T) { test32579(t) }
+func Test31891(t *testing.T) { test31891(t) }
func TestAlign(t *testing.T) { testAlign(t) }
func TestAtol(t *testing.T) { testAtol(t) }
func TestBlocking(t *testing.T) { testBlocking(t) }
// Brittle: the assertion may fail spuriously when the algorithm
// changes, but should remain stable otherwise.
got := fmt.Sprintf("%T %T", in, opts)
- want := "issue9026._Ctype_struct___0 *issue9026._Ctype_struct___0"
+ want := "issue9026._Ctype_struct___0 *issue9026._Ctype_struct___1"
if got != want {
t.Errorf("Non-deterministic type names: got %s, want %s", got, want)
}
// issue 28772 part 2 - part 1 in issuex.go
#define issue28772Constant2 2
+
+// issue 31891
+typedef struct {
+ long obj;
+} Issue31891A;
+
+typedef struct {
+ long obj;
+} Issue31891B;
+
+void callIssue31891(void);
*/
import "C"
// issue 28772 part 2
const issue28772Constant2 = C.issue28772Constant2
+
+// issue 31891
+
+//export useIssue31891A
+func useIssue31891A(c *C.Issue31891A) {}
+
+//export useIssue31891B
+func useIssue31891B(c *C.Issue31891B) {}
+
+func test31891(t *testing.T) {
+ C.callIssue31891()
+}
// Type returns a *Type with the same memory layout as
// dtype when used as the type of a variable or a struct field.
func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type {
+ return c.loadType(dtype, pos, "")
+}
+
+// loadType recursively loads the requested dtype and its dependency graph.
+func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Type {
// Always recompute bad pointer typedefs, as the set of such
// typedefs changes as we see more types.
checkCache := true
checkCache = false
}
- key := dtype.String()
+ // The cache key should be relative to its parent.
+ // See issue https://golang.org/issue/31891
+ key := parent + " > " + dtype.String()
if checkCache {
if t, ok := c.m[key]; ok {
// Translate to zero-length array instead.
count = 0
}
- sub := c.Type(dt.Type, pos)
+ sub := c.loadType(dt.Type, pos, key)
t.Align = sub.Align
t.Go = &ast.ArrayType{
Len: c.intExpr(count),
c.ptrs[key] = append(c.ptrs[key], t)
case *dwarf.QualType:
- t1 := c.Type(dt.Type, pos)
+ t1 := c.loadType(dt.Type, pos, key)
t.Size = t1.Size
t.Align = t1.Align
t.Go = t1.Go
}
name := c.Ident("_Ctype_" + dt.Name)
goIdent[name.Name] = name
- sub := c.Type(dt.Type, pos)
+ sub := c.loadType(dt.Type, pos, key)
if c.badPointerTypedef(dt) {
// Treat this typedef as a uintptr.
s := *sub