blob: d95c6295e640b5929d5390d365c3cdc828fdbad1 (
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
72
73
74
75
76
77
78
79
|
#!/bin/sh
set -eu
base="${TMPDIR-/tmp}/mcpu-cpp-zubr-expression-$$"
mkdir -p "$base"
trap 'rm -rf "$base"' EXIT HUP INT TERM
cat > "$base/main.c" <<'EOT'
#if 0b1010 == 10 && 077 == 63 && 0x2a == 42
radix_ok
#else
bad_radix
#endif
#if 9223372036854775807 == 0x7fffffffffffffff
int64_ok
#else
bad_int64
#endif
#if 0xffffffffffffffffU > 9223372036854775807
uint64_ok
#else
bad_uint64
#endif
#if 'A' == 65 && 'Я' == 0x42f && '\x42f' == 0x42f && '\101' == 65
ucs2_char_ok
#else
bad_ucs2_char
#endif
#if -1 < 0 && (8 << -1) == 4 && (4 >> -1) == 8
signed_shift_ok
#else
bad_signed_shift
#endif
#if 0 && (1 / 0)
bad_short_and
#endif
#if 1 || (1 / 0)
short_or_ok
#endif
#if 1 ? 7 : 1 / 0
ternary_ok
#endif
EOT
"$MCPU_CPP" --no-config "$base/main.c" -o "$base/out"
for word in \
radix_ok int64_ok uint64_ok ucs2_char_ok signed_shift_ok short_or_ok ternary_ok; do
test "`grep -c "^${word}$" "$base/out"`" -eq 1
done
for word in \
bad_radix bad_int64 bad_uint64 bad_ucs2_char bad_signed_shift bad_short_and; do
if grep "^${word}$" "$base/out" >/dev/null; then exit 1; fi
done
cat > "$base/bad-float.c" <<'EOT'
#if 1.0
bad
#endif
EOT
if "$MCPU_CPP" --no-config "$base/bad-float.c" -o "$base/bad-out" 2>/dev/null; then
exit 1
fi
cat > "$base/bad-inc.c" <<'EOT'
#if 1++2
bad
#endif
EOT
if "$MCPU_CPP" --no-config "$base/bad-inc.c" -o "$base/bad-out" 2>/dev/null; then
exit 1
fi
|