* calls.c (calls_function_1, case CONSTRUCTOR): New case.
[official-gcc.git] / gcc / gccbug.in
blob28463bdd49740a4252d347c881c5c42ee53b5244
1 #!/bin/sh
2 # Submit a problem report to a GNATS site.
3 # Copyright (C) 1993, 2000 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).
7 # This file is part of GNU GNATS.
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.
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.
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.
23 # The version of this send-pr.
24 VERSION=3.113
26 # The submitter-id for your site.
27 SUBMITTER=net
29 # The default mail address for PR submissions.
30 GNATS_ADDR=gcc-gnats@gcc.gnu.org
32 # The default release for this host.
33 DEFAULT_RELEASE="@gcc_version_full@"
35 # The default organization.
36 DEFAULT_ORGANIZATION=
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"
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
54 # How to read the passwd database.
55 PASSWD="cat /etc/passwd"
57 ECHON=bsd
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=
70 #\f
72 if [ -z "$TMPDIR" ]; then
73 TMPDIR=/tmp
74 else
75 if [ "`echo $TMPDIR | grep '/$'`" != "" ]; then
76 TMPDIR="`echo $TMPDIR | sed -e 's,/$,,'`"
80 TEMP=$TMPDIR/p$$
81 BAD=$TMPDIR/pbad$$
82 REF=$TMPDIR/pf$$
84 # find a user name
85 if [ "$LOGNAME" = "" ]; then
86 if [ "$USER" != "" ]; then
87 LOGNAME="$USER"
88 else
89 LOGNAME="UNKNOWN"
93 FROM="$LOGNAME"
94 REPLY_TO="${REPLY_TO:-${REPLYTO:-$LOGNAME}}"
96 # Find out the name of the originator of this PR.
97 if [ -n "$NAME" ]; then
98 ORIGINATOR="$NAME"
99 elif [ -f $HOME/.fullname ]; then
100 ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
101 else
102 # Must use temp file due to incompatibilities in quoting behavior
103 # and to protect shell metacharacters in the expansion of $LOGNAME
104 $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP
105 ORIGINATOR="`cat $TEMP`"
106 rm -f $TEMP
109 if [ -n "$ORGANIZATION" ]; then
110 if [ -f "$ORGANIZATION" ]; then
111 ORGANIZATION="`cat $ORGANIZATION`"
113 else
114 if [ -n "$DEFAULT_ORGANIZATION" ]; then
115 ORGANIZATION="$DEFAULT_ORGANIZATION"
116 elif [ -f $HOME/.organization ]; then
117 ORGANIZATION="`cat $HOME/.organization`"
121 # If they don't have a preferred editor set, then use
122 if [ -z "$VISUAL" ]; then
123 if [ -z "$EDITOR" ]; then
124 EDIT=vi
125 else
126 EDIT="$EDITOR"
128 else
129 EDIT="$VISUAL"
132 # Find out some information.
133 SYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \
134 ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
135 ARCH=`[ -f /bin/arch ] && /bin/arch`
136 MACHINE=`[ -f /bin/machine ] && /bin/machine`
138 COMMAND=`echo $0 | sed -e 's,.*/,,'`
139 USAGE="Usage: $COMMAND [-PVL] [-t address] [-f filename] [-s severity]
140 [-c address] [--request-id] [--version]"
141 REMOVE=
142 BATCH=
144 SEVERITY_C=
146 while [ $# -gt 0 ]; do
147 case "$1" in
148 -r) ;; # Ignore for backward compat.
149 -t | --to) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi
150 shift ; GNATS_ADDR="$1"
151 EXPLICIT_GNATS_ADDR=true
153 -f | --file) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi
154 shift ; IN_FILE="$1"
155 if [ "$IN_FILE" != "-" -a ! -r "$IN_FILE" ]; then
156 echo "$COMMAND: cannot read $IN_FILE"
157 exit 1
160 -b | --batch) BATCH=true ;;
161 -c | --cc) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi
162 shift ; CC="$1"
164 -s | --severity) if [ $# -eq 1 ]; then echo "$USAGE"; exit 1; fi
165 shift ; SEVERITY_C="$1"
167 -p | -P | --print) PRINT=true ;;
168 -L | --list) FORMAT=norm ;;
169 -l | -CL | --lisp) FORMAT=lisp ;;
170 --request-id) REQUEST_ID=true ;;
171 -h | --help) echo "$USAGE"; exit 0 ;;
172 -V | --version) echo "$VERSION"; exit 0 ;;
173 -*) echo "$USAGE" ; exit 1 ;;
174 *) echo "$USAGE" ; exit 1
175 esac
176 shift
177 done
179 # spam does not need to be listed here
180 CATEGORIES="c++ c debug fortran java libf2c libgcj libobjc libstdc++ middle-end objc optimization other preprocessor target web"
182 case "$FORMAT" in
183 lisp) echo "$CATEGORIES" | \
184 awk 'BEGIN {printf "( "} {printf "(\"%s\") ",$0} END {printf ")\n"}'
185 exit 0
187 norm) l=`echo "$CATEGORIES" | \
188 awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
189 END {print max + 1;}'`
190 c=`expr 70 / $l`
191 if [ $c -eq 0 ]; then c=1; fi
192 echo "$CATEGORIES" | \
193 awk 'BEGIN {print "Known categories:"; i = 0 }
194 { printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { print "" } }
195 END { print ""; }'
196 exit 0
198 esac
200 ORIGINATOR_C='<name of the PR author (one line)>'
201 ORGANIZATION_C='<organization of PR author (multiple lines)>'
202 SYNOPSIS_C='<synopsis of the problem (one line)>'
203 if [ -z "$SEVERITY_C" ]; then
204 SEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
206 PRIORITY_C='<[ low | medium | high ] (one line)>'
207 CATEGORY_C='<choose from the top of this file (one line)>'
208 RELEASE_C='<release number or tag (one line)>'
209 ENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>'
210 DESCRIPTION_C='<precise description of the problem (multiple lines)>'
211 HOW_TO_REPEAT_C='<When reporting a compiler error, preprocessor output must be included>'
212 FIX_C='<how to correct or work around the problem, if known (multiple lines)>'
214 # Catch some signals. ($xs kludge needed by Sun /bin/sh)
215 xs=0
216 trap 'rm -f $REF $TEMP; exit $xs' 0
217 trap 'echo "$COMMAND: Aborting ..."; rm -f $REF $TEMP; xs=1; exit' 1 3 13 15
219 # If they told us to use a specific file, then do so.
220 if [ -n "$IN_FILE" ]; then
221 if [ "$IN_FILE" = "-" ]; then
222 # The PR is coming from the standard input.
223 if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
224 sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" > $TEMP
225 else
226 cat > $TEMP
228 else
229 # Use the file they named.
230 if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
231 sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" $IN_FILE > $TEMP
232 else
233 cat $IN_FILE > $TEMP
236 else
238 if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
239 # If their PR_FORM points to a bogus entry, then bail.
240 if [ ! -f "$PR_FORM" -o ! -r "$PR_FORM" -o ! -s "$PR_FORM" ]; then
241 echo "$COMMAND: can't seem to read your template file (\`$PR_FORM'), ignoring PR_FORM"
242 sleep 1
243 PRINT_INTERN=bad_prform
247 if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
248 cp $PR_FORM $TEMP ||
249 ( echo "$COMMAND: could not copy $PR_FORM" ; xs=1; exit )
250 else
251 for file in $TEMP $REF ; do
252 cat > $file << '__EOF__'
253 SEND-PR: -*- send-pr -*-
254 SEND-PR: Lines starting with `SEND-PR' will be removed automatically, as
255 SEND-PR: will all comments (text enclosed in `<' and `>').
256 SEND-PR:
257 SEND-PR: Please consult the GCC manual if you are not sure how to
258 SEND-PR: fill out a problem report.
259 SEND-PR: Note that the Synopsis field is mandatory. The Subject (for
260 SEND-PR: the mail) will be made the same as Synopsis unless explicitly
261 SEND-PR: changed.
262 SEND-PR:
263 SEND-PR: Choose from the following categories:
264 SEND-PR:
265 __EOF__
267 # Format the categories so they fit onto lines.
268 l=`echo "$CATEGORIES" | \
269 awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
270 END {print max + 1;}'`
271 c=`expr 61 / $l`
272 if [ $c -eq 0 ]; then c=1; fi
273 echo "$CATEGORIES" | \
274 awk 'BEGIN {printf "SEND-PR: "; i = 0 }
275 { printf ("%-'$l'.'$l's", $0);
276 if ((++i % '$c') == 0) { printf "\nSEND-PR: " } }
277 END { printf "\nSEND-PR:\n"; }' >> $file
279 cat >> $file << __EOF__
280 To: $GNATS_ADDR
281 Subject:
282 From: $FROM
283 Reply-To: $REPLYTO
284 Cc: $CC
285 X-send-pr-version: $VERSION
286 X-GNATS-Notify:
289 >Submitter-Id: $SUBMITTER
290 >Originator: $ORIGINATOR
291 >Organization: ${ORGANIZATION-$ORGANIZATION_C}
292 >Confidential: no
293 SEND-PR: Leave "Confidential" as "no"; all GCC PRs are public.
294 >Synopsis: $SYNOPSIS_C
295 >Severity: $SEVERITY_C
296 SEND-PR: critical GCC is completely not operational; no work-around known.
297 SEND-PR: serious GCC is not working properly; a work-around is possible.
298 SEND-PR: non-critical Report indicates minor problem.
299 >Priority: $PRIORITY_C
300 SEND-PR: high A solution is necessary as soon as possible.
301 SEND-PR: medium The problem should be solved in the next release.
302 SEND-PR: low The problem should be solve in a future release.
303 >Category: $CATEGORY_C
304 >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)>
305 SEND-PR: doc-bug The doumentation is incorrect.
306 SEND-PR: accepts-illegal GCC fails to reject erroneous code.
307 SEND-PR: rejects-legal GCC gives an error message for correct code.
308 SEND-PR: wrong-code The machine code generated by gcc is incorrect.
309 SEND-PR: ice-on-legal-code GCC gives an Internal Compiler Error (ICE)
310 SEND-PR: for correct code
311 SEND-PR: ice-on-illegal-code GCC gives an ICE instead of reporting an error
312 SEND-PR: pessimizes-code GCC misses an important optimization opportunity
313 SEND-PR: sw-bug Software bug of some other class than above
314 SEND-PR: change-request A feature in GCC is missing.
315 SEND-PR: support I need help with gcc.
316 >Release: ${DEFAULT_RELEASE-$RELEASE_C}
317 >Environment:
318 `[ -n "$SYSTEM" ] && echo System: $SYSTEM`
319 `[ -n "$ARCH" ] && echo Architecture: $ARCH`
320 `[ -n "$MACHINE" ] && echo Machine: $MACHINE`
321 $ENVIRONMENT_C
322 host: @host@
323 build: @build@
324 target: @target@
325 configured with: @gcc_config_arguments@
326 >Description:
327 $DESCRIPTION_C
328 >How-To-Repeat:
329 $HOW_TO_REPEAT_C
330 >Fix:
331 $FIX_C
332 __EOF__
333 done
336 if [ "$PRINT" = true -o "$PRINT_INTERN" = true ]; then
337 cat $TEMP
338 xs=0; exit
341 chmod u+w $TEMP
342 if [ -z "$REQUEST_ID" ]; then
343 eval $EDIT $TEMP
344 else
345 ed -s $TEMP << '__EOF__'
346 /^Subject/s/^Subject:.*/Subject: request for a customer id/
347 /^>Category/s/^>Category:.*/>Category: send-pr/
350 __EOF__
353 if cmp -s $REF $TEMP ; then
354 echo "$COMMAND: problem report not filled out, therefore not sent"
355 xs=1; exit
360 # Check the enumeration fields
362 # This is a "sed-subroutine" with one keyword parameter
363 # (with workaround for Sun sed bug)
365 SED_CMD='
366 /$PATTERN/{
367 s|||
368 s|<.*>||
369 s|^[ ]*||
370 s|[ ]*$||
376 while [ -z "$REQUEST_ID" ]; do
377 CNT=0
379 # 1) Confidential
381 PATTERN=">Confidential:"
382 CONFIDENTIAL=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
383 case "$CONFIDENTIAL" in
384 no) CNT=`expr $CNT + 1` ;;
385 *) echo "$COMMAND: \`$CONFIDENTIAL' is not a valid value for \`Confidential'." ;;
386 esac
388 # 2) Severity
390 PATTERN=">Severity:"
391 SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
392 case "$SEVERITY" in
393 ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
394 *) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
395 esac
397 # 3) Priority
399 PATTERN=">Priority:"
400 PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
401 case "$PRIORITY" in
402 ""|low|medium|high) CNT=`expr $CNT + 1` ;;
403 *) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
404 esac
406 # 4) Category
408 PATTERN=">Category:"
409 CATEGORY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
410 FOUND=
411 for C in $CATEGORIES
413 if [ "$C" = "$CATEGORY" ]; then FOUND=true ; break ; fi
414 done
415 if [ -n "$FOUND" ]; then
416 CNT=`expr $CNT + 1`
417 else
418 if [ -z "$CATEGORY" ]; then
419 echo "$COMMAND: you must include a Category: field in your report."
420 else
421 echo "$COMMAND: \`$CATEGORY' is not a known category."
425 # 5) Class
427 PATTERN=">Class:"
428 CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
429 case "$CLASS" in
430 ""|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` ;;
431 *) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
432 esac
434 # 6) Check that synopsis is not empty
436 if grep "^>Synopsis:[ ]*${SYNOPSIS_C}\$" $TEMP > /dev/null
437 then
438 echo "$COMMAND: Synopsis must not be empty."
439 else
440 CNT=`expr $CNT + 1`
443 [ $CNT -lt 6 -a -z "$BATCH" ] &&
444 echo "Errors were found with the problem report."
446 while true; do
447 if [ -z "$BATCH" ]; then
448 $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
449 read input
450 else
451 if [ $CNT -eq 6 ]; then
452 input=s
453 else
454 input=a
457 case "$input" in
459 if [ -z "$BATCH" ]; then
460 echo "$COMMAND: the problem report remains in $BAD and is not sent."
461 mv $TEMP $BAD
462 else
463 echo "$COMMAND: the problem report is not sent."
465 xs=1; exit
468 eval $EDIT $TEMP
469 continue 2
472 break 2
474 esac
475 done
476 done
479 # Make sure the mail has got a Subject. If not, use the same as
480 # in Synopsis.
483 if grep '^Subject:[ ]*$' $TEMP > /dev/null
484 then
485 SYNOPSIS=`grep '^>Synopsis:' $TEMP | sed -e 's/^>Synopsis:[ ]*//'`
486 ed -s $TEMP << __EOF__
487 /^Subject:/s/:.*\$/: $SYNOPSIS/
490 __EOF__
494 # Remove comments and send the problem report
495 # (we have to use patterns, where the comment contains regex chars)
497 # /^>Originator:/s;$ORIGINATOR;;
498 sed -e "
499 /^SEND-PR:/d
500 /^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
501 /^>Confidential:/s;<.*>;;
502 /^>Synopsis:/s;$SYNOPSIS_C;;
503 /^>Severity:/s;<.*>;;
504 /^>Priority:/s;<.*>;;
505 /^>Category:/s;$CATEGORY_C;;
506 /^>Class:/s;<.*>;;
507 /^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
508 /^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
509 /^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
510 /^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
511 /^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
512 " $TEMP > $REF
514 if $MAIL_AGENT < $REF; then
515 echo "$COMMAND: problem report sent"
516 xs=0; exit
517 else
518 echo "$COMMAND: mysterious mail failure."
519 if [ -z "$BATCH" ]; then
520 echo "$COMMAND: the problem report remains in $BAD and is not sent."
521 mv $REF $BAD
522 else
523 echo "$COMMAND: the problem report is not sent."
525 xs=1; exit