diff options
| author | Hiroshi Ioka <hirochachacha@gmail.com> | 2018-12-05 08:01:07 +0900 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2018-12-05 14:12:14 +0000 |
| commit | 5e1727892bf36076ee45c417b56bba32801ffbd7 (patch) | |
| tree | b82cadedbf213e23f2e41cfcb4286458193a53a0 /misc/cgo/errors | |
| parent | 897e0807c30a7b1860c15d4c05d68907fbba9262 (diff) | |
| download | go-5e1727892bf36076ee45c417b56bba32801ffbd7.tar.xz | |
cmd/cgo: reject names that are likely to be mangled C name
Fixes #28721
Change-Id: I00356f3a9b0c2fb21dc9c2237dd5296fcb3b319b
Reviewed-on: https://go-review.googlesource.com/c/152657
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'misc/cgo/errors')
| -rw-r--r-- | misc/cgo/errors/errors_test.go | 1 | ||||
| -rw-r--r-- | misc/cgo/errors/src/issue28721.go | 29 |
2 files changed, 30 insertions, 0 deletions
diff --git a/misc/cgo/errors/errors_test.go b/misc/cgo/errors/errors_test.go index 0d7ca4cf9d..d2a72a46f4 100644 --- a/misc/cgo/errors/errors_test.go +++ b/misc/cgo/errors/errors_test.go @@ -121,6 +121,7 @@ func TestReportsTypeErrors(t *testing.T) { "issue16591.go", "issue18452.go", "issue18889.go", + "issue28721.go", } { check(t, file) } diff --git a/misc/cgo/errors/src/issue28721.go b/misc/cgo/errors/src/issue28721.go new file mode 100644 index 0000000000..0eb2a9271c --- /dev/null +++ b/misc/cgo/errors/src/issue28721.go @@ -0,0 +1,29 @@ +// Copyright 2018 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. + +// cgo should reject the use of mangled C names. + +package main + +/* +typedef struct a { + int i; +} a; +void fn(void) {} +*/ +import "C" + +type B _Ctype_struct_a // ERROR HERE + +var a _Ctype_struct_a // ERROR HERE + +type A struct { + a *_Ctype_struct_a // ERROR HERE +} + +var notExist _Ctype_NotExist // ERROR HERE + +func main() { + _Cfunc_fn() // ERROR HERE +} |
