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
35733573 /* ss <= 4 here */
35743574 if (ds <= 4) {
35753575 gv(RC_INT);
3576+ if (ds == 2 && (dbt & VT_UNSIGNED) &&
3577+ ss == 1 && (sbt & VT_UNSIGNED) == 0) {
3578+ vpushi(0xffff);
3579+ gen_op('&');
3580+ }
35763581 goto done; /* no 64bit envolved */
35773582 }
35783583 }
tests/bug.c+0−9
@@ -1,14 +1,6 @@
11 #include <stdio.h>
22 #include <stdarg.h>
33
4−void 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−
124 typedef struct{double x,y;}p;
135
146 void tst2(int n,...)
@@ -69,7 +61,6 @@ int · 54 unmodified lines
6961 main(void)
7062 {
7163 p v = { 1, 2};
72− tst1();
7364 tst2(1, v);
7465 tst3();
7566 }
tests/tests2/117_gcc_test.c+8−0
@@ -139,6 +139,13 @@ void tst_pack (void) · 138 unmodified lines
139139 if (j.f != i.f) printf("error\n");
140140 }
141141
142+void 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+
142149 int
143150 main (void)
144151 {
@@ -155,4 +162,5 @@ main (void) · 10 unmodified lines
155162 tst_builtin();
156163 tst_compare();
157164 tst_pack();
165+ tst_cast();
158166 }

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