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/gcc/doc"
22 echo "set \$CC to the compiler to be checked"
32 invoke_texi
=$gcc_docdir/invoke.texi
33 test -r "$invoke_texi" ||
{
34 echo "$progname: error: cannot read '$invoke_texi'" >&2
37 filebase
=check_warning_flags_file$$
38 stderr
=check_warning_flags_stderr$$
40 remove_problematic_flags
='
47 # Ensure that indexed warnings are accepted.
48 set x
`sed '/^@opindex W/{
50 '"$remove_problematic_flags"'
57 $CC -c $filebase.c
"$@" 2>&1 |
58 grep -v 'command line option.*is valid for.*but not for' >$stderr
59 if test -s $stderr; then
60 echo "options listed in @opindex but not accepted by the compiler:" >&2
64 rm -f $filebase.c
$stderr
66 # Check documentation of warning options.
67 for lang
in c c
++ objc obj-c
++; do
69 c
) ext
=c
; langmatch
='[^-]C[^+].*only' ;;
70 c
++) ext
=C
; langmatch
='[^-]C++.*only' ;;
71 objc
) ext
=m
; langmatch
='Objective-C[^+].*only' ;;
72 obj-c
++) ext
=M
; langmatch
='Objective-C++.*only' ;;
76 $CC -c $file 2>$stderr
77 if grep 'not installed on this system' $stderr >/dev
/null ||
78 grep 'installation problem, cannot exec' $stderr >/dev
/null ||
79 grep 'error trying to exec' $stderr >/dev
/null
81 echo "$progname: $CC is not configured for language $lang, skipping checks" >&2
82 rm -f $file $filebase.o
$filebase.obj
$stderr
86 # Verify good warning flags.
97 '"$remove_problematic_flags"'
102 $CC -c $file -O "$@" 2>$stderr
103 if test -s $stderr; then
109 # Verify bad warning flags.
120 '"$remove_problematic_flags"'
125 $CC -c $file -O "$@" 2>$stderr
127 test $# = `grep 'command line option.*valid.*but not for' <$stderr | wc -l` ||
{
130 grep "command line option.*$warning.*valid" <$stderr >&2 ||
131 echo "valid for $lang but not annotated as such: $warning"
135 rm -f $file $filebase.o
$filebase.obj
$stderr
139 remove_problematic_help_flags
='
142 /^Werror-implicit-function-declaration$/d
147 $CC --help -v 2>/dev/null | tr ' ' '\n' |
151 s/^-\(W[^<,]*\).*/\1/
155 '"$remove_problematic_help_flags"'
158 for flag
in $help_flags; do
159 $CC -c $filebase.c
-$flag 2>/dev
/null ||
{
160 echo "warning -$flag not supported" >&2
163 grep "@item.*$flag" $gcc_docdir/..
/*/*.texi
>/dev
/null ||
{
164 # For @item, we are satisfied with either -Wfoo or -Wno-foo.
165 inverted_flag
=`echo "$flag" | sed '
169 grep "@item.*$inverted_flag" $gcc_docdir/..
/*/*.texi
>/dev
/null ||
{
170 echo "warning -$flag not documented in $gcc_docdir/../*/*.texi" >&2
175 rm -f $filebase.c
$filebase.o