summaryrefslogtreecommitdiff
path: root/05/tcc-0.9.27/tests/tests2/93_integer_promotion.c
blob: a1176fc6bdcd719c99fddf7253e2c85ee7904091 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* integer promotion */

int printf(const char*, ...);
#define promote(s) printf(" %ssigned : %s\n", (s) - 100 < 0 ? "  " : "un", #s);

int main (void)
{
    struct {
        unsigned ub:3;
        unsigned u:32;
        unsigned long long ullb:35;
        unsigned long long ull:64;
        unsigned char c;
    } s = { 1, 1, 1 };

    promote(s.ub);
    promote(s.u);
    promote(s.ullb);
    promote(s.ull);
    promote(s.c);
    printf("\n");

    promote((1 ? s.ub : 1));
    promote((1 ? s.u : 1));
    promote((1 ? s.ullb : 1));
    promote((1 ? s.ull : 1));
    promote((1 ? s.c : 1));
    printf("\n");

    promote(s.ub << 1);
    promote(s.u << 1);
    promote(s.ullb << 1);
    promote(s.ull << 1);
    promote(s.c << 1);
    printf("\n");

    promote(+s.ub);
    promote(+s.u);
    promote(+s.ullb);
    promote(+s.ull);
    promote(+s.c);
    printf("\n");

    promote(-s.ub);
    promote(-s.u);
    promote(-s.ullb);
    promote(-s.ull);
    promote(-s.c);
    printf("\n");

    promote(~s.ub);
    promote(~s.u);
    promote(~s.ullb);
    promote(~s.ull);
    promote(~s.c);
    printf("\n");

    promote(!s.ub);
    promote(!s.u);
    promote(!s.ullb);
    promote(!s.ull);
    promote(!s.c);
    printf("\n");

    promote(+(unsigned)s.ub);
    promote(-(unsigned)s.ub);
    promote(~(unsigned)s.ub);
    promote(!(unsigned)s.ub);

    return 0;
}