1
0
mirror of https://github.com/golang/go synced 2024-11-14 20:50:30 -07:00
go/misc/cgo/test/issue20129.go
Hiroshi Ioka 289a8719ce cmd/cgo: unwrap typedef-chains before type checking
clang can emit some dwarf.VoidType which are wrapped by multiple
dwarf.TypedefType. We need to unwrap those before further processing.

Fixes #20129

Change-Id: I671ce6aef2dc7b55f1a02aec5f9789ac1b369643
Reviewed-on: https://go-review.googlesource.com/44772
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-27 23:02:34 +00:00

34 lines
694 B
Go

// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package cgotest
/*
int issue20129 = 0;
typedef void issue20129Void;
issue20129Void issue20129Foo() {
issue20129 = 1;
}
typedef issue20129Void issue20129Void2;
issue20129Void2 issue20129Bar() {
issue20129 = 2;
}
*/
import "C"
import "testing"
func test20129(t *testing.T) {
if C.issue20129 != 0 {
t.Fatal("test is broken")
}
C.issue20129Foo()
if C.issue20129 != 1 {
t.Errorf("got %v but expected %v", C.issue20129, 1)
}
C.issue20129Bar()
if C.issue20129 != 2 {
t.Errorf("got %v but expected %v", C.issue20129, 2)
}
}