3 # Check that the warning flags documented in invoke.texi match up
4 # with what the compiler accepts.
6 # Copyright (C) 2008, 2009, 2010 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
='
42 /-Wframe-larger-than/d
43 /-Wdisallowed-function-list/d
50 # Ensure that indexed warnings are accepted.
51 set x
`sed '/^@opindex W/{
53 '"$remove_problematic_flags"'
60 $CC -c $filebase.c
"$@" 2>&1 |
61 grep -v 'command line option.*is valid for.*but not for' >$stderr
62 if test -s $stderr; then
63 echo "options listed in @opindex but not accepted by the compiler:" >&2
67 rm -f $filebase.c
$stderr
69 # Check documentation of warning options.
70 for lang
in c c
++ objc obj-c
++; do
72 c
) ext
=c
; langmatch
='[^-]C[^+].*only' ;;
73 c
++) ext
=C
; langmatch
='[^-]C++.*only' ;;
74 objc
) ext
=m
; langmatch
='Objective-C[^+].*only' ;;
75 obj-c
++) ext
=M
; langmatch
='Objective-C++.*only' ;;
79 $CC -c $file 2>$stderr
80 if grep 'not installed on this system' $stderr >/dev
/null ||
81 grep 'installation problem, cannot exec' $stderr >/dev
/null ||
82 grep 'error trying to exec' $stderr >/dev
/null
84 echo "$progname: $CC is not configured for language $lang, skipping checks" >&2
85 rm -f $file $filebase.o
$filebase.obj
$stderr
89 # Verify good warning flags.
100 '"$remove_problematic_flags"'
105 $CC -c $file -O "$@" 2>$stderr
106 if test -s $stderr; then
112 # Verify bad warning flags.
123 '"$remove_problematic_flags"'
128 $CC -c $file -O "$@" 2>$stderr
130 test $# = `grep 'command line option.*valid.*but not for' <$stderr | wc -l` ||
{
133 grep "command line option.*$warning.*valid" <$stderr >&2 ||
134 echo "valid for $lang but not annotated as such: $warning"
138 rm -f $file $filebase.o
$filebase.obj
$stderr
142 remove_problematic_help_flags
='
145 /^Werror-implicit-function-declaration$/d
150 $CC --help -v 2>/dev/null | tr ' ' '\012' |
154 s/^-\(W[^<,]*\).*/\1/
158 '"$remove_problematic_help_flags"'
161 for flag
in $help_flags; do
162 $CC -c $filebase.c
-$flag 2>/dev
/null ||
{
163 echo "warning -$flag not supported" >&2
166 grep "@item.*$flag" $gcc_docdir/..
/*/*.texi
>/dev
/null ||
{
167 # For @item, we are satisfied with either -Wfoo or -Wno-foo.
168 inverted_flag
=`echo "$flag" | sed '
172 grep "@item.*$inverted_flag" $gcc_docdir/..
/*/*.texi
>/dev
/null ||
{
173 echo "warning -$flag not documented in $gcc_docdir/../*/*.texi" >&2
178 rm -f $filebase.c
$filebase.o