]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.12] cmd/cgo: simplify and fix handling of untyped constants
authorRémy Oudompheng <remyoudompheng@gmail.com>
Fri, 1 Mar 2019 22:12:19 +0000 (23:12 +0100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 13 Mar 2019 20:57:52 +0000 (20:57 +0000)
commitf9d0594a471841f6ddd97a38f822da4f3461232f
treea7a725d869491aa3fead3141ce66de8a0fe17079
parent7294ede9610a311576cf4e81c0ed89718e89e39d
[release-branch.go1.12] cmd/cgo: simplify and fix handling of untyped constants

Instead of trying to guess type of constants in the AST,
which is hard, use the "var cgo%d Type = Constant"
so that typechecking is left to the Go compiler.

The previous code could still fail in some cases
for constants imported from other modules
or defined in other, non-cgo files.

Fixes #30527

Change-Id: I2120cd90e90a74b9d765eeec53f6a3d2cfc1b642
Reviewed-on: https://go-review.googlesource.com/c/go/+/164897
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 711ea1e716b0c620cd9bcdd405eccae230d6dcbb)
Reviewed-on: https://go-review.googlesource.com/c/go/+/165748
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
misc/cgo/test/testdata/issue30527.go [new file with mode: 0644]
misc/cgo/test/testdata/issue30527/a.go [new file with mode: 0644]
misc/cgo/test/testdata/issue30527/b.go [new file with mode: 0644]
src/cmd/cgo/ast.go
src/cmd/cgo/gcc.go
src/cmd/cgo/main.go