Fix float to long long conversion on ARM
[tinycc.git] / tests / tests2 / 55_lshift_type.c
blobaa3e51a1681a3bc132210cc6493d83fea7c6d73d
1 /* $Id: lshift-type.c 53089 2012-07-06 11:18:26Z vinc17/ypig $
3 Tests on left-shift type, written by Vincent Lefevre <vincent@vinc17.net>.
5 ISO C99 TC3 says: [6.5.7#3] "The integer promotions are performed on
6 each of the operands. The type of the result is that of the promoted
7 left operand."
8 */
10 #include <stdio.h>
12 #define PTYPE(M) ((M) < 0 || -(M) < 0 ? -1 : 1) * (int) sizeof((M)+0)
13 #define CHECK(X,T) check(#X, PTYPE(X), PTYPE((X) << (T) 1))
14 #define TEST1(X,T) do { CHECK(X,T); CHECK(X,unsigned T); } while (0)
15 #define TEST2(X) \
16 do \
17 { \
18 TEST1((X),short); \
19 TEST1((X),int); \
20 TEST1((X),long); \
21 TEST1((X),long long); \
22 } \
23 while (0)
24 #define TEST3(X,T) do { TEST2((T)(X)); TEST2((unsigned T)(X)); } while (0)
25 #define TEST4(X) \
26 do \
27 { \
28 TEST3((X),short); \
29 TEST3((X),int); \
30 TEST3((X),long); \
31 TEST3((X),long long); \
32 } \
33 while (0)
35 static int debug, nfailed = 0;
37 static void check (const char *s, int arg1, int shift)
39 int failed = arg1 != shift;
40 if (debug || failed)
41 printf ("%s %d %d\n", s, arg1, shift);
42 nfailed += failed;
45 int main (int argc, char **argv)
47 debug = argc > 1;
48 TEST4(1);
49 TEST4(-1);
50 printf ("%d test(s) failed\n", nfailed);
51 return nfailed != 0;