OSDN Git Service

* c-decl.c (c_expand_body): Check TYPE_SIZE_UNIT (ret_type)
[pf3gnuchains/gcc-fork.git] / gcc / gccbug.in
1 #!/bin/sh
2 # Submit a problem report to a GNATS site.
3 # Copyright (C) 1993, 2000, 2001 Free Software Foundation, Inc.
4 # Contributed by Brendan Kehoe (brendan@cygnus.com), based on a
5 # version written by Heinz G. Seidl (hgs@cygnus.com).
6 #
7 # This file is part of GNU GNATS.
8 #
9 # GNU GNATS is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
12 # any later version.
13 #
14 # GNU GNATS is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with GNU GNATS; see the file COPYING.  If not, write to
21 # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 # The version of this send-pr.
24 VERSION=3.113
25
26 # The submitter-id for your site.
27 SUBMITTER=net
28
29 # The default mail address for PR submissions. 
30 GNATS_ADDR=gcc-gnats@gcc.gnu.org
31
32 # The default release for this host.
33 DEFAULT_RELEASE="@gcc_version_full@"
34
35 # The default organization.
36 DEFAULT_ORGANIZATION=
37
38 # What mailer to use.  This must come after the config file, since it is
39 # host-dependent.
40 # Copied from cvsbug
41 if [ -f /usr/sbin/sendmail ]; then  
42     MAIL_AGENT="/usr/sbin/sendmail -oi -t"
43 else  
44     MAIL_AGENT="/usr/lib/sendmail -oi -t"
45 fi
46 MAILER=`echo $MAIL_AGENT | sed -e 's, .*,,'`
47 if [ ! -f "$MAILER" ] ; then
48     echo "$COMMAND: Cannot file mail program \"$MAILER\"."
49     echo "$COMMAND: Please fix the MAIL_AGENT entry in the $COMMAND file."
50     exit 1
51 fi
52
53
54 # How to read the passwd database.
55 PASSWD="cat /etc/passwd"
56
57 ECHON=bsd
58
59 if [ $ECHON = bsd ] ; then
60   ECHON1="echo -n"
61   ECHON2=
62 elif [ $ECHON = sysv ] ; then
63   ECHON1=echo
64   ECHON2='\c'
65 else
66   ECHON1=echo
67   ECHON2=
68 fi
69
70 #\f
71
72 if [ -z "$TMPDIR" ]; then
73   TMPDIR=/tmp
74 else
75   if [ "`echo $TMPDIR | grep '/$'`" != "" ]; then
76     TMPDIR="`echo $TMPDIR | sed -e 's,/$,,'`"
77   fi
78 fi
79
80 if [ @have_mktemp_command@ = yes ]; then
81         TEMP0=`mktemp $TMPDIR/poXXXXXX` || exit 1
82         TEMP=`mktemp $TMPDIR/pXXXXXX` || exit 1
83         BAD=`mktemp $TMPDIR/pbadXXXXXX` || exit 1
84         REF=`mktemp $TMPDIR/pfXXXXXX` || exit 1
85 else
86         TEMP0=$TMPDIR/po$$
87         TEMP=$TMPDIR/p$$
88         BAD=$TMPDIR/pbad$$
89         REF=$TMPDIR/pf$$
90         # set -C _may_ use O_EXCL, but it need not.
91         set -C
92         bad_temp=0
93         : > $TEMP0 || bad_temp=1
94         : > $TEMP || bad_temp=1
95         : > $BAD || bad_temp=1
96         : > $REF || bad_temp=1
97         if [ $bad_temp = 1 ]; then
98                 rm -f $TEMP0 $TEMP $BAD $REF
99                 exit 1;
100         fi
101         set +C
102 fi
103 REMOVE_TEMP="rm -f $TEMP0 $TEMP $BAD $REF"
104
105 # find a user name
106 if [ "$LOGNAME" = "" ]; then
107         if [ "$USER" != "" ]; then
108                 LOGNAME="$USER"
109         else
110                 LOGNAME="UNKNOWN"
111         fi
112 fi
113
114 FROM="$LOGNAME"
115 REPLY_TO="${REPLY_TO:-${REPLYTO:-$LOGNAME}}"
116
117 # Find out the name of the originator of this PR.
118 if [ -n "$NAME" ]; then
119   ORIGINATOR="$NAME"
120 elif [ -f $HOME/.fullname ]; then
121   ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
122 else
123   # Must use temp file due to incompatibilities in quoting behavior
124   # and to protect shell metacharacters in the expansion of $LOGNAME
125   $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP0
126   ORIGINATOR="`cat $TEMP0`"
127   rm -f $TEMP0
128 fi
129
130 if [ -n "$ORGANIZATION" ]; then
131   if [ -f "$ORGANIZATION" ]; then
132     ORGANIZATION="`cat $ORGANIZATION`"
133   fi
134 else
135   if [ -n "$DEFAULT_ORGANIZATION" ]; then
136     ORGANIZATION="$DEFAULT_ORGANIZATION"
137   elif [ -f $HOME/.organization ]; then
138     ORGANIZATION="`cat $HOME/.organization`"
139   fi
140 fi
141
142 # If they don't have a preferred editor set, then use
143 if [ -z "$VISUAL" ]; then
144   if [ -z "$EDITOR" ]; then
145     EDIT=vi
146   else
147     EDIT="$EDITOR"
148   fi
149 else
150   EDIT="$VISUAL"
151 fi
152
153 # Find out some information.
154 SYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \
155         ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
156 ARCH=`[ -f /bin/arch ] && /bin/arch`
157 MACHINE=`[ -f /bin/machine ] && /bin/machine`
158
159 COMMAND=`echo $0 | sed -e 's,.*/,,'`
160 USAGE="Usage: $COMMAND [-PVL] [-t address] [-f filename] [-s severity]
161        [-c address] [--request-id] [--version]"
162 REMOVE=
163 BATCH=
164 CC=
165 SEVERITY_C=
166
167 while [ $# -gt 0 ]; do
168   case "$1" in
169     -r) ;;              # Ignore for backward compat.
170     -t | --to) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
171         shift ; GNATS_ADDR="$1"
172         EXPLICIT_GNATS_ADDR=true
173         ;;
174     -f | --file) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
175         shift ; IN_FILE="$1"
176         if [ "$IN_FILE" != "-" -a ! -r "$IN_FILE" ]; then
177           echo "$COMMAND: cannot read $IN_FILE"
178           $REMOVE_TEMP
179           exit 1
180         fi
181         ;;
182     -b | --batch) BATCH=true ;;
183     -c | --cc) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
184         shift ; CC="$1"
185         ;;
186     -s | --severity) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
187         shift ; SEVERITY_C="$1"
188         ;;
189     -p | -P | --print) PRINT=true ;;
190     -L | --list) FORMAT=norm ;;
191     -l | -CL | --lisp) FORMAT=lisp ;;
192     --request-id) REQUEST_ID=true ;;
193     -h | --help) echo "$USAGE"; $REMOVE_TEMP; exit 0 ;;
194     -V | --version) echo "$VERSION"; $REMOVE_TEMP; exit 0 ;;
195     -*) echo "$USAGE" ; $REMOVE_TEMP; exit 1 ;;
196     *) echo "$USAGE" ; $REMOVE_TEMP; exit 1
197  esac
198  shift
199 done
200
201 # spam does not need to be listed here
202 CATEGORIES="c++ c debug fortran java libf2c libgcj libobjc libstdc++ middle-end objc optimization other preprocessor target web"
203
204 case "$FORMAT" in
205   lisp) echo "$CATEGORIES" | \
206         awk 'BEGIN {printf "( "} {printf "(\"%s\") ",$0} END {printf ")\n"}'
207         $REMOVE_TEMP
208         exit 0
209         ;;
210   norm) l=`echo "$CATEGORIES" | \
211         awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
212              END {print max + 1;}'`
213         c=`expr 70 / $l`
214         if [ $c -eq 0 ]; then c=1; fi
215         echo "$CATEGORIES" | \
216         awk 'BEGIN {print "Known categories:"; i = 0 }
217           { printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { print "" } }
218             END { print ""; }'
219         $REMOVE_TEMP
220         exit 0
221         ;;
222 esac
223
224 ORIGINATOR_C='<name of the PR author (one line)>'
225 ORGANIZATION_C='<organization of PR author (multiple lines)>'
226 SYNOPSIS_C='<synopsis of the problem (one line)>'
227 if [ -z "$SEVERITY_C" ]; then
228   SEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
229 fi
230 PRIORITY_C='<[ low | medium | high ] (one line)>'
231 CATEGORY_C='<choose from the top of this file (one line)>'
232 RELEASE_C='<release number or tag (one line)>'
233 ENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>'
234 DESCRIPTION_C='<precise description of the problem (multiple lines)>'
235 HOW_TO_REPEAT_C='<When reporting a compiler error, preprocessor output must be included>'
236 FIX_C='<how to correct or work around the problem, if known (multiple lines)>'
237
238 # Catch some signals. ($xs kludge needed by Sun /bin/sh)
239 xs=0
240 trap '$REMOVE_TEMP; exit $xs' 0
241 trap 'echo "$COMMAND: Aborting ..."; $REMOVE_TEMP; xs=1; exit' 1 3 13 15
242
243 # If they told us to use a specific file, then do so.
244 if [ -n "$IN_FILE" ]; then
245   if [ "$IN_FILE" = "-" ]; then
246     # The PR is coming from the standard input.
247     if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
248       sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" > $TEMP
249     else
250       cat > $TEMP
251     fi
252   else
253     # Use the file they named.
254     if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
255       sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" $IN_FILE > $TEMP
256     else
257       cat $IN_FILE > $TEMP
258     fi
259   fi
260 else
261
262   if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
263     # If their PR_FORM points to a bogus entry, then bail.
264     if [ ! -f "$PR_FORM" -o ! -r "$PR_FORM" -o ! -s "$PR_FORM" ]; then
265       echo "$COMMAND: can't seem to read your template file (\`$PR_FORM'), ignoring PR_FORM"
266       sleep 1
267       PRINT_INTERN=bad_prform
268     fi
269   fi
270
271   if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
272     cp $PR_FORM $TEMP || 
273       ( echo "$COMMAND: could not copy $PR_FORM" ; xs=1; exit )
274   else
275     for file in $TEMP $REF ; do
276       cat  > $file << '__EOF__'
277 SEND-PR: -*- send-pr -*-
278 SEND-PR: Lines starting with `SEND-PR' will be removed automatically, as
279 SEND-PR: will all comments (text enclosed in `<' and `>').
280 SEND-PR: 
281 SEND-PR: Please consult the GCC manual if you are not sure how to
282 SEND-PR: fill out a problem report.
283 SEND-PR: Note that the Synopsis field is mandatory.  The Subject (for
284 SEND-PR: the mail) will be made the same as Synopsis unless explicitly
285 SEND-PR: changed.
286 SEND-PR:
287 SEND-PR: Choose from the following categories:
288 SEND-PR:
289 __EOF__
290
291       # Format the categories so they fit onto lines.
292         l=`echo "$CATEGORIES" | \
293         awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
294              END {print max + 1;}'`
295         c=`expr 61 / $l`
296         if [ $c -eq 0 ]; then c=1; fi
297         echo "$CATEGORIES" | \
298         awk 'BEGIN {printf "SEND-PR: "; i = 0 }
299           { printf ("%-'$l'.'$l's", $0);
300             if ((++i % '$c') == 0) { printf "\nSEND-PR: " } }
301             END { printf "\nSEND-PR:\n"; }' >> $file
302
303       cat >> $file << __EOF__
304 To: $GNATS_ADDR
305 Subject: 
306 From: $FROM
307 Reply-To: $REPLYTO
308 Cc: $CC
309 X-send-pr-version: $VERSION
310 X-GNATS-Notify: 
311
312
313 >Submitter-Id:  $SUBMITTER
314 >Originator:    $ORIGINATOR
315 >Organization:  ${ORGANIZATION-$ORGANIZATION_C}
316 >Confidential:  no
317 SEND-PR: Leave "Confidential" as "no"; all GCC PRs are public.
318 >Synopsis:      $SYNOPSIS_C
319 >Severity:      $SEVERITY_C
320 SEND-PR: critical     GCC is completely not operational; no work-around known.
321 SEND-PR: serious      GCC is not working properly; a work-around is possible.
322 SEND-PR: non-critical Report indicates minor problem.
323 >Priority:      $PRIORITY_C
324 SEND-PR: high         A solution is necessary as soon as possible.
325 SEND-PR: medium       The problem should be solved in the next release.
326 SEND-PR: low          The problem should be solve in a future release.
327 >Category:      $CATEGORY_C
328 >Class:         <[ doc-bug | accepts-illegal | rejects-legal | wrong-code | ice-on-legal-code| ice-on-illegal-code | pessimizes-code | sw-bug | change-request | support ] (one line)>
329 SEND-PR: doc-bug          The doumentation is incorrect.
330 SEND-PR: accepts-illegal  GCC fails to reject erroneous code.
331 SEND-PR: rejects-legal    GCC gives an error message for correct code.
332 SEND-PR: wrong-code       The machine code generated by gcc is incorrect.
333 SEND-PR: ice-on-legal-code   GCC gives an Internal Compiler Error (ICE)
334 SEND-PR:                     for correct code
335 SEND-PR: ice-on-illegal-code GCC gives an ICE instead of reporting an error
336 SEND-PR: pessimizes-code     GCC misses an important optimization opportunity
337 SEND-PR: sw-bug              Software bug of some other class than above
338 SEND-PR: change-request      A feature in GCC is missing.
339 SEND-PR: support             I need help with gcc.
340 >Release:       ${DEFAULT_RELEASE-$RELEASE_C}
341 >Environment:
342 `[ -n "$SYSTEM" ] && echo System: $SYSTEM`
343 `[ -n "$ARCH" ] && echo Architecture: $ARCH`
344 `[ -n "$MACHINE" ] && echo Machine: $MACHINE`
345         $ENVIRONMENT_C
346 host: @host@
347 build: @build@
348 target: @target@
349 configured with: @gcc_config_arguments@
350 >Description:
351         $DESCRIPTION_C
352 >How-To-Repeat:
353         $HOW_TO_REPEAT_C
354 >Fix:
355         $FIX_C
356 __EOF__
357     done
358   fi
359
360   if [ "$PRINT" = true -o "$PRINT_INTERN" = true ]; then
361     cat $TEMP
362     xs=0; exit
363   fi
364
365   chmod u+w $TEMP
366   if [ -z "$REQUEST_ID" ]; then
367     eval $EDIT $TEMP
368   else
369     ed -s $TEMP << '__EOF__'
370 /^Subject/s/^Subject:.*/Subject: request for a customer id/
371 /^>Category/s/^>Category:.*/>Category: send-pr/
372 w
373 q
374 __EOF__
375   fi
376
377   if cmp -s $REF $TEMP ; then
378     echo "$COMMAND: problem report not filled out, therefore not sent"
379     xs=1; exit
380   fi
381 fi
382
383 #\f
384 #       Check the enumeration fields
385
386 # This is a "sed-subroutine" with one keyword parameter 
387 # (with workaround for Sun sed bug)
388 #
389 SED_CMD='
390 /$PATTERN/{
391 s|||
392 s|<.*>||
393 s|^[    ]*||
394 s|[     ]*$||
395 p
396 q
397 }'
398
399
400 while [ -z "$REQUEST_ID" ]; do
401   CNT=0
402
403   # 1) Confidential
404   #
405   PATTERN=">Confidential:"
406   CONFIDENTIAL=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
407   case "$CONFIDENTIAL" in
408     no) CNT=`expr $CNT + 1` ;;
409     *) echo "$COMMAND: \`$CONFIDENTIAL' is not a valid value for \`Confidential'." ;;
410   esac
411   #
412   # 2) Severity
413   #
414   PATTERN=">Severity:"
415   SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
416   case "$SEVERITY" in
417     ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
418     *)  echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
419   esac
420   #
421   # 3) Priority
422   #
423   PATTERN=">Priority:"
424   PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
425   case "$PRIORITY" in
426     ""|low|medium|high) CNT=`expr $CNT + 1` ;;
427     *)  echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
428   esac
429   #
430   # 4) Category
431   #
432   PATTERN=">Category:"
433   CATEGORY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
434   FOUND=
435   for C in $CATEGORIES
436   do
437     if [ "$C" = "$CATEGORY" ]; then FOUND=true ; break ; fi
438   done
439   if [ -n "$FOUND" ]; then
440     CNT=`expr $CNT + 1` 
441   else
442     if [ -z "$CATEGORY" ]; then
443       echo "$COMMAND: you must include a Category: field in your report."
444     else
445       echo "$COMMAND: \`$CATEGORY' is not a known category."
446     fi
447   fi
448   #
449   # 5) Class
450   #
451   PATTERN=">Class:"
452   CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
453   case "$CLASS" in
454     ""|doc-bug|accepts-illegal|rejects-legal|wrong-code|ice-on-legal-code|ice-on-illegal-code|pessimizes-code|sw-bug|change-request|support) CNT=`expr $CNT + 1` ;;
455     *)  echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
456   esac
457   #
458   # 6) Check that synopsis is not empty
459   #
460   if grep "^>Synopsis:[         ]*${SYNOPSIS_C}\$" $TEMP > /dev/null
461   then
462     echo "$COMMAND: Synopsis must not be empty."
463   else
464     CNT=`expr $CNT + 1`
465   fi
466
467   [ $CNT -lt 6 -a -z "$BATCH" ] && 
468     echo "Errors were found with the problem report."
469
470   while true; do
471     if [ -z "$BATCH" ]; then
472       $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
473       read input
474     else
475       if [ $CNT -eq 6 ]; then
476         input=s
477       else
478         input=a
479       fi
480     fi
481     case "$input" in
482       a*)
483         if [ -z "$BATCH" ]; then
484           echo "$COMMAND: the problem report remains in $BAD and is not sent."
485           REMOVE_TEMP="rm -f $TEMP0 $TEMP $REF"
486           mv $TEMP $BAD
487         else
488           echo "$COMMAND: the problem report is not sent."
489         fi
490         xs=1; exit
491         ;;
492       e*)
493         eval $EDIT $TEMP
494         continue 2
495         ;;
496       s*)
497         break 2
498         ;;
499     esac
500   done
501 done
502
503 #
504 # Make sure the mail has got a Subject.  If not, use the same as
505 # in Synopsis.
506 #
507
508 if grep '^Subject:[     ]*$' $TEMP > /dev/null
509 then
510   SYNOPSIS=`grep '^>Synopsis:' $TEMP | sed -e 's/^>Synopsis:[   ]*//'`
511   ed -s $TEMP << __EOF__
512 /^Subject:/s/:.*\$/: $SYNOPSIS/
513 w
514 q
515 __EOF__
516 fi
517
518 #
519 #       Remove comments and send the problem report
520 #       (we have to use patterns, where the comment contains regex chars)
521 #
522 # /^>Originator:/s;$ORIGINATOR;;
523 sed  -e "
524 /^SEND-PR:/d
525 /^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
526 /^>Confidential:/s;<.*>;;
527 /^>Synopsis:/s;$SYNOPSIS_C;;
528 /^>Severity:/s;<.*>;;
529 /^>Priority:/s;<.*>;;
530 /^>Category:/s;$CATEGORY_C;;
531 /^>Class:/s;<.*>;;
532 /^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
533 /^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
534 /^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
535 /^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
536 /^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
537 " $TEMP > $REF
538
539 if $MAIL_AGENT < $REF; then
540   echo "$COMMAND: problem report sent"
541   xs=0; exit
542 else
543   echo "$COMMAND: mysterious mail failure."
544   if [ -z "$BATCH" ]; then
545     echo "$COMMAND: the problem report remains in $BAD and is not sent."
546     REMOVE_TEMP="rm -f $TEMP0 $TEMP $REF"
547     mv $REF $BAD
548   else
549     echo "$COMMAND: the problem report is not sent."
550   fi
551   xs=1; exit
552 fi