jsoninfo: add a function to directly convert an IP address
[olsrd.git] / gcc-warnings
1 #!/bin/sh
2 #
3 # We expect warning options for gcc as arguments and return the ones which are
4 # accepted by the given gcc.
5 #
6
7 set -ue
8 #set -vx
9
10 # make sure we do not use some locale ....
11 export LANG=C LC_ALL=C LC_COLLATE=C LC_CTYPE=C LC_MESSAGES=C LC_NUMERIC=C
12
13 OPTS=""
14 for param; do
15     case "$param" in
16     -[fWm]?*) OPTS="$OPTS $param";;
17     *)        echo "Ignoring $param" >&2
18     esac
19 done
20
21 testcompile() {
22     $CC $OPTS -x c -o /dev/null - 2>&1 <<- EOF
23        int main(void) {
24            return 0;
25        }
26 EOF
27 }
28
29 parsetest() {
30     while read error; do
31         case "$error" in
32         *:\ unrecognized\ *option\ \"*)
33             opt="${error#*\"}"
34             opt="${opt%\"*}"
35             ;;
36         *:\ unrecognized\ *option\ \‘*)
37             opt="${error#*\‘}"
38             opt="${opt%\‘*}"
39             ;;
40         *:\ unrecognized\ *option\ \'*)
41             opt="${error#*\'}"
42             opt="${opt%\'*}"
43             ;;
44         *:\ unrecognized\ *option\ \`*)
45             opt="${error#*\`}"
46             opt="${opt%\'*}"
47             ;;
48
49         # clang
50         *:\ unknown\ argument:\ \'*)
51             opt="${error#*\'}"
52             opt="${opt%\'*}"
53             ;;
54         *:\ unknown\ warning\ option\ \'*)
55             opt="${error#*\'}"
56             opt="${opt%\'*}"
57             ;;
58         *:\ optimization\ flag\ *\ is\ not\ supported)
59             opt="${error#*\'}"
60             opt="${opt%\'*}"
61             ;;
62
63         *)
64             continue
65             ;;
66        esac
67        # if we come here, we have in $opt the option to remove. and
68        # we remove all instances. And we save against leading "-"
69        NEW_OPTS=""
70        for o in $OPTS; do
71            case "$o" in
72                $opt) : echo "Removed $o" >&2;;
73                *)    NEW_OPTS="$NEW_OPTS $o";;
74            esac
75        done
76        OPTS="$NEW_OPTS"
77     done
78     echo $OPTS
79 }
80
81 testcompile | parsetest
82
83 exit 0