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
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)
21 TEST1((X),long long); \
24 #define TEST3(X,T) do { TEST2((T)(X)); TEST2((unsigned T)(X)); } while (0)
31 TEST3((X),long long); \
35 static int debug
, nfailed
= 0;
37 static void check (const char *s
, int arg1
, int shift
)
39 int failed
= arg1
!= shift
;
41 printf ("%s %d %d\n", s
, arg1
, shift
);
45 int main (int argc
, char **argv
)
50 printf ("%d test(s) failed\n", nfailed
);