OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / contrib / warn_summary
1 #!/bin/sh
2 # This script parses the output of a gcc bootstrap when using warning
3 # flags and determines various statistics.
4 #
5 # By Kaveh Ghazi  (ghazi@caip.rutgers.edu)  12/13/97.
6
7 # This function displays all warnings from stageN of the bootstrap.
8 stageNwarns()
9 {
10   stageNminus1=`expr $stageN - 1`
11 # Some awks choke on long lines so grep them out.
12   grep -v libf2c.a $1 | \
13         $AWK "/ warning: /{if(t==1)print} ; /stage$stageNminus1/{if(t==0)t=1} ; /stage$stageN/{if(t==1)t=0}"
14 }
15
16 usage="usage: `basename $0` [-s stage] [file(s)]"
17 stageN=3
18
19 # Find a good awk.
20 if test -z "$AWK" ; then
21   for AWK in gawk nawk awk ; do
22     if type $AWK 2>&1 | grep 'not found' > /dev/null 2>&1 ; then
23       :
24     else
25       break
26     fi
27   done
28 fi
29
30 while test -n "$1" ; do
31  case "$1" in
32    -s)  if test -z "$2"; then echo $usage; exit 1; fi; stageN="$2"; shift 2 ;;
33    -s*) stageN="`expr $1 : '-s\(.*\)'`" ; shift ;;
34    -*)  echo $usage ; exit 1 ;;
35    *)   break ;;
36  esac
37 done
38
39
40
41 for file in "$@" ; do
42
43   count=`stageNwarns $file | wc -l`
44   echo There are $count warnings in stage$stageN of this bootstrap.
45
46   echo
47   echo Number of warnings per file:
48   stageNwarns $file | $AWK -F: '{print$1}' | sort | uniq -c | sort -nr
49
50   echo
51   echo Number of warning types:
52   stageNwarns $file | sed 's/.*warning: //; 
53                 s/`\(int\)'"'"'/"\1"/g;
54                 s/`\(char\)'"'"'/"\1"/g;
55                 s/`\(inline\)'"'"'/"\1"/g;
56                 s/`\(else\)'"'"'/"\1"/g;
57                 s/`\(return\)'"'"'/"\1"/g;
58                 s/`\(static\)'"'"'/"\1"/g;
59                 s/`\(extern\)'"'"'/"\1"/g;
60                 s/`\(longjmp\)'"'"' or `\(vfork\)'"'"'/"\1" or "\2"/g;
61                 s/`'"[^']*'/"'`???'"'/g;"'
62                 s/.*format, .* arg (arg [0-9]*)/??? format, ??? arg (arg ???)/;
63                 s/(arg [0-9]*)/(arg ???)/;
64                 s/"\([^"]*\)"/`\1'"'"'/g' | \
65         sort | uniq -c | sort -nr
66
67 done