3 # Check that the warning flags documented in invoke.texi match up
4 # with what the compiler accepts.
6 # Copyright (C) 2008 Free Software Foundation, Inc.
7 # Written by Ralf Wildenhues <Ralf.Wildenhues@gmx.de>.
9 # This script is Free Software, and it can be copied, distributed and
10 # modified as defined in the GNU General Public License. A copy of
11 # its license can be downloaded from http://www.gnu.org/copyleft/gpl.html
14 # check_warning_flags.sh path/to/invoke.texi
15 # with CC set to the compiler to be tested.
16 # The script scribbles in the current directory.
18 progname=`echo "$0" | sed 's,.*/,,'`
21 echo "usage: $progname path/to/invoke.texi"
22 echo "set \$CC to the compiler to be checked"
32 test -r "$invoke_texi" || {
33 echo "$progname: error: cannot read '$invoke_texi'" >&2
36 filebase=check_warning_flags_file$$
37 stderr=check_warning_flags_stderr$$
39 remove_problematic_flags='
46 # Ensure that indexed warnings are accepted.
47 set x `sed '/^@opindex W/{
49 '"$remove_problematic_flags"'
56 $CC -c $filebase.c "$@" 2>&1 |
57 grep -v 'command line option.*is valid for.*but not for' >$stderr
58 if test -s $stderr; then
59 echo "options listed in @opindex but not accepted by the compiler:" >&2
63 rm -f $filebase.c $stderr
65 # Check documentation of warning options.
66 for lang in c c++ objc obj-c++; do
68 c) ext=c; langmatch='[^-]C[^+].*only' ;;
69 c++) ext=C; langmatch='[^-]C++.*only' ;;
70 objc) ext=m; langmatch='Objective-C[^+].*only' ;;
71 obj-c++) ext=M; langmatch='Objective-C++.*only' ;;
75 $CC -c $file 2>$stderr
76 if grep 'not installed on this system' $stderr >/dev/null ||
77 grep 'installation problem, cannot exec' $stderr >/dev/null ||
78 grep 'error trying to exec' $stderr >/dev/null
80 echo "$progname: $CC is not configured for language $lang, skipping checks" >&2
81 rm -f $file $filebase.o $filebase.obj $stderr
85 # Verify good warning flags.
96 '"$remove_problematic_flags"'
101 $CC -c $file -O "$@" 2>$stderr
102 if test -s $stderr; then
108 # Verify bad warning flags.
119 '"$remove_problematic_flags"'
124 $CC -c $file -O "$@" 2>$stderr
126 test $# = `grep 'command line option.*valid.*but not for' <$stderr | wc -l` || {
129 grep "command line option.*$warning.*valid" <$stderr >&2 ||
130 echo "valid for $lang but not annotated as such: $warning"
134 rm -f $file $filebase.o $filebase.obj $stderr