]> Cypherpunks repositories - gostls13.git/commit
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)
committerIan Lance Taylor <iant@golang.org>
Wed, 6 Mar 2019 21:16:20 +0000 (21:16 +0000)
commit711ea1e716b0c620cd9bcdd405eccae230d6dcbb
tree609ba7dc1c8bc0e872dac35afdc9a26f756d4966
parentedf8539fad89c22a7846196ae2f8920a480c1230
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>
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