1 |
689 |
jeremybenn |
/* Test for integer promotion rules: extended to long long by C99. */
|
2 |
|
|
/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
|
3 |
|
|
/* { dg-do compile } */
|
4 |
|
|
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
|
5 |
|
|
|
6 |
|
|
#include <limits.h>
|
7 |
|
|
|
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)
|
17 |
|
|
|
18 |
|
|
void
|
19 |
|
|
f (void)
|
20 |
|
|
{
|
21 |
|
|
/* Same type. */
|
22 |
|
|
CHECK(int, int, int);
|
23 |
|
|
CHECK(unsigned int, unsigned int, unsigned int);
|
24 |
|
|
CHECK(long, long, long);
|
25 |
|
|
CHECK(unsigned long, unsigned long, unsigned long);
|
26 |
|
|
CHECK(long long, long long, long long);
|
27 |
|
|
CHECK(unsigned long long, unsigned long long, unsigned long long);
|
28 |
|
|
/* Both signed. */
|
29 |
|
|
CHECK(int, long, long);
|
30 |
|
|
CHECK(int, long long, long long);
|
31 |
|
|
CHECK(long, int, long);
|
32 |
|
|
CHECK(long, long long, long long);
|
33 |
|
|
CHECK(long long, int, long long);
|
34 |
|
|
CHECK(long long, long, long long);
|
35 |
|
|
/* Both unsigned. */
|
36 |
|
|
CHECK(unsigned int, unsigned long, unsigned long);
|
37 |
|
|
CHECK(unsigned int, unsigned long long, unsigned long long);
|
38 |
|
|
CHECK(unsigned long, unsigned int, unsigned long);
|
39 |
|
|
CHECK(unsigned long, unsigned long long, unsigned long long);
|
40 |
|
|
CHECK(unsigned long long, unsigned int, unsigned long long);
|
41 |
|
|
CHECK(unsigned long long, unsigned long, unsigned long long);
|
42 |
|
|
/* Unsigned of greater or equal rank. */
|
43 |
|
|
CHECK(int, unsigned int, unsigned int);
|
44 |
|
|
CHECK(int, unsigned long, unsigned long);
|
45 |
|
|
CHECK(int, unsigned long long, unsigned long long);
|
46 |
|
|
CHECK(unsigned int, int, unsigned int);
|
47 |
|
|
CHECK(long, unsigned long, unsigned long);
|
48 |
|
|
CHECK(long, unsigned long long, unsigned long long);
|
49 |
|
|
CHECK(unsigned long, int, unsigned long);
|
50 |
|
|
CHECK(unsigned long, long, unsigned long);
|
51 |
|
|
CHECK(long long, unsigned long long, unsigned long long);
|
52 |
|
|
CHECK(unsigned long long, int, unsigned long long);
|
53 |
|
|
CHECK(unsigned long long, long, unsigned long long);
|
54 |
|
|
CHECK(unsigned long long, long long, unsigned long long);
|
55 |
|
|
/* Signed of greater rank. */
|
56 |
|
|
#if LONG_MAX >= UINT_MAX
|
57 |
|
|
CHECK(unsigned int, long, long);
|
58 |
|
|
CHECK(long, unsigned int, long);
|
59 |
|
|
#else
|
60 |
|
|
CHECK(unsigned int, long, unsigned long);
|
61 |
|
|
CHECK(long, unsigned int, unsigned long);
|
62 |
|
|
#endif
|
63 |
|
|
#if LLONG_MAX >= UINT_MAX
|
64 |
|
|
CHECK(unsigned int, long long, long long);
|
65 |
|
|
CHECK(long long, unsigned int, long long);
|
66 |
|
|
#else
|
67 |
|
|
CHECK(unsigned int, long long, unsigned long long);
|
68 |
|
|
CHECK(long long, unsigned int, unsigned long long);
|
69 |
|
|
#endif
|
70 |
|
|
#if LLONG_MAX >= ULONG_MAX
|
71 |
|
|
CHECK(unsigned long, long long, long long);
|
72 |
|
|
CHECK(long long, unsigned long, long long);
|
73 |
|
|
#else
|
74 |
|
|
CHECK(unsigned long, long long, unsigned long long);
|
75 |
|
|
CHECK(long long, unsigned long, unsigned long long);
|
76 |
|
|
#endif
|
77 |
|
|
}
|