History

update gen_cast

grischka committed 6 years ago

Commit 89372dc1 parent 35475b510 files · +371 −278Browse files

Showing the changes to tests (4 of 10 files). Show all

Unified · Split

4 files
  1. tests/Makefile +1 −0
  2. tests/tcctest.c +52 −6
  3. tests/tests2/88_codeopt.c +1 −1
  4. tests/tests2/96_nodata_wanted.expect +1 −1
tests/Makefile+1−0
@@ -269,6 +269,7 @@ cross-test : · 268 unmodified lines
269269 $(TOP)/arm-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
270270 $(TOP)/arm-wince-tcc$(EXESUF) $(TCCFLAGS-win) -c $(TOPSRC)/examples/ex3.c && echo "ok"
271271 $(TOP)/arm64-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
272+ $(TOP)/riscv64-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
272273 $(TOP)/c67-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
273274 $(TOP)/i386-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/win32/examples/hello_win.c && echo "ok"
274275 $(TOP)/x86_64-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/win32/examples/hello_win.c && echo "ok"
tests/tcctest.c+52−6
@@ -16,6 +16,10 @@ · 15 unmodified lines
1616
1717 #endif
1818
19+#ifndef __TINYC__
20+typedef __SIZE_TYPE__ uintptr_t;
21+#endif
22+
1923 #if defined(_WIN32)
2024 #define LONG_LONG_FORMAT "%lld"
2125 #define ULONG_LONG_FORMAT "%llu"
@@ -1163,7 +1167,7 @@ void struct_test() · 1141 unmodified lines
11631167 s->f3 = 1;
11641168 printf("st2: %d %d %d\n",
11651169 s->f1, s->f2, s->f3);
1166− printf("str_addr=%x\n", (int)st1.str - (int)&st1.f1);
1170+ printf("str_addr=%x\n", (int)(uintptr_t)st1.str - (int)(uintptr_t)&st1.f1);
11671171
11681172 /* align / size tests */
11691173 printf("aligntest1 sizeof=%d alignof=%d\n",
@@ -1203,10 +1207,17 @@ void struct_test() · 33 unmodified lines
12031207 printf("Large: offsetof(compound_head)=%d\n", (int)((char*)&ls.compound_head - (char*)&ls));
12041208 }
12051209
1210+/* simulate char/short return value with undefined upper bits */
1211+static int __csf(int x) { return x; }
1212+static void *_csf = __csf;
1213+#define csf(t,n) ((t(*)(int))_csf)(n)
1214+
12061215 /* XXX: depend on endianness */
12071216 void char_short_test()
12081217 {
12091218 int var1, var2;
1219+ char var3;
1220+ long long var4;
12101221
12111222 printf("char_short:\n");
12121223
@@ -1230,6 +1241,34 @@ void char_short_test() · 17 unmodified lines
12301241 printf("var1=%x\n", var1);
12311242 *(int *)&var1 = 0x08090a0b;
12321243 printf("var1=%x\n", var1);
1244+
1245+ var1 = 0x778899aa;
1246+ var4 = 0x11223344aa998877ULL;
1247+ var1 = var3 = var1 + 1;
1248+ var4 = var3 = var4 + 1;
1249+ printf("promote char/short assign %d "LONG_LONG_FORMAT"\n", var1, var4);
1250+ var1 = 0x778899aa;
1251+ var4 = 0x11223344aa998877ULL;
1252+ printf("promote char/short assign VA %d %d\n", var3 = var1 + 1, var3 = var4 + 1);
1253+ printf("promote char/short cast VA %d %d\n", (char)(var1 + 1), (char)(var4 + 1));
1254+ var1 = csf(unsigned char,0x89898989);
1255+ var4 = csf(char,0xabababab);
1256+ printf("promote char/short funcret %d "LONG_LONG_FORMAT"\n", var1, var4);
1257+ printf("promote char/short fumcret VA %d %d %d %d\n",
1258+ csf(unsigned short,0xcdcdcdcd),
1259+ csf(short,0xefefefef),
1260+ csf(_Bool,0x33221100),
1261+ csf(_Bool,0x33221101));
1262+ var3 = -10;
1263+ var1 = (char)(unsigned char)(var3 + 1);
1264+ var4 = (char)(unsigned char)(var3 + 1);
1265+ printf("promote multicast (char)(unsigned char) %d "LONG_LONG_FORMAT"\n", var1, var4);
1266+ var4 = 0x11223344aa998877ULL;
1267+ var4 = (unsigned)(int)(var4 + 1);
1268+ printf("promote multicast (unsigned)(int) "LONG_LONG_FORMAT"\n", var4);
1269+ var4 = 0x11223344bbaa9988ULL;
1270+ var4 = (unsigned)(char)(var4 + 1);
1271+ printf("promote multicast (unsigned)(char) "LONG_LONG_FORMAT"\n", var4);
12331272 }
12341273
12351274 /******************/
@@ -1679,6 +1718,10 @@ void cast_test() · 443 unmodified lines
16791718 printf("sizeof(-(char)'a') = %d\n", sizeof(-(char)'a'));
16801719 printf("sizeof(~(char)'a') = %d\n", sizeof(-(char)'a'));
16811720
1721+#ifdef __TINYC__
1722+# pragma comment(option, "-w")
1723+#endif
1724+
16821725 /* from pointer to integer types */
16831726 printf("%d %d %ld %ld %lld %lld\n",
16841727 (int)p, (unsigned int)p,
@@ -1689,6 +1732,10 @@ void cast_test() · 4 unmodified lines
16891732 printf("%p %p %p %p\n",
16901733 (void *)a, (void *)b, (void *)c, (void *)d);
16911734
1735+#ifdef __TINYC__
1736+# pragma comment(option, "-W")
1737+#endif
1738+
16921739 /* int to int with sign set */
16931740 printf("0x%lx\n", (unsigned long)(int)ul);
16941741 }
@@ -2347,7 +2394,7 @@ void funcptr_test() · 652 unmodified lines
23472394
23482395 /* Check that we can align functions */
23492396 func = aligned_function;
2350− printf("aligned_function (should be zero): %d\n", ((int)func) & 15);
2397+ printf("aligned_function (should be zero): %d\n", ((int)(uintptr_t)func) & 15);
23512398 }
23522399
23532400 void lloptest(long long a, long long b)
@@ -2549,6 +2596,9 @@ void longlong_test(void) · 195 unmodified lines
25492596 unsigned long long u = 0x8000000000000001ULL;
25502597 u = (unsigned)(u + 1);
25512598 printf("long long u=" ULONG_LONG_FORMAT "\n", u);
2599+ u = 0x11223344aa998877ULL;
2600+ u = (unsigned)(int)(u + 1);
2601+ printf("long long u=" ULONG_LONG_FORMAT "\n", u);
25522602
25532603 /* was a problem with missing save_regs in gen_opl on 32-bit platforms */
25542604 char cc = 78;
@@ -2897,10 +2947,6 @@ void c99_vla_test(int size1, int size2) · 342 unmodified lines
28972947 #endif
28982948 }
28992949
2900−#ifndef __TINYC__
2901−typedef __SIZE_TYPE__ uintptr_t;
2902−#endif
2903−
29042950 void sizeof_test(void)
29052951 {
29062952 int a;
tests/tests2/88_codeopt.c+1−1
@@ -1,7 +1,7 @@
11 /* Check some way in where code suppression caused various
22 miscompilations. */
33 extern int printf (const char *, ...);
4−typedef unsigned long size_t;
4+typedef __SIZE_TYPE__ size_t;
55
66 size_t _brk_start, _brk_end;
77 void * extend_brk(size_t size, size_t align)
tests/tests2/96_nodata_wanted.expect+1−1
@@ -9,7 +9,7 @@ · 8 unmodified lines
99
1010 [test_local_data_noerror]
1111 96_nodata_wanted.c:25: warning: assignment makes integer from pointer without a cast
12−96_nodata_wanted.c:25: warning: nonportable conversion from pointer to char/short
12+96_nodata_wanted.c:25: warning: cast between pointer and integer of different size
1313
1414 [test_data_suppression_off]
1515 data:

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