@@ -301,18 +301,12 @@ func (p *Package) guessKinds(f *File) []*Name {
301
301
// void __cgo_f_xxx_4(void) { static const double __cgo_undefined__4 = (name); }
302
302
// #line xxx "not-str-lit"
303
303
// void __cgo_f_xxx_5(void) { static const char __cgo_undefined__5[] = (name); }
304
- // #line xxx "not-signed-int-const"
305
- // #if 0 < -(name)
306
- // #line xxx "not-signed-int-const"
307
- // #error found unsigned int
308
- // #endif
309
304
//
310
305
// If we see an error at not-declared:xxx, the corresponding name is not declared.
311
306
// If we see an error at not-type:xxx, the corresponding name is a type.
312
307
// If we see an error at not-int-const:xxx, the corresponding name is not an integer constant.
313
308
// If we see an error at not-num-const:xxx, the corresponding name is not a number constant.
314
309
// If we see an error at not-str-lit:xxx, the corresponding name is not a string literal.
315
- // If we see an error at not-signed-int-const:xxx, the corresponding name is not a signed integer literal.
316
310
//
317
311
// The specific input forms are chosen so that they are valid C syntax regardless of
318
312
// whether name denotes a type or an expression.
@@ -331,18 +325,12 @@ func (p *Package) guessKinds(f *File) []*Name {
331
325
"#line %d \" not-num-const\" \n " +
332
326
"void __cgo_f_%d_4(void) { static const double __cgo_undefined__4 = (%s); }\n " +
333
327
"#line %d \" not-str-lit\" \n " +
334
- "void __cgo_f_%d_5(void) { static const char __cgo_undefined__5[] = (%s); }\n " +
335
- "#line %d \" not-signed-int-const\" \n " +
336
- "#if 0 < (%s)\n " +
337
- "#line %d \" not-signed-int-const\" \n " +
338
- "#error found unsigned int\n " +
339
- "#endif\n " ,
328
+ "void __cgo_f_%d_5(void) { static const char __cgo_undefined__5[] = (%s); }\n " ,
340
329
i + 1 , i + 1 , n .C ,
341
330
i + 1 , i + 1 , n .C ,
342
331
i + 1 , i + 1 , n .C ,
343
332
i + 1 , i + 1 , n .C ,
344
333
i + 1 , i + 1 , n .C ,
345
- i + 1 , n .C , i + 1 ,
346
334
)
347
335
}
348
336
fmt .Fprintf (& b , "#line 1 \" completed\" \n " +
@@ -361,7 +349,6 @@ func (p *Package) guessKinds(f *File) []*Name {
361
349
notNumConst
362
350
notStrLiteral
363
351
notDeclared
364
- notSignedIntConst
365
352
)
366
353
sawUnmatchedErrors := false
367
354
for _ , line := range strings .Split (stderr , "\n " ) {
@@ -415,8 +402,6 @@ func (p *Package) guessKinds(f *File) []*Name {
415
402
sniff [i ] |= notNumConst
416
403
case "not-str-lit" :
417
404
sniff [i ] |= notStrLiteral
418
- case "not-signed-int-const" :
419
- sniff [i ] |= notSignedIntConst
420
405
default :
421
406
if isError {
422
407
sawUnmatchedErrors = true
@@ -432,15 +417,11 @@ func (p *Package) guessKinds(f *File) []*Name {
432
417
}
433
418
434
419
for i , n := range names {
435
- switch sniff [i ] &^ notSignedIntConst {
420
+ switch sniff [i ] {
436
421
default :
437
422
error_ (f .NamePos [n ], "could not determine kind of name for C.%s" , fixGo (n .Go ))
438
423
case notStrLiteral | notType :
439
- if sniff [i ]& notSignedIntConst != 0 {
440
- n .Kind = "uconst"
441
- } else {
442
- n .Kind = "iconst"
443
- }
424
+ n .Kind = "iconst"
444
425
case notIntConst | notStrLiteral | notType :
445
426
n .Kind = "fconst"
446
427
case notIntConst | notNumConst | notType :
@@ -485,7 +466,7 @@ func (p *Package) loadDWARF(f *File, names []*Name) {
485
466
b .WriteString ("#line 1 \" cgo-dwarf-inference\" \n " )
486
467
for i , n := range names {
487
468
fmt .Fprintf (& b , "__typeof__(%s) *__cgo__%d;\n " , n .C , i )
488
- if n .Kind == "iconst" || n . Kind == "uconst" {
469
+ if n .Kind == "iconst" {
489
470
fmt .Fprintf (& b , "enum { __cgo_enum__%d = %s };\n " , i , n .C )
490
471
}
491
472
}
@@ -494,7 +475,7 @@ func (p *Package) loadDWARF(f *File, names []*Name) {
494
475
// so we can read them out of the object file.
495
476
fmt .Fprintf (& b , "long long __cgodebug_ints[] = {\n " )
496
477
for _ , n := range names {
497
- if n .Kind == "iconst" || n . Kind == "uconst" {
478
+ if n .Kind == "iconst" {
498
479
fmt .Fprintf (& b , "\t %s,\n " , n .C )
499
480
} else {
500
481
fmt .Fprintf (& b , "\t 0,\n " )
@@ -592,11 +573,11 @@ func (p *Package) loadDWARF(f *File, names []*Name) {
592
573
switch n .Kind {
593
574
case "iconst" :
594
575
if i < len (ints ) {
595
- n . Const = fmt . Sprintf ( "%#x" , ints [i ])
596
- }
597
- case "uconst" :
598
- if i < len ( ints ) {
599
- n . Const = fmt . Sprintf ( "%#x" , uint64 ( ints [ i ]))
576
+ if _ , ok := types [i ].( * dwarf. UintType ); ok {
577
+ n . Const = fmt . Sprintf ( "%#x" , uint64 ( ints [ i ]))
578
+ } else {
579
+ n . Const = fmt . Sprintf ( "%#x" , ints [ i ])
580
+ }
600
581
}
601
582
case "fconst" :
602
583
if i < len (floats ) {
0 commit comments