@@ -305,18 +305,12 @@ func (p *Package) guessKinds(f *File) []*Name {
305
305
// void __cgo_f_xxx_4(void) { static const double __cgo_undefined__4 = (name); }
306
306
// #line xxx "not-str-lit"
307
307
// void __cgo_f_xxx_5(void) { static const char __cgo_undefined__5[] = (name); }
308
- // #line xxx "not-signed-int-const"
309
- // #if 0 < -(name)
310
- // #line xxx "not-signed-int-const"
311
- // #error found unsigned int
312
- // #endif
313
308
//
314
309
// If we see an error at not-declared:xxx, the corresponding name is not declared.
315
310
// If we see an error at not-type:xxx, the corresponding name is a type.
316
311
// If we see an error at not-int-const:xxx, the corresponding name is not an integer constant.
317
312
// If we see an error at not-num-const:xxx, the corresponding name is not a number constant.
318
313
// If we see an error at not-str-lit:xxx, the corresponding name is not a string literal.
319
- // If we see an error at not-signed-int-const:xxx, the corresponding name is not a signed integer literal.
320
314
//
321
315
// The specific input forms are chosen so that they are valid C syntax regardless of
322
316
// whether name denotes a type or an expression.
@@ -335,18 +329,12 @@ func (p *Package) guessKinds(f *File) []*Name {
335
329
"#line %d \" not-num-const\" \n " +
336
330
"void __cgo_f_%d_4(void) { static const double __cgo_undefined__4 = (%s); }\n " +
337
331
"#line %d \" not-str-lit\" \n " +
338
- "void __cgo_f_%d_5(void) { static const char __cgo_undefined__5[] = (%s); }\n " +
339
- "#line %d \" not-signed-int-const\" \n " +
340
- "#if 0 < (%s)\n " +
341
- "#line %d \" not-signed-int-const\" \n " +
342
- "#error found unsigned int\n " +
343
- "#endif\n " ,
332
+ "void __cgo_f_%d_5(void) { static const char __cgo_undefined__5[] = (%s); }\n " ,
344
333
i + 1 , i + 1 , n .C ,
345
334
i + 1 , i + 1 , n .C ,
346
335
i + 1 , i + 1 , n .C ,
347
336
i + 1 , i + 1 , n .C ,
348
337
i + 1 , i + 1 , n .C ,
349
- i + 1 , n .C , i + 1 ,
350
338
)
351
339
}
352
340
fmt .Fprintf (& b , "#line 1 \" completed\" \n " +
@@ -365,7 +353,6 @@ func (p *Package) guessKinds(f *File) []*Name {
365
353
notNumConst
366
354
notStrLiteral
367
355
notDeclared
368
- notSignedIntConst
369
356
)
370
357
sawUnmatchedErrors := false
371
358
for _ , line := range strings .Split (stderr , "\n " ) {
@@ -419,8 +406,6 @@ func (p *Package) guessKinds(f *File) []*Name {
419
406
sniff [i ] |= notNumConst
420
407
case "not-str-lit" :
421
408
sniff [i ] |= notStrLiteral
422
- case "not-signed-int-const" :
423
- sniff [i ] |= notSignedIntConst
424
409
default :
425
410
if isError {
426
411
sawUnmatchedErrors = true
@@ -436,7 +421,7 @@ func (p *Package) guessKinds(f *File) []*Name {
436
421
}
437
422
438
423
for i , n := range names {
439
- switch sniff [i ] &^ notSignedIntConst {
424
+ switch sniff [i ] {
440
425
default :
441
426
var tpos token.Pos
442
427
for _ , ref := range f .Ref {
@@ -447,11 +432,7 @@ func (p *Package) guessKinds(f *File) []*Name {
447
432
}
448
433
error_ (tpos , "could not determine kind of name for C.%s" , fixGo (n .Go ))
449
434
case notStrLiteral | notType :
450
- if sniff [i ]& notSignedIntConst != 0 {
451
- n .Kind = "uconst"
452
- } else {
453
- n .Kind = "iconst"
454
- }
435
+ n .Kind = "iconst"
455
436
case notIntConst | notStrLiteral | notType :
456
437
n .Kind = "fconst"
457
438
case notIntConst | notNumConst | notType :
@@ -496,7 +477,7 @@ func (p *Package) loadDWARF(f *File, names []*Name) {
496
477
b .WriteString ("#line 1 \" cgo-dwarf-inference\" \n " )
497
478
for i , n := range names {
498
479
fmt .Fprintf (& b , "__typeof__(%s) *__cgo__%d;\n " , n .C , i )
499
- if n .Kind == "iconst" || n . Kind == "uconst" {
480
+ if n .Kind == "iconst" {
500
481
fmt .Fprintf (& b , "enum { __cgo_enum__%d = %s };\n " , i , n .C )
501
482
}
502
483
}
@@ -505,7 +486,7 @@ func (p *Package) loadDWARF(f *File, names []*Name) {
505
486
// so we can read them out of the object file.
506
487
fmt .Fprintf (& b , "long long __cgodebug_ints[] = {\n " )
507
488
for _ , n := range names {
508
- if n .Kind == "iconst" || n . Kind == "uconst" {
489
+ if n .Kind == "iconst" {
509
490
fmt .Fprintf (& b , "\t %s,\n " , n .C )
510
491
} else {
511
492
fmt .Fprintf (& b , "\t 0,\n " )
@@ -614,11 +595,11 @@ func (p *Package) loadDWARF(f *File, names []*Name) {
614
595
switch n .Kind {
615
596
case "iconst" :
616
597
if i < len (ints ) {
617
- n . Const = fmt . Sprintf ( "%#x" , ints [i ])
618
- }
619
- case "uconst" :
620
- if i < len ( ints ) {
621
- n . Const = fmt . Sprintf ( "%#x" , uint64 ( ints [ i ]))
598
+ if _ , ok := types [i ].( * dwarf. UintType ); ok {
599
+ n . Const = fmt . Sprintf ( "%#x" , uint64 ( ints [ i ]))
600
+ } else {
601
+ n . Const = fmt . Sprintf ( "%#x" , ints [ i ])
602
+ }
622
603
}
623
604
case "fconst" :
624
605
if i < len (floats ) {
0 commit comments