| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# This file is in the public domain. |
| 4 |
# https://github.com/kmcallister/autoharden/blob/c5c7842f39c2f8d19836bb5427d6479db4436d62/LICENSE |
| 5 |
# |
| 6 |
# From kmcallister: |
| 7 |
# https://github.com/kmcallister/autoharden/blob/efaf5a16612589808c276a11536ea9a47071f74b/scripts/wrap-compiler-for-flag-check |
| 8 |
|
| 9 |
# Prior to clang v5.1, there was no way to make |
| 10 |
# clang's "argument unused" warning fatal. This |
| 11 |
# wrapper script that greps for this warning message. Newer clang's have no issues. |
| 12 |
# |
| 13 |
# Ideally the search string would also include 'clang: ' but this output might |
| 14 |
# depend on clang's argv[0]. |
| 15 |
# |
| 16 |
set -o errexit |
| 17 |
set -o nounset |
| 18 |
|
| 19 |
if out=`"$@" 2>&1`; then |
| 20 |
echo "$out" |
| 21 |
if echo "$out" | grep 'warning: argument unused' >/dev/null; then |
| 22 |
echo "$0: found clang warning" |
| 23 |
exit 1 |
| 24 |
else |
| 25 |
exit 0 |
| 26 |
fi |
| 27 |
else |
| 28 |
code=$? |
| 29 |
echo "$out" |
| 30 |
exit $code |
| 31 |
fi |