blob: b30a1d98732659bdcf08775ac0750954c96e2722 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#!/bin/sh
set -eu
src="${TMPDIR-/tmp}/mcpu-cpp-predef-redef-$$.c"
out="${TMPDIR-/tmp}/mcpu-cpp-predef-redef-$$.out"
err="${TMPDIR-/tmp}/mcpu-cpp-predef-redef-$$.err"
trap 'rm -f "$src" "$out" "$err"' EXIT HUP INT TERM
cat > "$src" <<'EOT'
before = __LINE__;
#define __LINE__ 77
after = __LINE__;
#undef __LINE__
literal = __LINE__;
"__FILE__ __LINE__ __MCPU_CPP_VERSION__"
EOT
"$MCPU_CPP" --no-config "$src" -o "$out" 2>"$err"
grep '^before = 1;$' "$out" >/dev/null
grep '^literal = __LINE__;$' "$out" >/dev/null
grep '^after = 77;$' "$out" >/dev/null
grep '^"__FILE__ __LINE__ __MCPU_CPP_VERSION__"$' "$out" >/dev/null
grep "warning: macro '__LINE__' redefined" "$err" >/dev/null
|