History

enums and ints are compatible

Michael Matz committed 10 years ago

Commit b1a906b1 parent c0368602 files · +10 −0Browse files

Unified · Split

2 files
  1. tccgen.c +8 −0
  2. tests/tcctest.c +2 −0
tccgen.c+8−0
@@ -2565,6 +2565,14 @@ static int compare_types(CType *type1, CType *type2, int unqualified) · 2564 unmodified lines
2565 t1 &= ~VT_DEFSIGN;2565 t1 &= ~VT_DEFSIGN;
2566 t2 &= ~VT_DEFSIGN;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 /* XXX: bitfields ? */2576 /* XXX: bitfields ? */
2569 if (t1 != t2)2577 if (t1 != t2)
2570 return 0;2578 return 0;
tests/tcctest.c+2−0
@@ -590,6 +590,8 @@ enum test { · 589 unmodified lines
590void enum_test()590void enum_test()
591{591{
592 enum test b1;592 enum test b1;
593 /* The following should give no warning */
594 int *p = &b1;
593 printf("enum:\n%d %d %d %d %d %d\n",595 printf("enum:\n%d %d %d %d %d %d\n",
594 E0, E1, E2, E3, E4, E5);596 E0, E1, E2, E3, E4, E5);
595 b1 = 1;597 b1 = 1;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t