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