History

Fix char to ushort cast

tccgen.c: - gen_cast: add check for char to ushort cast tests/bug.c: - remove tst1 tests/tests2/117_gcc_test.c: - add tst_cast

herman ten brugge committed 6 years ago

Commit a34a9771 parent 696b7653 files · +13 −9Browse files

Unified · Split

3 files
  1. tccgen.c +5 −0
  2. tests/bug.c +0 −9
  3. tests/tests2/117_gcc_test.c +8 −0
tccgen.c+5−0
@@ -3573,6 +3573,11 @@ again: · 3572 unmodified lines
3573 /* ss <= 4 here */3573 /* ss <= 4 here */
3574 if (ds <= 4) {3574 if (ds <= 4) {
3575 gv(RC_INT);3575 gv(RC_INT);
3576 if (ds == 2 && (dbt & VT_UNSIGNED) &&
3577 ss == 1 && (sbt & VT_UNSIGNED) == 0) {
3578 vpushi(0xffff);
3579 gen_op('&');
3580 }
3576 goto done; /* no 64bit envolved */3581 goto done; /* no 64bit envolved */
3577 }3582 }
3578 }3583 }
tests/bug.c+0−9
@@ -1,14 +1,6 @@
1#include <stdio.h>1#include <stdio.h>
2#include <stdarg.h>2#include <stdarg.h>
3 3
4void tst1(void)
5{
6 /* problem in gen_cast. Should mask unsigned types */
7 signed char c = (signed char) 0xffffffff;
8 int r = (unsigned short) c ^ (signed char) 0x99999999;
9 if (r != 0xffff0066) printf ("%x\n", r);
10}
11
12typedef struct{double x,y;}p;4typedef struct{double x,y;}p;
13 5
14void tst2(int n,...)6void tst2(int n,...)
@@ -69,7 +61,6 @@ int · 54 unmodified lines
69main(void)61main(void)
70{62{
71 p v = { 1, 2};63 p v = { 1, 2};
72 tst1();
73 tst2(1, v);64 tst2(1, v);
74 tst3();65 tst3();
75}66}
tests/tests2/117_gcc_test.c+8−0
@@ -139,6 +139,13 @@ void tst_pack (void) · 138 unmodified lines
139 if (j.f != i.f) printf("error\n");139 if (j.f != i.f) printf("error\n");
140}140}
141 141
142void tst_cast(void)
143{
144 signed char c = (signed char) 0xaaaaaaaa;
145 int r = (unsigned short) c ^ (signed char) 0x99999999;
146 if (r != 0xffff0033) printf ("%x\n", r);
147}
148
142int149int
143main (void)150main (void)
144{151{
@@ -155,4 +162,5 @@ main (void) · 10 unmodified lines
155 tst_builtin();162 tst_builtin();
156 tst_compare();163 tst_compare();
157 tst_pack();164 tst_pack();
165 tst_cast();
158}166}

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