PR middle-end/27945
[official-gcc.git] / gcc / testsuite / gcc.dg / c90-intprom-1.c
blob78e4b39ef356dac8ad7f432b3b0a87195cc3f5e8
1 /* Test for integer promotion rules: C90 subset of types. */
2 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */
3 /* { dg-do compile } */
4 /* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
6 #include <limits.h>
8 #define CHECK(T1, T2, TC) \
9 do { \
10 T1 a = 0; \
11 T2 b = 0; \
12 TC *c = 0; \
13 __typeof__(a+b) *d = 0; \
14 c = d; \
15 d = c; \
16 } while (0)
18 void
19 f (void)
21 /* One type is unsigned long. */
22 CHECK(unsigned long, unsigned long, unsigned long);
23 CHECK(unsigned int, unsigned long, unsigned long);
24 CHECK(unsigned long, unsigned int, unsigned long);
25 CHECK(int, unsigned long, unsigned long);
26 CHECK(long, unsigned long, unsigned long);
27 CHECK(unsigned long, int, unsigned long);
28 CHECK(unsigned long, long, unsigned long);
29 /* long and unsigned int. */
30 #if LONG_MAX >= UINT_MAX
31 CHECK(unsigned int, long, long);
32 CHECK(long, unsigned int, long);
33 #else
34 CHECK(unsigned int, long, unsigned long);
35 CHECK(long, unsigned int, unsigned long);
36 #endif
37 /* One type is long. */
38 CHECK(long, long, long);
39 CHECK(int, long, long);
40 CHECK(long, int, long);
41 /* One type is unsigned int. */
42 CHECK(unsigned int, unsigned int, unsigned int);
43 CHECK(int, unsigned int, unsigned int);
44 CHECK(unsigned int, int, unsigned int);
45 /* Otherwise int. */
46 CHECK(int, int, int);