Unified · Split
| @@ -2565,6 +2565,14 @@ static int compare_types(CType *type1, CType *type2, int unqualified) · 2564 unmodified lines | ||
| 2565 | 2565 | t1 &= ~VT_DEFSIGN; |
| 2566 | 2566 | t2 &= ~VT_DEFSIGN; |
| 2567 | 2567 | } |
| 2568 | + if ((t1 & VT_BTYPE) == VT_ENUM) { | |
| 2569 | + /* An enum is compatible with (unsigned) int. */ | |
| 2570 | + t1 = VT_INT | (t1 & ~VT_BTYPE); | |
| 2571 | + } | |
| 2572 | + if ((t2 & VT_BTYPE) == VT_ENUM) { | |
| 2573 | + /* An enum is compatible with (unsigned) int. */ | |
| 2574 | + t2 = VT_INT | (t2 & ~VT_BTYPE); | |
| 2575 | + } | |
| 2568 | 2576 | /* XXX: bitfields ? */ |
| 2569 | 2577 | if (t1 != t2) |
| 2570 | 2578 | return 0; |
| @@ -590,6 +590,8 @@ enum test { · 589 unmodified lines | ||
| 590 | 590 | void enum_test() |
| 591 | 591 | { |
| 592 | 592 | enum test b1; |
| 593 | + /* The following should give no warning */ | |
| 594 | + int *p = &b1; | |
| 593 | 595 | printf("enum:\n%d %d %d %d %d %d\n", |
| 594 | 596 | E0, E1, E2, E3, E4, E5); |
| 595 | 597 | b1 = 1; |