History

Fix const folding of 64bit pointer constants

See testcase.

Michael Matz committed 10 years ago

Commit 3bc9c321 parent 0b0e64c2 files · +8 −2Browse files

Unified · Split

2 files
  1. tccgen.c +2 −2
  2. tests/tcctest.c +6 −0
tccgen.c+2−2
@@ -1659,10 +1659,10 @@ static void gen_opic(int op) · 1658 unmodified lines
16591659 uint64_t l2 = c2 ? v2->c.i : 0;
16601660 int shm = (t1 == VT_LLONG) ? 63 : 31;
16611661
1662− if (t1 != VT_LLONG)
1662+ if (t1 != VT_LLONG && (PTR_SIZE != 8 || t1 != VT_PTR))
16631663 l1 = ((uint32_t)l1 |
16641664 (v1->type.t & VT_UNSIGNED ? 0 : -(l1 & 0x80000000)));
1665− if (t2 != VT_LLONG)
1665+ if (t2 != VT_LLONG && (PTR_SIZE != 8 || t2 != VT_PTR))
16661666 l2 = ((uint32_t)l2 |
16671667 (v2->type.t & VT_UNSIGNED ? 0 : -(l2 & 0x80000000)));
16681668
tests/tcctest.c+6−0
@@ -946,6 +946,12 @@ void expr_ptr_test() · 945 unmodified lines
946946 j = -1;
947947 printf("%d\n", sp[j].i);
948948 }
949+#ifdef __LP64__
950+ i = 1;
951+ p = (int*)0x100000000UL + i;
952+ i = ((long)p) >> 32;
953+ printf("largeptr: %p %d\n", p, i);
954+#endif
949955 }
950956
951957 void expr_cmp_test()

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