Commit cc08650
committed
fix: cast bare comparisons to value type in function macro translation
C comparison operators return int (0 or 1), but Rust's produce bool.
Without the cast, macros like `#define GT(x, y) ((x) > (y))` generated
`-> i64` functions with a bool body, and comparisons used inside
arithmetic (`((x) > (y)) + 1`) failed to compile.
Wrap bare comparison results with `as vt` in translate_expr. Remove
the `expr_tokens_are_boolean` / `cond_is_raw_bool` short-circuits from
the logical-op and ternary handlers — they now always convert operands
via `!= 0`, which is slightly more verbose but correct for all nesting
patterns.1 parent 385a72f commit cc08650
File tree
6 files changed
+114
-38
lines changed- bindgen-tests/tests
- expectations/tests
- headers
- bindgen/ir
6 files changed
+114
-38
lines changedLines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
515 | | - | |
516 | | - | |
| 515 | + | |
517 | 516 | | |
518 | 517 | | |
519 | 518 | | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
530 | 523 | | |
531 | 524 | | |
532 | 525 | | |
533 | 526 | | |
534 | 527 | | |
535 | 528 | | |
536 | 529 | | |
537 | | - | |
538 | | - | |
539 | | - | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
540 | 533 | | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
| 534 | + | |
| 535 | + | |
546 | 536 | | |
547 | 537 | | |
548 | | - | |
549 | | - | |
550 | | - | |
| 538 | + | |
551 | 539 | | |
552 | 540 | | |
553 | 541 | | |
554 | 542 | | |
555 | | - | |
556 | | - | |
557 | | - | |
| 543 | + | |
558 | 544 | | |
559 | 545 | | |
560 | 546 | | |
| |||
574 | 560 | | |
575 | 561 | | |
576 | 562 | | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
577 | 575 | | |
578 | 576 | | |
579 | 577 | | |
| |||
682 | 680 | | |
683 | 681 | | |
684 | 682 | | |
685 | | - | |
| 683 | + | |
| 684 | + | |
686 | 685 | | |
687 | 686 | | |
688 | 687 | | |
| |||
0 commit comments