* c-common.c (decl_attributes): Take a pointer to the node to
[official-gcc.git] / gcc / gccbug.in
blob6bb390896f80710233ff59ca4f51fb65262264e5
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).
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 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 REMOVE_TEMP="rm -f $TEMP0 $TEMP $BAD $REF"
86 else
87 TEMPD=$TMPDIR/pd$$
88 TEMP0=$TEMPD/po$$
89 TEMP=$TEMPD/p$$
90 BAD=$TEMPD/pbad$$
91 REF=$TEMPD/pf$$
92 mkdir $TEMPD || exit 1
93 REMOVE_TEMP="rm -rf $TEMPD"
96 # find a user name
97 if [ "$LOGNAME" = "" ]; then
98 if [ "$USER" != "" ]; then
99 LOGNAME="$USER"
100 else
101 LOGNAME="UNKNOWN"
105 FROM="$LOGNAME"
106 REPLY_TO="${REPLY_TO:-${REPLYTO:-$LOGNAME}}"
108 # Find out the name of the originator of this PR.
109 if [ -n "$NAME" ]; then
110 ORIGINATOR="$NAME"
111 elif [ -f $HOME/.fullname ]; then
112 ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
113 else
114 # Must use temp file due to incompatibilities in quoting behavior
115 # and to protect shell metacharacters in the expansion of $LOGNAME
116 $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP0
117 ORIGINATOR="`cat $TEMP0`"
118 rm -f $TEMP0
121 if [ -n "$ORGANIZATION" ]; then
122 if [ -f "$ORGANIZATION" ]; then
123 ORGANIZATION="`cat $ORGANIZATION`"
125 else
126 if [ -n "$DEFAULT_ORGANIZATION" ]; then
127 ORGANIZATION="$DEFAULT_ORGANIZATION"
128 elif [ -f $HOME/.organization ]; then
129 ORGANIZATION="`cat $HOME/.organization`"
133 # If they don't have a preferred editor set, then use
134 if [ -z "$VISUAL" ]; then
135 if [ -z "$EDITOR" ]; then
136 EDIT=vi
137 else
138 EDIT="$EDITOR"
140 else
141 EDIT="$VISUAL"
144 # Find out some information.
145 SYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \
146 ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
147 ARCH=`[ -f /bin/arch ] && /bin/arch`
148 MACHINE=`[ -f /bin/machine ] && /bin/machine`
150 COMMAND=`echo $0 | sed -e 's,.*/,,'`
151 USAGE="Usage: $COMMAND [-PVL] [-t address] [-f filename] [-s severity]
152 [-c address] [--request-id] [--version]"
153 REMOVE=
154 BATCH=
156 SEVERITY_C=
158 while [ $# -gt 0 ]; do
159 case "$1" in
160 -r) ;; # Ignore for backward compat.
161 -t | --to) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
162 shift ; GNATS_ADDR="$1"
163 EXPLICIT_GNATS_ADDR=true
165 -f | --file) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
166 shift ; IN_FILE="$1"
167 if [ "$IN_FILE" != "-" -a ! -r "$IN_FILE" ]; then
168 echo "$COMMAND: cannot read $IN_FILE"
169 $REMOVE_TEMP
170 exit 1
173 -b | --batch) BATCH=true ;;
174 -c | --cc) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
175 shift ; CC="$1"
177 -s | --severity) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
178 shift ; SEVERITY_C="$1"
180 -p | -P | --print) PRINT=true ;;
181 -L | --list) FORMAT=norm ;;
182 -l | -CL | --lisp) FORMAT=lisp ;;
183 --request-id) REQUEST_ID=true ;;
184 -h | --help) echo "$USAGE"; $REMOVE_TEMP; exit 0 ;;
185 -V | --version) echo "$VERSION"; $REMOVE_TEMP; exit 0 ;;
186 -*) echo "$USAGE" ; $REMOVE_TEMP; exit 1 ;;
187 *) echo "$USAGE" ; $REMOVE_TEMP; exit 1
188 esac
189 shift
190 done
192 # spam does not need to be listed here
193 CATEGORIES="bootstrap c++ c debug fortran java libf2c libgcj libobjc libstdc++ middle-end objc optimization other preprocessor target web"
195 case "$FORMAT" in
196 lisp) echo "$CATEGORIES" | \
197 awk 'BEGIN {printf "( "} {printf "(\"%s\") ",$0} END {printf ")\n"}'
198 $REMOVE_TEMP
199 exit 0
201 norm) l=`echo "$CATEGORIES" | \
202 awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
203 END {print max + 1;}'`
204 c=`expr 70 / $l`
205 if [ $c -eq 0 ]; then c=1; fi
206 echo "$CATEGORIES" | \
207 awk 'BEGIN {print "Known categories:"; i = 0 }
208 { printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { print "" } }
209 END { print ""; }'
210 $REMOVE_TEMP
211 exit 0
213 esac
215 ORIGINATOR_C='<name of the PR author (one line)>'
216 ORGANIZATION_C='<organization of PR author (multiple lines)>'
217 SYNOPSIS_C='<synopsis of the problem (one line)>'
218 if [ -z "$SEVERITY_C" ]; then
219 SEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
221 PRIORITY_C='<[ low | medium ] (one line)>'
222 CATEGORY_C='<choose from the top of this file (one line)>'
223 RELEASE_C='<release number or tag (one line)>'
224 ENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>'
225 DESCRIPTION_C='<precise description of the problem (multiple lines)>'
226 HOW_TO_REPEAT_C='<When reporting a compiler error, preprocessor output must be included>'
227 FIX_C='<how to correct or work around the problem, if known (multiple lines)>'
229 # Catch some signals. ($xs kludge needed by Sun /bin/sh)
230 xs=0
231 trap '$REMOVE_TEMP; exit $xs' 0
232 trap 'echo "$COMMAND: Aborting ..."; $REMOVE_TEMP; xs=1; exit' 1 3 13 15
234 # If they told us to use a specific file, then do so.
235 if [ -n "$IN_FILE" ]; then
236 if [ "$IN_FILE" = "-" ]; then
237 # The PR is coming from the standard input.
238 if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
239 sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" > $TEMP
240 else
241 cat > $TEMP
243 else
244 # Use the file they named.
245 if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
246 sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" $IN_FILE > $TEMP
247 else
248 cat $IN_FILE > $TEMP
251 else
253 if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
254 # If their PR_FORM points to a bogus entry, then bail.
255 if [ ! -f "$PR_FORM" -o ! -r "$PR_FORM" -o ! -s "$PR_FORM" ]; then
256 echo "$COMMAND: can't seem to read your template file (\`$PR_FORM'), ignoring PR_FORM"
257 sleep 1
258 PRINT_INTERN=bad_prform
262 if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
263 cp $PR_FORM $TEMP ||
264 ( echo "$COMMAND: could not copy $PR_FORM" ; xs=1; exit )
265 else
266 for file in $TEMP $REF ; do
267 cat > $file << '__EOF__'
268 SEND-PR: -*- send-pr -*-
269 SEND-PR: Lines starting with `SEND-PR' will be removed automatically, as
270 SEND-PR: will all comments (text enclosed in `<' and `>').
271 SEND-PR:
272 SEND-PR: Please consult the GCC manual if you are not sure how to
273 SEND-PR: fill out a problem report.
274 SEND-PR: Note that the Synopsis field is mandatory. The Subject (for
275 SEND-PR: the mail) will be made the same as Synopsis unless explicitly
276 SEND-PR: changed.
277 SEND-PR:
278 SEND-PR: Choose from the following categories:
279 SEND-PR:
280 __EOF__
282 # Format the categories so they fit onto lines.
283 l=`echo "$CATEGORIES" | \
284 awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
285 END {print max + 1;}'`
286 c=`expr 61 / $l`
287 if [ $c -eq 0 ]; then c=1; fi
288 echo "$CATEGORIES" | \
289 awk 'BEGIN {printf "SEND-PR: "; i = 0 }
290 { printf ("%-'$l'.'$l's", $0);
291 if ((++i % '$c') == 0) { printf "\nSEND-PR: " } }
292 END { printf "\nSEND-PR:\n"; }' >> $file
294 cat >> $file << __EOF__
295 To: $GNATS_ADDR
296 Subject:
297 From: $FROM
298 Reply-To: $REPLYTO
299 Cc: $CC
300 X-send-pr-version: $VERSION
301 X-GNATS-Notify:
304 >Submitter-Id: $SUBMITTER
305 >Originator: $ORIGINATOR
306 >Organization: ${ORGANIZATION-$ORGANIZATION_C}
307 >Confidential: no
308 SEND-PR: Leave "Confidential" as "no"; all GCC PRs are public.
309 >Synopsis: $SYNOPSIS_C
310 >Severity: $SEVERITY_C
311 SEND-PR: critical GCC is completely not operational; no work-around known.
312 SEND-PR: serious GCC is not working properly; a work-around is possible.
313 SEND-PR: non-critical Report indicates minor problem.
314 >Priority: $PRIORITY_C
315 SEND-PR: medium The problem should be solved in the next release.
316 SEND-PR: low The problem should be solve in a future release.
317 >Category: $CATEGORY_C
318 >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)>
319 SEND-PR: doc-bug The documentation is incorrect.
320 SEND-PR: accepts-illegal GCC fails to reject erroneous code.
321 SEND-PR: rejects-legal GCC gives an error message for correct code.
322 SEND-PR: wrong-code The machine code generated by gcc is incorrect.
323 SEND-PR: ice-on-legal-code GCC gives an Internal Compiler Error (ICE)
324 SEND-PR: for correct code
325 SEND-PR: ice-on-illegal-code GCC gives an ICE instead of reporting an error
326 SEND-PR: pessimizes-code GCC misses an important optimization opportunity
327 SEND-PR: sw-bug Software bug of some other class than above
328 SEND-PR: change-request A feature in GCC is missing.
329 SEND-PR: support I need help with gcc.
330 >Release: ${DEFAULT_RELEASE-$RELEASE_C}
331 >Environment:
332 `[ -n "$SYSTEM" ] && echo System: $SYSTEM`
333 `[ -n "$ARCH" ] && echo Architecture: $ARCH`
334 `[ -n "$MACHINE" ] && echo Machine: $MACHINE`
335 $ENVIRONMENT_C
336 host: @host@
337 build: @build@
338 target: @target@
339 configured with: @gcc_config_arguments@
340 >Description:
341 $DESCRIPTION_C
342 >How-To-Repeat:
343 $HOW_TO_REPEAT_C
344 >Fix:
345 $FIX_C
346 __EOF__
347 done
350 if [ "$PRINT" = true -o "$PRINT_INTERN" = true ]; then
351 cat $TEMP
352 xs=0; exit
355 chmod u+w $TEMP
356 if [ -z "$REQUEST_ID" ]; then
357 eval $EDIT $TEMP
358 else
359 ed -s $TEMP << '__EOF__'
360 /^Subject/s/^Subject:.*/Subject: request for a customer id/
361 /^>Category/s/^>Category:.*/>Category: send-pr/
364 __EOF__
367 if cmp -s $REF $TEMP ; then
368 echo "$COMMAND: problem report not filled out, therefore not sent"
369 xs=1; exit
374 # Check the enumeration fields
376 # This is a "sed-subroutine" with one keyword parameter
377 # (with workaround for Sun sed bug)
379 SED_CMD='
380 /$PATTERN/{
381 s|||
382 s|<.*>||
383 s|^[ ]*||
384 s|[ ]*$||
390 while [ -z "$REQUEST_ID" ]; do
391 CNT=0
393 # 1) Confidential
395 PATTERN=">Confidential:"
396 CONFIDENTIAL=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
397 case "$CONFIDENTIAL" in
398 no) CNT=`expr $CNT + 1` ;;
399 *) echo "$COMMAND: \`$CONFIDENTIAL' is not a valid value for \`Confidential'." ;;
400 esac
402 # 2) Severity
404 PATTERN=">Severity:"
405 SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
406 case "$SEVERITY" in
407 ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
408 *) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
409 esac
411 # 3) Priority
413 PATTERN=">Priority:"
414 PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
415 case "$PRIORITY" in
416 ""|low|medium) CNT=`expr $CNT + 1` ;;
417 high) echo "$COMMAND: \`Priority: high' is reserved for GCC maintainers." ;;
418 *) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
419 esac
421 # 4) Category
423 PATTERN=">Category:"
424 CATEGORY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
425 FOUND=
426 for C in $CATEGORIES
428 if [ "$C" = "$CATEGORY" ]; then FOUND=true ; break ; fi
429 done
430 if [ -n "$FOUND" ]; then
431 CNT=`expr $CNT + 1`
432 else
433 if [ -z "$CATEGORY" ]; then
434 echo "$COMMAND: you must include a Category: field in your report."
435 else
436 echo "$COMMAND: \`$CATEGORY' is not a known category."
440 # 5) Class
442 PATTERN=">Class:"
443 CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
444 case "$CLASS" in
445 ""|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` ;;
446 *) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
447 esac
449 # 6) Check that synopsis is not empty
451 if grep "^>Synopsis:[ ]*${SYNOPSIS_C}\$" $TEMP > /dev/null
452 then
453 echo "$COMMAND: Synopsis must not be empty."
454 else
455 CNT=`expr $CNT + 1`
458 [ $CNT -lt 6 -a -z "$BATCH" ] &&
459 echo "Errors were found with the problem report."
461 while true; do
462 if [ -z "$BATCH" ]; then
463 $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
464 read input
465 else
466 if [ $CNT -eq 6 ]; then
467 input=s
468 else
469 input=a
472 case "$input" in
474 if [ -z "$BATCH" ]; then
475 echo "$COMMAND: the problem report remains in $BAD and is not sent."
476 REMOVE_TEMP="rm -f $TEMP0 $TEMP $REF"
477 mv $TEMP $BAD
478 else
479 echo "$COMMAND: the problem report is not sent."
481 xs=1; exit
484 eval $EDIT $TEMP
485 continue 2
488 break 2
490 esac
491 done
492 done
495 # Make sure the mail has got a Subject. If not, use the same as
496 # in Synopsis.
499 if grep '^Subject:[ ]*$' $TEMP > /dev/null
500 then
501 SYNOPSIS=`grep '^>Synopsis:' $TEMP | sed -e 's/^>Synopsis:[ ]*//'`
502 ed -s $TEMP << __EOF__
503 /^Subject:/s/:.*\$/: $SYNOPSIS/
506 __EOF__
510 # Remove comments and send the problem report
511 # (we have to use patterns, where the comment contains regex chars)
513 # /^>Originator:/s;$ORIGINATOR;;
514 sed -e "
515 /^SEND-PR:/d
516 /^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
517 /^>Confidential:/s;<.*>;;
518 /^>Synopsis:/s;$SYNOPSIS_C;;
519 /^>Severity:/s;<.*>;;
520 /^>Priority:/s;<.*>;;
521 /^>Category:/s;$CATEGORY_C;;
522 /^>Class:/s;<.*>;;
523 /^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
524 /^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
525 /^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
526 /^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
527 /^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
528 " $TEMP > $REF
530 if $MAIL_AGENT < $REF; then
531 echo "$COMMAND: problem report sent"
532 xs=0; exit
533 else
534 echo "$COMMAND: mysterious mail failure."
535 if [ -z "$BATCH" ]; then
536 echo "$COMMAND: the problem report remains in $BAD and is not sent."
537 REMOVE_TEMP="rm -f $TEMP0 $TEMP $REF"
538 mv $REF $BAD
539 else
540 echo "$COMMAND: the problem report is not sent."
542 xs=1; exit