Skip to content

Commit a5a9a06

Browse files
cmd/cgo: in -godefs mode, don't change constant to type
Fixes #39534 Change-Id: Icbc1745935dd7098c09e2d35c61cd5bfbaa31c63 Reviewed-on: https://go-review.googlesource.com/c/go/+/237558 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
1 parent f7ba82d commit a5a9a06

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2020 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
//
5+
// +build ignore
6+
7+
package main
8+
9+
// enum { ENUMVAL = 0x1 };
10+
import "C"
11+
12+
const ENUMVAL = C.ENUMVAL

misc/cgo/testgodefs/testgodefs_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var filePrefixes = []string{
2424
"issue37479",
2525
"issue37621",
2626
"issue38649",
27+
"issue39534",
2728
}
2829

2930
func TestGoDefs(t *testing.T) {

src/cmd/cgo/gcc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ func (p *Package) rewriteRef(f *File) {
13541354

13551355
if *godefs {
13561356
// Substitute definition for mangled type name.
1357-
if r.Name.Type != nil {
1357+
if r.Name.Type != nil && r.Name.Kind == "type" {
13581358
expr = r.Name.Type.Go
13591359
}
13601360
if id, ok := expr.(*ast.Ident); ok {

0 commit comments

Comments
 (0)