aboutsummaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/cc
diff options
context:
space:
mode:
authorsvn2git <svn2git@FreeBSD.org>1994-05-01 00:00:00 -0800
committersvn2git <svn2git@FreeBSD.org>1994-05-01 00:00:00 -0800
commita16f65c7d117419bd266c28a1901ef129a337569 (patch)
tree2626602f66dc3551e7a7c7bc9ad763c3bc7ab40a /gnu/usr.bin/cc
parent8503f4f13f77abf7adc8f7e329c6f9c1d52b6a20 (diff)
downloadsrc-a16f65c7d117419bd266c28a1901ef129a337569.tar.gz
src-a16f65c7d117419bd266c28a1901ef129a337569.zip
Release FreeBSD 1.1release/1.1.0_cvs
This commit was manufactured to restore the state of the 1.1-RELEASE image. Releases prior to 5.3-RELEASE are omitting the secure/ and crypto/ subdirs.
Diffstat (limited to 'gnu/usr.bin/cc')
-rw-r--r--gnu/usr.bin/cc/Makefile2
-rw-r--r--gnu/usr.bin/cc/TODO3
-rw-r--r--gnu/usr.bin/cc/cc/Makefile20
-rw-r--r--gnu/usr.bin/cc/cc/f77.script114
-rw-r--r--gnu/usr.bin/cc/cc/g++.1635
-rw-r--r--gnu/usr.bin/cc/cc/g++.script111
-rw-r--r--gnu/usr.bin/cc/cc/gcc.14222
-rw-r--r--gnu/usr.bin/cc/cc/gcc.c4270
-rw-r--r--gnu/usr.bin/cc/cc1/Makefile23
-rw-r--r--gnu/usr.bin/cc/cc1/c-aux-info.c642
-rw-r--r--gnu/usr.bin/cc/cc1/c-convert.c95
-rw-r--r--gnu/usr.bin/cc/cc1/c-decl.c6494
-rw-r--r--gnu/usr.bin/cc/cc1/c-iterate.c594
-rw-r--r--gnu/usr.bin/cc/cc1/c-lang.c129
-rw-r--r--gnu/usr.bin/cc/cc1/c-lex.c2111
-rw-r--r--gnu/usr.bin/cc/cc1/c-parse.c3435
-rw-r--r--gnu/usr.bin/cc/cc1/c-pragma.c198
-rw-r--r--gnu/usr.bin/cc/cc1/c-typeck.c5827
-rw-r--r--gnu/usr.bin/cc/cc1obj/Makefile22
-rw-r--r--gnu/usr.bin/cc/cc1obj/objc-act.c7636
-rw-r--r--gnu/usr.bin/cc/cc1obj/objc-act.h116
-rw-r--r--gnu/usr.bin/cc/cc1obj/objc-parse.c4626
-rw-r--r--gnu/usr.bin/cc/cc1obj/objc-tree.def36
-rw-r--r--gnu/usr.bin/cc/cc1plus/Makefile24
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-call.c2823
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-class.c4274
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-class.h115
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-cvt.c1790
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-decl.c11551
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-decl.h59
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-decl2.c2451
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-edsel.c927
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-except.c1221
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-expr.c222
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-gc.c793
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-hash.h186
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-init.c4008
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-input.c184
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-lex.c4232
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-lex.h107
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-method.c2679
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-parse.c7295
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-parse.h88
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-pt.c2123
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-ptree.c153
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-search.c4284
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-spew.c1086
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-tree.c1706
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-tree.def85
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-tree.h2006
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-type2.c1635
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-typeck.c6374
-rw-r--r--gnu/usr.bin/cc/cc1plus/cp-xref.c825
-rw-r--r--gnu/usr.bin/cc/cc1plus/stack.h41
-rw-r--r--gnu/usr.bin/cc/cpp/Makefile27
-rw-r--r--gnu/usr.bin/cc/cpp/cccp.c9144
-rw-r--r--gnu/usr.bin/cc/cpp/cexp.y1006
-rw-r--r--gnu/usr.bin/cc/cpp/gcpp.1667
-rw-r--r--gnu/usr.bin/cc/cpp/pcp.h100
-rw-r--r--gnu/usr.bin/cc/cpp/usr.bin.cpp.sh91
-rw-r--r--gnu/usr.bin/cc/lib/Makefile21
-rw-r--r--gnu/usr.bin/cc/lib/aux-output.c1921
-rw-r--r--gnu/usr.bin/cc/lib/basic-block.h68
-rw-r--r--gnu/usr.bin/cc/lib/c-common.c1222
-rw-r--r--gnu/usr.bin/cc/lib/c-lex.h79
-rw-r--r--gnu/usr.bin/cc/lib/c-parse.h65
-rw-r--r--gnu/usr.bin/cc/lib/c-tree.h447
-rw-r--r--gnu/usr.bin/cc/lib/caller-save.c780
-rw-r--r--gnu/usr.bin/cc/lib/calls.c2891
-rw-r--r--gnu/usr.bin/cc/lib/combine.c10025
-rw-r--r--gnu/usr.bin/cc/lib/conditions.h115
-rw-r--r--gnu/usr.bin/cc/lib/config.h52
-rw-r--r--gnu/usr.bin/cc/lib/convert.c443
-rw-r--r--gnu/usr.bin/cc/lib/convert.h23
-rw-r--r--gnu/usr.bin/cc/lib/cse.c8243
-rw-r--r--gnu/usr.bin/cc/lib/dbxout.c2439
-rw-r--r--gnu/usr.bin/cc/lib/defaults.h120
-rw-r--r--gnu/usr.bin/cc/lib/dwarfout.c5647
-rw-r--r--gnu/usr.bin/cc/lib/emit-rtl.c3137
-rw-r--r--gnu/usr.bin/cc/lib/explow.c1055
-rw-r--r--gnu/usr.bin/cc/lib/expmed.c3160
-rw-r--r--gnu/usr.bin/cc/lib/expr.c7994
-rw-r--r--gnu/usr.bin/cc/lib/expr.h812
-rw-r--r--gnu/usr.bin/cc/lib/final.c2740
-rw-r--r--gnu/usr.bin/cc/lib/flags.h344
-rw-r--r--gnu/usr.bin/cc/lib/flow.c2674
-rw-r--r--gnu/usr.bin/cc/lib/fold-const.c4479
-rw-r--r--gnu/usr.bin/cc/lib/function.c4913
-rw-r--r--gnu/usr.bin/cc/lib/function.h203
-rw-r--r--gnu/usr.bin/cc/lib/gbl-ctors.h80
-rw-r--r--gnu/usr.bin/cc/lib/getpwd.c94
-rw-r--r--gnu/usr.bin/cc/lib/glimits.h83
-rw-r--r--gnu/usr.bin/cc/lib/global.c1660
-rw-r--r--gnu/usr.bin/cc/lib/gstddef.h217
-rw-r--r--gnu/usr.bin/cc/lib/gvarargs.h169
-rw-r--r--gnu/usr.bin/cc/lib/hard-reg-set.h267
-rw-r--r--gnu/usr.bin/cc/lib/i386/bsd.h132
-rw-r--r--gnu/usr.bin/cc/lib/i386/gas.h158
-rw-r--r--gnu/usr.bin/cc/lib/i386/gstabs.h9
-rw-r--r--gnu/usr.bin/cc/lib/i386/i386.h1591
-rw-r--r--gnu/usr.bin/cc/lib/i386/perform.h93
-rw-r--r--gnu/usr.bin/cc/lib/i386/unix.h145
-rw-r--r--gnu/usr.bin/cc/lib/input.h46
-rw-r--r--gnu/usr.bin/cc/lib/insn-attr.h19
-rw-r--r--gnu/usr.bin/cc/lib/insn-attrtab.c14
-rw-r--r--gnu/usr.bin/cc/lib/insn-codes.h174
-rw-r--r--gnu/usr.bin/cc/lib/insn-config.h12
-rw-r--r--gnu/usr.bin/cc/lib/insn-emit.c2708
-rw-r--r--gnu/usr.bin/cc/lib/insn-extract.c505
-rw-r--r--gnu/usr.bin/cc/lib/insn-flags.h522
-rw-r--r--gnu/usr.bin/cc/lib/insn-opinit.c179
-rw-r--r--gnu/usr.bin/cc/lib/insn-output.c5899
-rw-r--r--gnu/usr.bin/cc/lib/insn-peep.c28
-rw-r--r--gnu/usr.bin/cc/lib/insn-recog.c6158
-rw-r--r--gnu/usr.bin/cc/lib/integrate.c2902
-rw-r--r--gnu/usr.bin/cc/lib/integrate.h120
-rw-r--r--gnu/usr.bin/cc/lib/jump.c4235
-rw-r--r--gnu/usr.bin/cc/lib/lib.mk196
-rw-r--r--gnu/usr.bin/cc/lib/local-alloc.c2173
-rw-r--r--gnu/usr.bin/cc/lib/longlong.h1004
-rw-r--r--gnu/usr.bin/cc/lib/loop.c6508
-rw-r--r--gnu/usr.bin/cc/lib/loop.h169
-rw-r--r--gnu/usr.bin/cc/lib/machmode.def117
-rw-r--r--gnu/usr.bin/cc/lib/machmode.h166
-rw-r--r--gnu/usr.bin/cc/lib/obstack.c454
-rw-r--r--gnu/usr.bin/cc/lib/obstack.h484
-rw-r--r--gnu/usr.bin/cc/lib/optabs.c3614
-rw-r--r--gnu/usr.bin/cc/lib/output.h171
-rw-r--r--gnu/usr.bin/cc/lib/print-rtl.c328
-rw-r--r--gnu/usr.bin/cc/lib/print-tree.c630
-rw-r--r--gnu/usr.bin/cc/lib/real.c5060
-rw-r--r--gnu/usr.bin/cc/lib/real.h363
-rw-r--r--gnu/usr.bin/cc/lib/recog.c1961
-rw-r--r--gnu/usr.bin/cc/lib/recog.h120
-rw-r--r--gnu/usr.bin/cc/lib/reg-stack.c2897
-rw-r--r--gnu/usr.bin/cc/lib/regclass.c1673
-rw-r--r--gnu/usr.bin/cc/lib/regs.h148
-rw-r--r--gnu/usr.bin/cc/lib/reload.c5435
-rw-r--r--gnu/usr.bin/cc/lib/reload.h247
-rw-r--r--gnu/usr.bin/cc/lib/reload1.c6774
-rw-r--r--gnu/usr.bin/cc/lib/reorg.c4115
-rw-r--r--gnu/usr.bin/cc/lib/rtl.c860
-rw-r--r--gnu/usr.bin/cc/lib/rtl.def760
-rw-r--r--gnu/usr.bin/cc/lib/rtl.h917
-rw-r--r--gnu/usr.bin/cc/lib/rtlanal.c1594
-rw-r--r--gnu/usr.bin/cc/lib/sched.c4675
-rw-r--r--gnu/usr.bin/cc/lib/sdbout.c1484
-rw-r--r--gnu/usr.bin/cc/lib/stmt.c4749
-rw-r--r--gnu/usr.bin/cc/lib/stor-layout.c1170
-rw-r--r--gnu/usr.bin/cc/lib/stupid.c544
-rw-r--r--gnu/usr.bin/cc/lib/tconfig.h48
-rw-r--r--gnu/usr.bin/cc/lib/tm.h172
-rw-r--r--gnu/usr.bin/cc/lib/toplev.c3509
-rw-r--r--gnu/usr.bin/cc/lib/tree.c3341
-rw-r--r--gnu/usr.bin/cc/lib/tree.def645
-rw-r--r--gnu/usr.bin/cc/lib/tree.h1507
-rw-r--r--gnu/usr.bin/cc/lib/typeclass.h14
-rw-r--r--gnu/usr.bin/cc/lib/unroll.c3251
-rw-r--r--gnu/usr.bin/cc/lib/varasm.c3033
-rw-r--r--gnu/usr.bin/cc/lib/version.c1
-rw-r--r--gnu/usr.bin/cc/lib/xcoffout.c484
-rw-r--r--gnu/usr.bin/cc/libgcc/Makefile50
-rw-r--r--gnu/usr.bin/cc/libgcc/libgcc1.c607
-rw-r--r--gnu/usr.bin/cc/libgcc/libgcc2.c1758
-rw-r--r--gnu/usr.bin/cc/libobjc/Makefile31
-rw-r--r--gnu/usr.bin/cc/libobjc/Object.h121
-rw-r--r--gnu/usr.bin/cc/libobjc/Object.m358
-rw-r--r--gnu/usr.bin/cc/libobjc/Protocol.h57
-rw-r--r--gnu/usr.bin/cc/libobjc/Protocol.m127
-rw-r--r--gnu/usr.bin/cc/libobjc/archive.c1492
-rw-r--r--gnu/usr.bin/cc/libobjc/class.c350
-rw-r--r--gnu/usr.bin/cc/libobjc/gstdarg.h156
-rw-r--r--gnu/usr.bin/cc/libobjc/hash.c250
-rw-r--r--gnu/usr.bin/cc/libobjc/hash.h200
-rw-r--r--gnu/usr.bin/cc/libobjc/init.c275
-rw-r--r--gnu/usr.bin/cc/libobjc/list.h145
-rw-r--r--gnu/usr.bin/cc/libobjc/misc.c72
-rw-r--r--gnu/usr.bin/cc/libobjc/objc-api.h450
-rw-r--r--gnu/usr.bin/cc/libobjc/objc.h185
-rw-r--r--gnu/usr.bin/cc/libobjc/objects.c91
-rw-r--r--gnu/usr.bin/cc/libobjc/runtime.h73
-rw-r--r--gnu/usr.bin/cc/libobjc/sarray.c435
-rw-r--r--gnu/usr.bin/cc/libobjc/sarray.h235
-rw-r--r--gnu/usr.bin/cc/libobjc/selector.c139
-rw-r--r--gnu/usr.bin/cc/libobjc/sendmsg.c471
-rw-r--r--gnu/usr.bin/cc/libobjc/typedstream.h132
186 files changed, 297899 insertions, 0 deletions
diff --git a/gnu/usr.bin/cc/Makefile b/gnu/usr.bin/cc/Makefile
new file mode 100644
index 000000000000..09821cb28b46
--- /dev/null
+++ b/gnu/usr.bin/cc/Makefile
@@ -0,0 +1,2 @@
+SUBDIR= cc cpp lib cc1 libgcc cc1plus cc1obj libobjc
+.include <bsd.subdir.mk>
diff --git a/gnu/usr.bin/cc/TODO b/gnu/usr.bin/cc/TODO
new file mode 100644
index 000000000000..66783533a858
--- /dev/null
+++ b/gnu/usr.bin/cc/TODO
@@ -0,0 +1,3 @@
+Fix obj library -- doesn't compile with b-make
+Move i386 sources to arch dependant directory
+Fix up make to build insn files from config files.
diff --git a/gnu/usr.bin/cc/cc/Makefile b/gnu/usr.bin/cc/cc/Makefile
new file mode 100644
index 000000000000..5956dcb08542
--- /dev/null
+++ b/gnu/usr.bin/cc/cc/Makefile
@@ -0,0 +1,20 @@
+# from: @(#)Makefile 6.2 (Berkeley) 3/25/91
+# $Id: Makefile,v 1.10 1994/02/22 23:34:30 rgrimes Exp $
+
+PROG= gcc
+SRCS= gcc.c version.c obstack.c
+MAN1= gcc.1 g++.1
+MLINKS+= gcc.1 cc.1
+BINDIR= /usr/bin
+CFLAGS+= -I$(.CURDIR) -I$(.CURDIR)/../lib
+.PATH: $(.CURDIR)/../lib
+
+afterinstall:
+ install -c -o $(BINOWN) -g $(BINGRP) -m $(BINMODE) \
+ $(.CURDIR)/g++.script $(DESTDIR)/usr/bin/g++
+ install -c -o $(BINOWN) -g $(BINGRP) -m $(BINMODE) \
+ $(.CURDIR)/f77.script $(DESTDIR)/usr/bin/f77
+ rm -f $(DESTDIR)$(BINDIR)/cc
+ cd $(DESTDIR)$(BINDIR); ln -s gcc cc
+
+.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/cc/cc/f77.script b/gnu/usr.bin/cc/cc/f77.script
new file mode 100644
index 000000000000..f218a03d9625
--- /dev/null
+++ b/gnu/usr.bin/cc/cc/f77.script
@@ -0,0 +1,114 @@
+#!/bin/sh
+# Compile Fortran code, adding -lf2c.
+# This is a slightly modified g++ script.
+
+: || exec /bin/sh -f $0 $argv:q
+
+# The compiler name might be different when doing cross-compilation
+# (this should be configured)
+gcc_name=gcc
+speclang=-xnone
+
+# replace the command name by the name of the new command
+progname=`basename $0`
+case "$0" in
+ */*)
+ gcc=`echo $0 | sed -e "s;/[^/]*$;;"`/$gcc_name
+ ;;
+ *)
+ gcc=$gcc_name
+ ;;
+esac
+
+# $first is yes for first arg, no afterwards.
+first=yes
+# If next arg is the argument of an option, $quote is non-empty.
+# More precisely, it is the option that wants an argument.
+quote=
+# $library is made empty to disable use of libf2c.
+#library=-lF77 -lI77 -lm
+library="-lf2c -lm"
+numargs=$#
+
+# ash requires the newline before `do'.
+for arg
+do
+ if [ $first = yes ]
+ then
+ # Need some 1st arg to `set' which does not begin with `-'.
+ # We get rid of it after the loop ends.
+ set gcc
+ first=no
+ fi
+ # If you have to ask what this does, you should not edit this file. :-)
+ # The ``S'' at the start is so that echo -nostdinc does not eat the
+ # -nostdinc.
+ arg=`echo "S$arg" | sed "s/^S//; s/'/'\\\\\\\\''/g"`
+ if [ x$quote != x ]
+ then
+ quote=
+ else
+ quote=
+ case $arg in
+ -nostdlib)
+ # Inhibit linking with -lf2c.
+ library=
+ ;;
+ -lm | -lmath)
+ # Because libf2c uses things from the math library, make sure it
+ # always comes before the math library. We recognize both -lm
+ # and -lmath, since on some systems (e.g. m88k SVR3), it
+ # doesn't call it libm.a for some reason.
+ #set "$@" $library
+ #library=""
+ ;;
+ -[bBVDUoeTuIYmLiA] | -Tdata)
+ # these switches take following word as argument,
+ # so don't treat it as a file name.
+ quote=$arg
+ ;;
+ -[cSEM] | -MM)
+ # Don't specify libraries if we won't link,
+ # since that would cause a warning.
+ library=
+ ;;
+ -x*)
+ speclang=$arg
+ ;;
+ -v)
+ # catch `f77 -v'
+ if [ $numargs = 1 ] ; then library="" ; fi
+ ;;
+ -*)
+ # Pass other options through; they don't need -x and aren't inputs.
+ ;;
+ *)
+ # If file ends in .i, put options around it.
+ # But not if a specified -x option is currently active.
+ case "$speclang $arg" in -xnone\ *.i)
+ set "$@" -xf2c "'$arg'" -xnone
+ continue
+ esac
+ ;;
+ esac
+ fi
+ set "$@" "'$arg'"
+done
+
+# Get rid of that initial 1st arg
+if [ $first = no ]; then
+ shift
+else
+ echo "$0: No input files specified."
+ exit 1
+fi
+
+if [ x$quote != x ]
+then
+ echo "$0: argument to \`$quote' missing"
+ exit 1
+fi
+
+eval $gcc "$@" $library
+
+
diff --git a/gnu/usr.bin/cc/cc/g++.1 b/gnu/usr.bin/cc/cc/g++.1
new file mode 100644
index 000000000000..38d4410f8000
--- /dev/null
+++ b/gnu/usr.bin/cc/cc/g++.1
@@ -0,0 +1,635 @@
+.\" Copyright (c) 1991, 1992 Free Software Foundation -*-Text-*-
+.\" See section COPYING for conditions for redistribution
+.\" FIXME: no info here on predefines. Should there be? extra for C++...
+.TH G++ 1 "30apr1993" "GNU Tools" "GNU Tools"
+.de BP
+.sp
+.ti \-.2i
+\(**
+..
+.SH NAME
+g++ \- GNU project C++ Compiler (v2.4)
+.SH SYNOPSIS
+.RB g++ " [" \c
+.IR option " | " filename " ].\|.\|.
+.SH DESCRIPTION
+The C and C++ compilers are integrated;
+.B g++
+is a script to call
+.B gcc with options to recognize C++.
+.B gcc
+processes input files
+through one or more of four stages: preprocessing, compilation,
+assembly, and linking. This man page contains full descriptions for
+.I only
+C++ specific aspects of the compiler, though it also contains
+summaries of some general-purpose options. For a fuller explanation
+of the compiler, see
+.BR gcc ( 1 ).
+
+C++ source files use one of the suffixes `\|\c
+.B .C\c
+\&\|', `\|\c
+.B .cc\c
+\&\|', or `\|\c
+.B .cxx\c
+\&\|'; preprocessed C++ files use the suffix `\|\c
+.B .ii\c
+\&\|'.
+.SH OPTIONS
+There are many command-line options, including options to control
+details of optimization, warnings, and code generation, which are
+common to both
+.B gcc
+and
+.B g++\c
+\&. For full information on all options, see
+.BR gcc ( 1 ).
+
+Options must be separate: `\|\c
+.B \-dr\c
+\&\|' is quite different from `\|\c
+.B \-d \-r
+\&\|'.
+
+Most `\|\c
+.B \-f\c
+\&\|' and `\|\c
+.B \-W\c
+\&\|' options have two contrary forms:
+.BI \-f name
+and
+.BI \-fno\- name\c
+\& (or
+.BI \-W name
+and
+.BI \-Wno\- name\c
+\&). Only the non-default forms are shown here.
+
+.TP
+.B \-c
+Compile or assemble the source files, but do not link. The compiler
+output is an object file corresponding to each source file.
+.TP
+.BI \-D macro
+Define macro \c
+.I macro\c
+\& with the string `\|\c
+.B 1\c
+\&\|' as its definition.
+.TP
+.BI \-D macro = defn
+Define macro \c
+.I macro\c
+\& as \c
+.I defn\c
+\&.
+.TP
+.B \-E
+Stop after the preprocessing stage; do not run the compiler proper. The
+output is preprocessed source code, which is sent to the
+standard output.
+.TP
+.B \-fall\-virtual
+Treat all possible member functions as virtual, implicitly. All
+member functions (except for constructor functions and
+.B new
+or
+.B delete
+member operators) are treated as virtual functions of the class where
+they appear.
+
+This does not mean that all calls to these member functions will be
+made through the internal table of virtual functions. Under some
+circumstances, the compiler can determine that a call to a given
+virtual function can be made directly; in these cases the calls are
+direct in any case.
+.TP
+.B \-fdollars\-in\-identifiers
+Permit the use of `\|\c
+.B $\c
+\&\|' in identifiers.
+Traditional C allowed the character `\|\c
+.B $\c
+\&\|' to form part of identifiers; by default, GNU C also
+allows this. However, ANSI C forbids `\|\c
+.B $\c
+\&\|' in identifiers, and GNU C++ also forbids it by default on most
+platforms (though on some platforms it's enabled by default for GNU
+C++ as well).
+.TP
+.B \-felide\-constructors
+Use this option to instruct the compiler to be smarter about when it can
+elide constructors. Without this flag, GNU C++ and cfront both
+generate effectively the same code for:
+.sp
+.br
+A\ foo\ ();
+.br
+A\ x\ (foo\ ());\ \ \ //\ x\ initialized\ by\ `foo\ ()',\ no\ ctor\ called
+.br
+A\ y\ =\ foo\ ();\ \ \ //\ call\ to\ `foo\ ()'\ heads\ to\ temporary,
+.br
+\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ //\ y\ is\ initialized\ from\ the\ temporary.
+.br
+.sp
+Note the difference! With this flag, GNU C++ initializes `\|\c
+.B y\c
+\&\|' directly
+from the call to
+.B foo ()
+without going through a temporary.
+.TP
+.B \-fenum\-int\-equiv
+Normally GNU C++ allows conversion of
+.B enum
+to
+.B int\c
+\&, but not the other way around. Use this option if you want GNU C++
+to allow conversion of
+.B int
+to
+.B enum
+as well.
+.TP
+.B \-fno\-gnu\-linker
+Do not output global initializations (such as C++ constructors and
+destructors) in the form used by the GNU linker (on systems where the GNU
+linker is the standard method of handling them). Use this option when
+you want to use a non-GNU linker, which also requires using the
+.B collect2
+program to make sure the system linker includes
+constructors and destructors. (\c
+.B collect2
+is included in the GNU CC distribution.) For systems which
+.I must
+use
+.B collect2\c
+\&, the compiler driver
+.B gcc
+is configured to do this automatically.
+.TP
+.B \-fmemoize\-lookups
+.TP
+.B \-fsave\-memoized
+These flags are used to get the compiler to compile programs faster
+using heuristics. They are not on by default since they are only effective
+about half the time. The other half of the time programs compile more
+slowly (and take more memory).
+
+The first time the compiler must build a call to a member function (or
+reference to a data member), it must (1) determine whether the class
+implements member functions of that name; (2) resolve which member
+function to call (which involves figuring out what sorts of type
+conversions need to be made); and (3) check the visibility of the member
+function to the caller. All of this adds up to slower compilation.
+Normally, the second time a call is made to that member function (or
+reference to that data member), it must go through the same lengthy
+process again. This means that code like this
+.sp
+.br
+\ \ cout\ <<\ "This\ "\ <<\ p\ <<\ "\ has\ "\ <<\ n\ <<\ "\ legs.\en";
+.br
+.sp
+makes six passes through all three steps. By using a software cache,
+a ``hit'' significantly reduces this cost. Unfortunately, using the
+cache introduces another layer of mechanisms which must be implemented,
+and so incurs its own overhead. `\|\c
+.B \-fmemoize\-lookups\c
+\&\|' enables
+the software cache.
+
+Because access privileges (visibility) to members and member functions
+may differ from one function context to the next,
+.B g++
+may need to flush the cache. With the `\|\c
+.B \-fmemoize\-lookups\c
+\&\|' flag, the cache is flushed after every
+function that is compiled. The `\|\c
+\-fsave\-memoized\c
+\&\|' flag enables the same software cache, but when the compiler
+determines that the context of the last function compiled would yield
+the same access privileges of the next function to compile, it
+preserves the cache.
+This is most helpful when defining many member functions for the same
+class: with the exception of member functions which are friends of
+other classes, each member function has exactly the same access
+privileges as every other, and the cache need not be flushed.
+.TP
+.B \-fno\-default\-inline
+Do not make member functions inline by default merely because they are
+defined inside the class scope. Otherwise, when you specify
+.B \-O\c
+\&, member functions defined inside class scope are compiled
+inline by default; i.e., you don't need to add `\|\c
+.B inline\c
+\&\|' in front of
+the member function name.
+.TP
+.B \-fno\-strict\-prototype
+Consider the declaration \c
+.B int foo ();\c
+\&. In C++, this means that the
+function \c
+.B foo\c
+\& takes no arguments. In ANSI C, this is declared
+.B int foo(void);\c
+\&. With the flag `\|\c
+.B \-fno\-strict\-prototype\c
+\&\|',
+declaring functions with no arguments is equivalent to declaring its
+argument list to be untyped, i.e., \c
+.B int foo ();\c
+\& is equivalent to
+saying \c
+.B int foo (...);\c
+\&.
+.TP
+.B \-fnonnull\-objects
+Normally, GNU C++ makes conservative assumptions about objects reached
+through references. For example, the compiler must check that `\|\c
+.B a\c
+\&\|' is not null in code like the following:
+.br
+\ \ \ \ obj\ &a\ =\ g\ ();
+.br
+\ \ \ \ a.f\ (2);
+.br
+Checking that references of this sort have non-null values requires
+extra code, however, and it is unnecessary for many programs. You can
+use `\|\c
+.B \-fnonnull\-objects\c
+\&\|' to omit the checks for null, if your program doesn't require the
+default checking.
+.TP
+.B \-fthis\-is\-variable
+The incorporation of user-defined free store management into C++ has
+made assignment to \c
+.B this\c
+\& an anachronism. Therefore, by default GNU
+C++ treats the type of \c
+.B this\c
+\& in a member function of \c
+.B class X\c
+\&
+to be \c
+.B X *const\c
+\&. In other words, it is illegal to assign to
+\c
+.B this\c
+\& within a class member function. However, for backwards
+compatibility, you can invoke the old behavior by using
+\&`\|\c
+.B \-fthis\-is\-variable\c
+\&\|'.
+.TP
+.B \-g
+Produce debugging information in the operating system's native format
+(for DBX or SDB or DWARF). GDB also can work with this debugging
+information. On most systems that use DBX format, `\|\c
+.B \-g\c
+\&\|' enables use
+of extra debugging information that only GDB can use.
+
+Unlike most other C compilers, GNU CC allows you to use `\|\c
+.B \-g\c
+\&\|' with
+`\|\c
+.B \-O\c
+\&\|'. The shortcuts taken by optimized code may occasionally
+produce surprising results: some variables you declared may not exist
+at all; flow of control may briefly move where you did not expect it;
+some statements may not be executed because they compute constant
+results or their values were already at hand; some statements may
+execute in different places because they were moved out of loops.
+
+Nevertheless it proves possible to debug optimized output. This makes
+it reasonable to use the optimizer for programs that might have bugs.
+.TP
+.BI "\-I" "dir"\c
+\&
+Append directory \c
+.I dir\c
+\& to the list of directories searched for include files.
+.TP
+.BI "\-L" "dir"\c
+\&
+Add directory \c
+.I dir\c
+\& to the list of directories to be searched
+for `\|\c
+.B \-l\c
+\&\|'.
+.TP
+.BI \-l library\c
+\&
+Use the library named \c
+.I library\c
+\& when linking. (C++ programs often require `\|\c
+\-lg++\c
+\&\|' for successful linking.)
+.TP
+.B \-nostdinc
+Do not search the standard system directories for header files. Only
+the directories you have specified with
+.B \-I
+options (and the current directory, if appropriate) are searched.
+.TP
+.B \-nostdinc++
+Do not search for header files in the standard directories specific to
+C++, but do still search the other standard directories. (This option
+is used when building libg++.)
+.TP
+.B \-O
+Optimize. Optimizing compilation takes somewhat more time, and a lot
+more memory for a large function.
+.TP
+.BI "\-o " file\c
+\&
+Place output in file \c
+.I file\c
+\&.
+.TP
+.B \-S
+Stop after the stage of compilation proper; do not assemble. The output
+is an assembler code file for each non-assembler input
+file specified.
+.TP
+.B \-traditional
+Attempt to support some aspects of traditional C compilers.
+
+Specifically, for both C and C++ programs:
+.TP
+\ \ \ \(bu
+In the preprocessor, comments convert to nothing at all, rather than
+to a space. This allows traditional token concatenation.
+.TP
+\ \ \ \(bu
+In the preprocessor, macro arguments are recognized within string
+constants in a macro definition (and their values are stringified,
+though without additional quote marks, when they appear in such a
+context). The preprocessor always considers a string constant to end
+at a newline.
+.TP
+\ \ \ \(bu
+The preprocessor does not predefine the macro \c
+.B __STDC__\c
+\& when you use
+`\|\c
+.B \-traditional\c
+\&\|', but still predefines\c
+.B __GNUC__\c
+\& (since the GNU extensions indicated by
+.B __GNUC__\c
+\& are not affected by
+`\|\c
+.B \-traditional\c
+\&\|'). If you need to write header files that work
+differently depending on whether `\|\c
+.B \-traditional\c
+\&\|' is in use, by
+testing both of these predefined macros you can distinguish four
+situations: GNU C, traditional GNU C, other ANSI C compilers, and
+other old C compilers.
+.TP
+\ \ \ \(bu
+In the preprocessor, comments convert to nothing at all, rather than
+to a space. This allows traditional token concatenation.
+.TP
+\ \ \ \(bu
+In the preprocessor, macro arguments are recognized within string
+constants in a macro definition (and their values are stringified,
+though without additional quote marks, when they appear in such a
+context). The preprocessor always considers a string constant to end
+at a newline.
+.TP
+\ \ \ \(bu
+The preprocessor does not predefine the macro \c
+.B __STDC__\c
+\& when you use
+`\|\c
+.B \-traditional\c
+\&\|', but still predefines\c
+.B __GNUC__\c
+\& (since the GNU extensions indicated by
+.B __GNUC__\c
+\& are not affected by
+`\|\c
+.B \-traditional\c
+\&\|'). If you need to write header files that work
+differently depending on whether `\|\c
+.B \-traditional\c
+\&\|' is in use, by
+testing both of these predefined macros you can distinguish four
+situations: GNU C, traditional GNU C, other ANSI C compilers, and
+other old C compilers.
+.PP
+.TP
+\ \ \ \(bu
+String ``constants'' are not necessarily constant; they are stored in
+writable space, and identical looking constants are allocated
+separately.
+
+For C++ programs only (not C), `\|\c
+.B \-traditional\c
+\&\|' has one additional effect: assignment to
+.B this
+is permitted. This is the same as the effect of `\|\c
+.B \-fthis\-is\-variable\c
+\&\|'.
+.TP
+.BI \-U macro
+Undefine macro \c
+.I macro\c
+\&.
+.TP
+.B \-Wall
+Issue warnings for conditions which pertain to usage that we recommend
+avoiding and that we believe is easy to avoid, even in conjunction
+with macros.
+.TP
+.B \-Wenum\-clash
+Warn when converting between different enumeration types.
+.TP
+.B \-Woverloaded\-virtual
+In a derived class, the definitions of virtual functions must match
+the type signature of a virtual function declared in the base class.
+Use this option to request warnings when a derived class declares a
+function that may be an erroneous attempt to define a virtual
+function: that is, warn when a function with the same name as a
+virtual function in the base class, but with a type signature that
+doesn't match any virtual functions from the base class.
+.TP
+.B \-Wtemplate\-debugging
+When using templates in a C++ program, warn if debugging is not yet
+fully available.
+.TP
+.B \-w
+Inhibit all warning messages.
+.TP
+.BI +e N
+Control how virtual function definitions are used, in a fashion
+compatible with
+.B cfront
+1.x.
+.PP
+
+.SH PRAGMAS
+Two `\|\c
+.B #pragma\c
+\&\|' directives are supported for GNU C++, to permit using the same
+header file for two purposes: as a definition of interfaces to a given
+object class, and as the full definition of the contents of that object class.
+.TP
+.B #pragma interface
+Use this directive in header files that define object classes, to save
+space in most of the object files that use those classes. Normally,
+local copies of certain information (backup copies of inline member
+functions, debugging information, and the internal tables that
+implement virtual functions) must be kept in each object file that
+includes class definitions. You can use this pragma to avoid such
+duplication. When a header file containing `\|\c
+.B #pragma interface\c
+\&\|' is included in a compilation, this auxiliary information
+will not be generated (unless the main input source file itself uses
+`\|\c
+.B #pragma implementation\c
+\&\|'). Instead, the object files will contain references to be
+resolved at link time.
+.tr !"
+.TP
+.B #pragma implementation
+.TP
+.BI "#pragma implementation !" objects .h!
+Use this pragma in a main input file, when you want full output from
+included header files to be generated (and made globally visible).
+The included header file, in turn, should use `\|\c
+.B #pragma interface\c
+\&\|'.
+Backup copies of inline member functions, debugging information, and
+the internal tables used to implement virtual functions are all
+generated in implementation files.
+
+If you use `\|\c
+.B #pragma implementation\c
+\&\|' with no argument, it applies to an include file with the same
+basename as your source file; for example, in `\|\c
+.B allclass.cc\c
+\&\|', `\|\c
+.B #pragma implementation\c
+\&\|' by itself is equivalent to `\|\c
+.B
+#pragma implementation "allclass.h"\c
+\&\|'. Use the string argument if you want a single implementation
+file to include code from multiple header files.
+
+There is no way to split up the contents of a single header file into
+multiple implementation files.
+.SH FILES
+.ta \w'LIBDIR/g++\-include 'u
+file.h C header (preprocessor) file
+.br
+file.i preprocessed C source file
+.br
+file.C C++ source file
+.br
+file.cc C++ source file
+.br
+file.cxx C++ source file
+.br
+file.s assembly language file
+.br
+file.o object file
+.br
+a.out link edited output
+.br
+\fITMPDIR\fR/cc\(** temporary files
+.br
+\fILIBDIR\fR/cpp preprocessor
+.br
+\fILIBDIR\fR/cc1plus compiler
+.br
+\fILIBDIR\fR/collect linker front end needed on some machines
+.br
+\fILIBDIR\fR/libgcc.a GCC subroutine library
+.br
+/lib/crt[01n].o start-up routine
+.br
+\fILIBDIR\fR/ccrt0 additional start-up routine for C++
+.br
+/lib/libc.a standard C library, see
+.IR intro (3)
+.br
+/usr/include standard directory for
+.B #include
+files
+.br
+\fILIBDIR\fR/include standard gcc directory for
+.B #include
+files
+.br
+\fILIBDIR\fR/g++\-include additional g++ directory for
+.B #include
+.sp
+.I LIBDIR
+is usually
+.B /usr/local/lib/\c
+.IR machine / version .
+.br
+.I TMPDIR
+comes from the environment variable
+.B TMPDIR
+(default
+.B /usr/tmp
+if available, else
+.B /tmp\c
+\&).
+.SH "SEE ALSO"
+gcc(1), cpp(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1).
+.br
+.RB "`\|" gcc "\|', `\|" cpp \|',
+.RB `\| as \|', `\| ld \|',
+and
+.RB `\| gdb \|'
+entries in
+.B info\c
+\&.
+.br
+.I
+Using and Porting GNU CC (for version 2.0)\c
+, Richard M. Stallman;
+.I
+The C Preprocessor\c
+, Richard M. Stallman;
+.I
+Debugging with GDB: the GNU Source-Level Debugger\c
+, Richard M. Stallman and Roland H. Pesch;
+.I
+Using as: the GNU Assembler\c
+, Dean Elsner, Jay Fenlason & friends;
+.I
+gld: the GNU linker\c
+, Steve Chamberlain and Roland Pesch.
+
+.SH BUGS
+For instructions on how to report bugs, see the GCC manual.
+
+.SH COPYING
+Copyright (c) 1991, 1992, 1993 Free Software Foundation, Inc.
+.PP
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+.PP
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the
+entire resulting derived work is distributed under the terms of a
+permission notice identical to this one.
+.PP
+Permission is granted to copy and distribute translations of this
+manual into another language, under the above conditions for modified
+versions, except that this permission notice may be included in
+translations approved by the Free Software Foundation instead of in
+the original English.
+.SH AUTHORS
+See the GNU CC Manual for the contributors to GNU CC.
diff --git a/gnu/usr.bin/cc/cc/g++.script b/gnu/usr.bin/cc/cc/g++.script
new file mode 100644
index 000000000000..d633e1c459ad
--- /dev/null
+++ b/gnu/usr.bin/cc/cc/g++.script
@@ -0,0 +1,111 @@
+#!/bin/sh
+# Compile programs, treating .c files as C++.
+: || exec /bin/sh -f $0 $argv:q
+
+# The compiler name might be different when doing cross-compilation
+# (this should be configured)
+gcc_name=gcc
+speclang=-xnone
+
+# replace the command name by the name of the new command
+progname=`basename $0`
+case "$0" in
+ */*)
+ gcc=`echo $0 | sed -e "s;/[^/]*$;;"`/$gcc_name
+ ;;
+ *)
+ gcc=$gcc_name
+ ;;
+esac
+
+# $first is yes for first arg, no afterwards.
+first=yes
+# If next arg is the argument of an option, $quote is non-empty.
+# More precisely, it is the option that wants an argument.
+quote=
+# $library is made empty to disable use of libg++.
+library=-lg++
+numargs=$#
+
+# ash requires the newline before `do'.
+for arg
+do
+ if [ $first = yes ]
+ then
+ # Need some 1st arg to `set' which does not begin with `-'.
+ # We get rid of it after the loop ends.
+ set gcc
+ first=no
+ fi
+ # If you have to ask what this does, you should not edit this file. :-)
+ # The ``S'' at the start is so that echo -nostdinc does not eat the
+ # -nostdinc.
+ arg=`echo "S$arg" | sed "s/^S//; s/'/'\\\\\\\\''/g"`
+ if [ x$quote != x ]
+ then
+ quote=
+ else
+ quote=
+ case $arg in
+ -nostdlib)
+ # Inhibit linking with -lg++.
+ library=
+ ;;
+ -lm | -lmath)
+ # Because libg++ uses things from the math library, make sure it
+ # always comes before the math library. We recognize both -lm
+ # and -lmath, since on some systems (e.g. m88k SVR3), it
+ # doesn't call it libm.a for some reason.
+ set "$@" $library
+ library=""
+ ;;
+ -[bBVDUoeTuIYmLiA] | -Tdata)
+ # these switches take following word as argument,
+ # so don't treat it as a file name.
+ quote=$arg
+ ;;
+ -[cSEM] | -MM)
+ # Don't specify libraries if we won't link,
+ # since that would cause a warning.
+ library=
+ ;;
+ -x*)
+ speclang=$arg
+ ;;
+ -v)
+ # catch `g++ -v'
+ if [ $numargs = 1 ] ; then library="" ; fi
+ ;;
+ -*)
+ # Pass other options through; they don't need -x and aren't inputs.
+ ;;
+ *)
+ # If file ends in .c or .i, put options around it.
+ # But not if a specified -x option is currently active.
+ case "$speclang $arg" in -xnone\ *.[ci])
+ set "$@" -xc++ "'$arg'" -xnone
+ continue
+ esac
+ ;;
+ esac
+ fi
+ set "$@" "'$arg'"
+done
+
+# Get rid of that initial 1st arg
+if [ $first = no ]; then
+ shift
+else
+ echo "$0: No input files specified."
+ exit 1
+fi
+
+if [ x$quote != x ]
+then
+ echo "$0: argument to \`$quote' missing"
+ exit 1
+fi
+
+eval $gcc "$@" $library
+
+
diff --git a/gnu/usr.bin/cc/cc/gcc.1 b/gnu/usr.bin/cc/cc/gcc.1
new file mode 100644
index 000000000000..07755f17073b
--- /dev/null
+++ b/gnu/usr.bin/cc/cc/gcc.1
@@ -0,0 +1,4222 @@
+.\" Copyright (c) 1991, 1992, 1993 Free Software Foundation -*-Text-*-
+.\" See section COPYING for conditions for redistribution
+.TH GCC 1 "30apr1993" "GNU Tools" "GNU Tools"
+.de BP
+.sp
+.ti \-.2i
+\(**
+..
+.SH NAME
+gcc, g++ \- GNU project C and C++ Compiler (v2.4)
+.SH SYNOPSIS
+.RB gcc " [" \c
+.IR option " | " filename " ].\|.\|.
+.br
+.RB g++ " [" \c
+.IR option " | " filename " ].\|.\|.
+.SH WARNING
+The information in this man page is an extract from the full
+documentation of the GNU C compiler, and is limited to the meaning of
+the options. This man page is not kept up to date except when
+volunteers want to maintain it.
+
+For complete and current documentation, refer to the Info file `\|\c
+.B gcc\c
+\&\|' or the manual
+.I
+Using and Porting GNU CC (for version 2.0)\c
+\&. Both are made from the Texinfo source file
+.BR gcc.texinfo .
+.SH DESCRIPTION
+The C and C++ compilers are integrated. Both process input files
+through one or more of four stages: preprocessing, compilation,
+assembly, and linking. Source filename suffixes identify the source
+language, but which name you use for the compiler governs default
+assumptions:
+.TP
+.B gcc
+assumes preprocessed (\c
+.B .i\c
+\&) files are C and assumes C style linking.
+.TP
+.B g++
+assumes preprocessed (\c
+.B .i\c
+\&) files are C++ and assumes C++ style linking.
+.PP
+Suffixes of source file names indicate the language and kind of
+processing to be done:
+
+.ta \w'.cxx 'u
+.B .c\c
+\& C source; preprocess, compile, assemble
+.br
+.B .C\c
+\& C++ source; preprocess, compile, assemble
+.br
+.B .cc\c
+\& C++ source; preprocess, compile, assemble
+.br
+.B .cxx\c
+\& C++ source; preprocess, compile, assemble
+.br
+.B .m\c
+\& Objective-C source; preprocess, compile, assemble
+.br
+.B .i\c
+\& preprocessed C; compile, assemble
+.br
+.B .ii\c
+\& preprocessed C++; compile, assemble
+.br
+.B .s\c
+\& Assembler source; assemble
+.br
+.B .S\c
+\& Assembler source; preprocess, assemble
+.br
+.B .h\c
+\& Preprocessor file; not usually named on command line
+
+.I ??\c
+\& Other (unrecognized) files passed to linker.
+.br
+\& Common cases:
+.br
+.B .o\c
+\& Object file
+.br
+.B .a\c
+\& Archive file
+
+Linking is always the last stage unless you use one of the
+.BR \-c ,
+.BR \-S ,
+or
+.B \-E
+options to avoid it (or unless compilation errors stop the whole
+process). For the link stage, all
+.B .o
+files corresponding to source files,
+.B \-l
+libraries, unrecognized filenames (including named
+.B .o
+object files and
+.B .a
+archives)
+are passed to the linker in command-line order.
+
+.SH OPTIONS
+Options must be separate: `\|\c
+.B \-dr\c
+\&\|' is quite different from `\|\c
+.B \-d \-r
+\&\|'.
+
+Most `\|\c
+.B \-f\c
+\&\|' and `\|\c
+.B \-W\c
+\&\|' options have two contrary forms:
+.BI \-f name
+and
+.BI \-fno\- name\c
+\& (or
+.BI \-W name
+and
+.BI \-Wno\- name\c
+\&). Only the non-default forms are shown here.
+
+Here is a summary of all the options, grouped by type. Explanations are
+in the following sections.
+
+.hy 0
+.na
+.TP
+.B Overall Options
+.br
+\-c
+\-S
+\-E
+.RI "\-o " file
+\-pipe
+\-v
+.RI "\-x " language
+
+.TP
+.B Language Options
+\-ansi
+\-fall\-virtual
+\-fcond\-mismatch
+\-fdollars\-in\-identifiers
+\-fenum\-int\-equiv
+\-fno\-asm
+\-fno\-builtin
+\-fno\-strict\-prototype
+\-fsigned\-bitfields
+\-fsigned\-char
+\-fthis\-is\-variable
+\-funsigned\-bitfields
+\-funsigned\-char
+\-fwritable\-strings
+\-traditional
+\-traditional\-cpp
+\-trigraphs
+
+.TP
+.B Warning Options
+\-fsyntax\-only
+\-pedantic
+\-pedantic\-errors
+\-w
+\-W
+\-Wall
+\-Waggregate\-return
+\-Wcast\-align
+\-Wcast\-qual
+\-Wchar\-subscript
+\-Wcomment
+\-Wconversion
+\-Wenum\-clash
+\-Werror
+\-Wformat
+.RI \-Wid\-clash\- len
+\-Wimplicit
+\-Winline
+\-Wmissing\-prototypes
+\-Wnested\-externs
+\-Wno\-import
+\-Wparentheses
+\-Wpointer\-arith
+\-Wredundant\-decls
+\-Wreturn\-type
+\-Wshadow
+\-Wstrict\-prototypes
+\-Wswitch
+\-Wtemplate\-debugging
+\-Wtraditional
+\-Wtrigraphs
+\-Wuninitialized
+\-Wunused
+\-Wwrite\-strings
+
+.TP
+.B Debugging Options
+\-a
+.RI \-d letters
+\-fpretend\-float
+\-g
+.RI \-g level
+\-gcoff
+\-gxcoff
+\-gxcoff+
+\-gdwarf
+\-gdwarf+
+\-gstabs
+\-gstabs+
+\-ggdb
+\-p
+\-pg
+\-save\-temps
+\-print\-libgcc\-file\-name
+
+.TP
+.B Optimization Options
+\-fcaller\-saves
+\-fcse\-follow\-jumps
+\-fcse\-skip\-blocks
+\-fdelayed\-branch
+\-felide\-constructors
+\-fexpensive\-optimizations
+\-ffast-\math
+\-ffloat\-store
+\-fforce\-addr
+\-fforce\-mem
+\-finline\-functions
+\-fkeep\-inline\-functions
+\-fmemoize\-lookups
+\-fno\-default\-inline
+\-fno\-defer\-pop
+\-fno\-function\-cse
+\-fno\-inline
+\-fno\-peephole
+\-fomit\-frame\-pointer
+\-frerun\-cse\-after\-loop
+\-fschedule\-insns
+\-fschedule\-insns2
+\-fstrength\-reduce
+\-fthread\-jumps
+\-funroll\-all\-loops
+\-funroll\-loops
+\-O
+\-O2
+
+.TP
+.B Preprocessor Options
+.RI \-A assertion
+\-C
+\-dD
+\-dM
+\-dN
+.RI \-D macro [\|= defn \|]
+\-E
+\-H
+.RI "\-idirafter " dir
+.RI "\-include " file
+.RI "\-imacros " file
+.RI "\-iprefix " file
+.RI "\-iwithprefix " dir
+\-M
+\-MD
+\-MM
+\-MMD
+\-nostdinc
+\-P
+.RI \-U macro
+\-undef
+
+.TP
+.B Assembler Option
+.RI \-Wa, option
+
+.TP
+.B Linker Options
+.RI \-l library
+\-nostartfiles
+\-nostdlib
+\-static
+\-shared
+\-symbolic
+.RI "\-Xlinker\ " option
+.RI \-Wl, option
+.RI "\-u " symbol
+
+.TP
+.B Directory Options
+.RI \-B prefix
+.RI \-I dir
+\-I\-
+.RI \-L dir
+
+.TP
+.B Target Options
+.RI "\-b " machine
+.RI "\-V " version
+
+.TP
+.B Configuration Dependent Options
+.I M680x0\ Options
+.br
+\-m68000
+\-m68020
+\-m68020\-40
+\-m68030
+\-m68040
+\-m68881
+\-mbitfield
+\-mc68000
+\-mc68020
+\-mfpa
+\-mnobitfield
+\-mrtd
+\-mshort
+\-msoft\-float
+
+.I VAX Options
+.br
+\-mg
+\-mgnu
+\-munix
+
+.I SPARC Options
+.br
+\-mepilogue
+\-mfpu
+\-mhard\-float
+\-mno\-fpu
+\-mno\-epilogue
+\-msoft\-float
+\-msparclite
+\-mv8
+
+.I Convex Options
+.br
+\-margcount
+\-mc1
+\-mc2
+\-mnoargcount
+
+.I AMD29K Options
+.br
+\-m29000
+\-m29050
+\-mbw
+\-mdw
+\-mkernel\-registers
+\-mlarge
+\-mnbw
+\-mnodw
+\-msmall
+\-mstack\-check
+\-muser\-registers
+
+.I M88K Options
+.br
+\-m88000
+\-m88100
+\-m88110
+\-mbig\-pic
+\-mcheck\-zero\-division
+\-mhandle\-large\-shift
+\-midentify\-revision
+\-mno\-check\-zero\-division
+\-mno\-ocs\-debug\-info
+\-mno\-ocs\-frame\-position
+\-mno\-optimize\-arg\-area
+\-mno\-seriazlize\-volatile
+\-mno\-underscores
+\-mocs\-debug\-info
+\-mocs\-frame\-position
+\-moptimize\-arg\-area
+\-mserialize\-volatile
+.RI \-mshort\-data\- num
+\-msvr3
+\-msvr4
+\-mtrap\-large\-shift
+\-muse\-div\-instruction
+\-mversion\-03.00
+\-mwarn\-passed\-structs
+
+.I RS6000 Options
+.br
+\-mfp\-in\-toc
+\-mno\-fop\-in\-toc
+
+.I RT Options
+.br
+\-mcall\-lib\-mul
+\-mfp\-arg\-in\-fpregs
+\-mfp\-arg\-in\-gregs
+\-mfull\-fp\-blocks
+\-mhc\-struct\-return
+\-min\-line\-mul
+\-mminimum\-fp\-blocks
+\-mnohc\-struct\-return
+
+.I MIPS Options
+.br
+\-mcpu=\fIcpu type\fP
+\-mips2
+\-mips3
+\-mint64
+\-mlong64
+\-mlonglong128
+\-mmips\-as
+\-mgas
+\-mrnames
+\-mno\-rnames
+\-mgpopt
+\-mno\-gpopt
+\-mstats
+\-mno\-stats
+\-mmemcpy
+\-mno\-memcpy
+\-mno\-mips\-tfile
+\-mmips\-tfile
+\-msoft\-float
+\-mhard\-float
+\-mabicalls
+\-mno\-abicalls
+\-mhalf\-pic
+\-mno\-half\-pic
+\-G \fInum\fP
+\-nocpp
+
+.I i386 Options
+.br
+\-m486
+\-mno\-486
+\-msoft\-float
+\-mno\-fp\-ret\-in\-387
+
+.I HPPA Options
+.br
+\-mpa\-risc\-1\-0
+\-mpa\-risc\-1\-1
+\-mkernel
+\-mshared\-libs
+\-mno\-shared\-libs
+\-mlong\-calls
+\-mdisable\-fpregs
+\-mdisable\-indexing
+\-mtrailing\-colon
+
+.I i960 Options
+.br
+\-m\fIcpu-type\fP
+\-mnumerics
+\-msoft\-float
+\-mleaf\-procedures
+\-mno\-leaf\-procedures
+\-mtail\-call
+\-mno\-tail\-call
+\-mcomplex\-addr
+\-mno\-complex\-addr
+\-mcode\-align
+\-mno\-code\-align
+\-mic\-compat
+\-mic2.0\-compat
+\-mic3.0\-compat
+\-masm\-compat
+\-mintel\-asm
+\-mstrict\-align
+\-mno\-strict\-align
+\-mold\-align
+\-mno\-old\-align
+
+.I DEC Alpha Options
+.br
+\-mfp\-regs
+\-mno\-fp\-regs
+\-mno\-soft\-float
+\-msoft\-float
+
+.I System V Options
+.br
+\-G
+\-Qy
+\-Qn
+.RI \-YP, paths
+.RI \-Ym, dir
+
+.TP
+.B Code Generation Options
+.RI \-fcall\-saved\- reg
+.RI \-fcall\-used\- reg
+.RI \-ffixed\- reg
+\-finhibit\-size\-directive
+\-fnonnull\-objects
+\-fno\-common
+\-fno\-ident
+\-fno\-gnu\-linker
+\-fpcc\-struct\-return
+\-fpic
+\-fPIC
+\-freg\-struct\-returno
+\-fshared\-data
+\-fshort\-enums
+\-fshort\-double
+\-fvolatile
+\-fvolatile\-global
+\-fverbose\-asm
+.ad b
+.hy 1
+
+.SH OVERALL OPTIONS
+.TP
+.BI "\-x " "language"
+Specify explicitly the
+.I language\c
+\& for the following input files (rather than choosing a default based
+on the file name suffix) . This option applies to all following input
+files until the next `\|\c
+.B \-x\c
+\&\|' option. Possible values of \c
+.I language\c
+\& are
+`\|\c
+.B c\c
+\&\|', `\|\c
+.B objective\-c\c
+\&\|', `\|\c
+.B c\-header\c
+\&\|', `\|\c
+.B c++\c
+\&\|',
+`\|\c
+.B cpp\-output\c
+\&\|', `\|\c
+.B assembler\c
+\&\|', and `\|\c
+.B assembler\-with\-cpp\c
+\&\|'.
+.TP
+.B \-x none
+Turn off any specification of a language, so that subsequent files are
+handled according to their file name suffixes (as they are if `\|\c
+.B \-x\c
+\&\|'
+has not been used at all).
+.PP
+
+If you want only some of the four stages (preprocess, compile,
+assemble, link), you can use
+`\|\c
+.B \-x\c
+\&\|' (or filename suffixes) to tell \c
+.B gcc\c
+\& where to start, and
+one of the options `\|\c
+.B \-c\c
+\&\|', `\|\c
+.B \-S\c
+\&\|', or `\|\c
+.B \-E\c
+\&\|' to say where
+\c
+.B gcc\c
+\& is to stop. Note that some combinations (for example,
+`\|\c
+.B \-x cpp\-output \-E\c
+\&\|') instruct \c
+.B gcc\c
+\& to do nothing at all.
+.TP
+.B \-c
+Compile or assemble the source files, but do not link. The compiler
+output is an object file corresponding to each source file.
+
+By default, GCC makes the object file name for a source file by replacing
+the suffix `\|\c
+.B .c\c
+\&\|', `\|\c
+.B .i\c
+\&\|', `\|\c
+.B .s\c
+\&\|', etc., with `\|\c
+.B .o\c
+\&\|'. Use
+.B \-o\c
+\& to select another name.
+
+GCC ignores any unrecognized input files (those that do not require
+compilation or assembly) with the
+.B \-c
+option.
+.TP
+.B \-S
+Stop after the stage of compilation proper; do not assemble. The output
+is an assembler code file for each non-assembler input
+file specified.
+
+By default, GCC makes the assembler file name for a source file by
+replacing the suffix `\|\c
+.B .c\c
+\&\|', `\|\c
+.B .i\c
+\&\|', etc., with `\|\c
+.B .s\c
+\&\|'. Use
+.B \-o\c
+\& to select another name.
+
+
+GCC ignores any input files that don't require compilation.
+.TP
+.B \-E
+Stop after the preprocessing stage; do not run the compiler proper. The
+output is preprocessed source code, which is sent to the
+standard output.
+
+GCC ignores input files which don't require preprocessing.
+.TP
+.BI "\-o " file\c
+\&
+Place output in file \c
+.I file\c
+\&. This applies regardless to whatever
+sort of output GCC is producing, whether it be an executable file,
+an object file, an assembler file or preprocessed C code.
+
+Since only one output file can be specified, it does not make sense to
+use `\|\c
+.B \-o\c
+\&\|' when compiling more than one input file, unless you are
+producing an executable file as output.
+
+If you do not specify `\|\c
+.B \-o\c
+\&\|', the default is to put an executable file
+in `\|\c
+.B a.out\c
+\&\|', the object file for `\|\c
+.B \c
+.I source\c
+\&.\c
+.I suffix\c
+\&\c
+\&\|' in
+`\|\c
+.B \c
+.I source\c
+\&.o\c
+\&\|', its assembler file in `\|\c
+.B \c
+.I source\c
+\&.s\c
+\&\|', and
+all preprocessed C source on standard output.
+.TP
+.B \-v
+Print (on standard error output) the commands executed to run the stages
+of compilation. Also print the version number of the compiler driver
+program and of the preprocessor and the compiler proper.
+.TP
+.B \-pipe
+Use pipes rather than temporary files for communication between the
+various stages of compilation. This fails to work on some systems where
+the assembler cannot read from a pipe; but the GNU assembler has
+no trouble.
+.PP
+
+.SH LANGUAGE OPTIONS
+The following options control the dialect of C that the compiler
+accepts:
+.TP
+.B \-ansi
+Support all ANSI standard C programs.
+
+This turns off certain features of GNU C that are incompatible with
+ANSI C, such as the \c
+.B asm\c
+\&, \c
+.B inline\c
+\& and \c
+.B typeof\c
+\&
+keywords, and predefined macros such as \c
+.B unix\c
+\& and \c
+.B vax\c
+\&
+that identify the type of system you are using. It also enables the
+undesirable and rarely used ANSI trigraph feature, and disallows `\|\c
+.B $\c
+\&\|' as part of identifiers.
+
+The alternate keywords \c
+.B __asm__\c
+\&, \c
+.B __extension__\c
+\&,
+\c
+.B __inline__\c
+\& and \c
+.B __typeof__\c
+\& continue to work despite
+`\|\c
+.B \-ansi\c
+\&\|'. You would not want to use them in an ANSI C program, of
+course, but it is useful to put them in header files that might be included
+in compilations done with `\|\c
+.B \-ansi\c
+\&\|'. Alternate predefined macros
+such as \c
+.B __unix__\c
+\& and \c
+.B __vax__\c
+\& are also available, with or
+without `\|\c
+.B \-ansi\c
+\&\|'.
+
+The `\|\c
+.B \-ansi\c
+\&\|' option does not cause non-ANSI programs to be
+rejected gratuitously. For that, `\|\c
+.B \-pedantic\c
+\&\|' is required in
+addition to `\|\c
+.B \-ansi\c
+\&\|'.
+
+The preprocessor predefines a macro \c
+.B __STRICT_ANSI__\c
+\& when you use the `\|\c
+.B \-ansi\c
+\&\|'
+option. Some header files may notice this macro and refrain
+from declaring certain functions or defining certain macros that the
+ANSI standard doesn't call for; this is to avoid interfering with any
+programs that might use these names for other things.
+.TP
+.B \-fno\-asm
+Do not recognize \c
+.B asm\c
+\&, \c
+.B inline\c
+\& or \c
+.B typeof\c
+\& as a
+keyword. These words may then be used as identifiers. You can
+use \c
+.B __asm__\c
+\&, \c
+.B __inline__\c
+\& and \c
+.B __typeof__\c
+\& instead.
+`\|\c
+.B \-ansi\c
+\&\|' implies `\|\c
+.B \-fno\-asm\c
+\&\|'.
+.TP
+.B \-fno\-builtin
+Don't recognize built-in functions that do not begin with two leading
+underscores. Currently, the functions affected include \c
+.B _exit\c
+\&,
+\c
+.B abort\c
+\&, \c
+.B abs\c
+\&, \c
+.B alloca\c
+\&, \c
+.B cos\c
+\&, \c
+.B exit\c
+\&,
+\c
+.B fabs\c
+\&, \c
+.B labs\c
+\&, \c
+.B memcmp\c
+\&, \c
+.B memcpy\c
+\&, \c
+.B sin\c
+\&,
+\c
+.B sqrt\c
+\&, \c
+.B strcmp\c
+\&, \c
+.B strcpy\c
+\&, and \c
+.B strlen\c
+\&.
+
+The `\|\c
+.B \-ansi\c
+\&\|' option prevents \c
+.B alloca\c
+\& and \c
+.B _exit\c
+\& from
+being builtin functions.
+.TP
+.B \-fno\-strict\-prototype
+Treat a function declaration with no arguments, such as `\|\c
+.B int foo
+();\c
+\&\|', as C would treat it\(em\&as saying nothing about the number of
+arguments or their types (C++ only). Normally, such a declaration in
+C++ means that the function \c
+.B foo\c
+\& takes no arguments.
+.TP
+.B \-trigraphs
+Support ANSI C trigraphs. The `\|\c
+.B \-ansi\c
+\&\|' option implies `\|\c
+.B \-trigraphs\c
+\&\|'.
+.TP
+.B \-traditional
+Attempt to support some aspects of traditional C compilers.
+For details, see the GNU C Manual; the duplicate list here
+has been deleted so that we won't get complaints when it
+is out of date.
+
+But one note about C++ programs only (not C). `\|\c
+.B \-traditional\c
+\&\|' has one additional effect for C++: assignment to
+.B this
+is permitted. This is the same as the effect of `\|\c
+.B \-fthis\-is\-variable\c
+\&\|'.
+.TP
+.B \-traditional\-cpp
+Attempt to support some aspects of traditional C preprocessors.
+This includes the items that specifically mention the preprocessor above,
+but none of the other effects of `\|\c
+.B \-traditional\c
+\&\|'.
+.TP
+.B \-fdollars\-in\-identifiers
+Permit the use of `\|\c
+.B $\c
+\&\|' in identifiers (C++ only). You can also use
+`\|\c
+.B \-fno\-dollars\-in\-identifiers\c
+\&\|' to explicitly prohibit use of
+`\|\c
+.B $\c
+\&\|'. (GNU C++ allows `\|\c
+.B $\c
+\&\|' by default on some target systems
+but not others.)
+.TP
+.B \-fenum\-int\-equiv
+Permit implicit conversion of \c
+.B int\c
+\& to enumeration types (C++
+only). Normally GNU C++ allows conversion of \c
+.B enum\c
+\& to \c
+.B int\c
+\&,
+but not the other way around.
+.TP
+.B \-fall\-virtual
+Treat all possible member functions as virtual, implicitly. All
+member functions (except for constructor functions and
+.B new
+or
+.B delete
+member operators) are treated as virtual functions of the class where
+they appear.
+
+This does not mean that all calls to these member functions will be
+made through the internal table of virtual functions. Under some
+circumstances, the compiler can determine that a call to a given
+virtual function can be made directly; in these cases the calls are
+direct in any case.
+.TP
+.B \-fcond\-mismatch
+Allow conditional expressions with mismatched types in the second and
+third arguments. The value of such an expression is void.
+.TP
+.B \-fthis\-is\-variable
+Permit assignment to \c
+.B this\c
+\& (C++ only). The incorporation of
+user-defined free store management into C++ has made assignment to
+`\|\c
+.B this\c
+\&\|' an anachronism. Therefore, by default it is invalid to
+assign to \c
+.B this\c
+\& within a class member function. However, for
+backwards compatibility, you can make it valid with
+`\|\c
+.B \-fthis-is-variable\c
+\&\|'.
+.TP
+.B \-funsigned\-char
+Let the type \c
+.B char\c
+\& be unsigned, like \c
+.B unsigned char\c
+\&.
+
+Each kind of machine has a default for what \c
+.B char\c
+\& should
+be. It is either like \c
+.B unsigned char\c
+\& by default or like
+\c
+.B signed char\c
+\& by default.
+
+Ideally, a portable program should always use \c
+.B signed char\c
+\& or
+\c
+.B unsigned char\c
+\& when it depends on the signedness of an object.
+But many programs have been written to use plain \c
+.B char\c
+\& and
+expect it to be signed, or expect it to be unsigned, depending on the
+machines they were written for. This option, and its inverse, let you
+make such a program work with the opposite default.
+
+The type \c
+.B char\c
+\& is always a distinct type from each of
+\c
+.B signed char\c
+\& and \c
+.B unsigned char\c
+\&, even though its behavior
+is always just like one of those two.
+
+.TP
+.B \-fsigned\-char
+Let the type \c
+.B char\c
+\& be signed, like \c
+.B signed char\c
+\&.
+
+Note that this is equivalent to `\|\c
+.B \-fno\-unsigned\-char\c
+\&\|', which is
+the negative form of `\|\c
+.B \-funsigned\-char\c
+\&\|'. Likewise,
+`\|\c
+.B \-fno\-signed\-char\c
+\&\|' is equivalent to `\|\c
+.B \-funsigned\-char\c
+\&\|'.
+.TP
+.B \-fsigned\-bitfields
+.TP
+.B \-funsigned\-bitfields
+.TP
+.B \-fno\-signed\-bitfields
+.TP
+.B \-fno\-unsigned\-bitfields
+These options control whether a bitfield is
+signed or unsigned, when declared with no explicit `\|\c
+.B signed\c
+\&\|' or `\|\c
+.B unsigned\c
+\&\|' qualifier. By default, such a bitfield is
+signed, because this is consistent: the basic integer types such as
+\c
+.B int\c
+\& are signed types.
+
+However, when you specify `\|\c
+.B \-traditional\c
+\&\|', bitfields are all unsigned
+no matter what.
+.TP
+.B \-fwritable\-strings
+Store string constants in the writable data segment and don't uniquize
+them. This is for compatibility with old programs which assume they
+can write into string constants. `\|\c
+.B \-traditional\c
+\&\|' also has this
+effect.
+
+Writing into string constants is a very bad idea; ``constants'' should
+be constant.
+.PP
+
+.SH PREPROCESSOR OPTIONS
+These options control the C preprocessor, which is run on each C source
+file before actual compilation.
+
+If you use the `\|\c
+.B \-E\c
+\&\|' option, GCC does nothing except preprocessing.
+Some of these options make sense only together with `\|\c
+.B \-E\c
+\&\|' because
+they cause the preprocessor output to be unsuitable for actual
+compilation.
+.TP
+.BI "\-include " "file"
+Process \c
+.I file\c
+\& as input before processing the regular input file.
+In effect, the contents of \c
+.I file\c
+\& are compiled first. Any `\|\c
+.B \-D\c
+\&\|'
+and `\|\c
+.B \-U\c
+\&\|' options on the command line are always processed before
+`\|\c
+.B \-include \c
+.I file\c
+\&\c
+\&\|', regardless of the order in which they are
+written. All the `\|\c
+.B \-include\c
+\&\|' and `\|\c
+.B \-imacros\c
+\&\|' options are
+processed in the order in which they are written.
+.TP
+.BI "\-imacros " file
+Process \c
+.I file\c
+\& as input, discarding the resulting output, before
+processing the regular input file. Because the output generated from
+\c
+.I file\c
+\& is discarded, the only effect of `\|\c
+.B \-imacros \c
+.I file\c
+\&\c
+\&\|' is to
+make the macros defined in \c
+.I file\c
+\& available for use in the main
+input. The preprocessor evaluates any `\|\c
+.B \-D\c
+\&\|' and `\|\c
+.B \-U\c
+\&\|' options
+on the command line before processing `\|\c
+.B \-imacros\c
+.I file\c
+\&\|', regardless of the order in
+which they are written. All the `\|\c
+.B \-include\c
+\&\|' and `\|\c
+.B \-imacros\c
+\&\|'
+options are processed in the order in which they are written.
+.TP
+.BI "-idirafter " "dir"\c
+\&
+Add the directory \c
+.I dir\c
+\& to the second include path. The directories
+on the second include path are searched when a header file is not found
+in any of the directories in the main include path (the one that
+`\|\c
+.B \-I\c
+\&\|' adds to).
+.TP
+.BI "-iprefix " "prefix"\c
+\&
+Specify \c
+.I prefix\c
+\& as the prefix for subsequent `\|\c
+.B \-iwithprefix\c
+\&\|'
+options.
+.TP
+.BI "-iwithprefix " "dir"\c
+\&
+Add a directory to the second include path. The directory's name is
+made by concatenating \c
+.I prefix\c
+\& and \c
+.I dir\c
+\&, where \c
+.I prefix\c
+\&
+was specified previously with `\|\c
+.B \-iprefix\c
+\&\|'.
+.TP
+.B \-nostdinc
+Do not search the standard system directories for header files. Only
+the directories you have specified with `\|\c
+.B \-I\c
+\&\|' options (and the
+current directory, if appropriate) are searched.
+
+By using both `\|\c
+.B \-nostdinc\c
+\&\|' and `\|\c
+.B \-I\-\c
+\&\|', you can limit the include-file search file to only those
+directories you specify explicitly.
+.TP
+.B \-nostdinc++
+Do not search for header files in the C++-specific standard directories,
+but do still search the other standard directories.
+(This option is used when building `\|\c
+.B libg++\c
+\&\|'.)
+.TP
+.B \-undef
+Do not predefine any nonstandard macros. (Including architecture flags).
+.TP
+.B \-E
+Run only the C preprocessor. Preprocess all the C source files
+specified and output the results to standard output or to the
+specified output file.
+.TP
+.B \-C
+Tell the preprocessor not to discard comments. Used with the
+`\|\c
+.B \-E\c
+\&\|' option.
+.TP
+.B \-P
+Tell the preprocessor not to generate `\|\c
+.B #line\c
+\&\|' commands.
+Used with the `\|\c
+.B \-E\c
+\&\|' option.
+.TP
+.B \-M
+Tell the preprocessor to output a rule suitable for \c
+.B make\c
+\&
+describing the dependencies of each object file. For each source file,
+the preprocessor outputs one \c
+.B make\c
+\&-rule whose target is the object
+file name for that source file and whose dependencies are all the files
+`\|\c
+.B #include\c
+\&\|'d in it. This rule may be a single line or may be
+continued with `\|\c
+.B \e\c
+\&\|'-newline if it is long. The list of rules is
+printed on standard output instead of the preprocessed C program.
+
+`\|\c
+.B \-M\c
+\&\|' implies `\|\c
+.B \-E\c
+\&\|'.
+.TP
+.B \-MM
+Like `\|\c
+.B \-M\c
+\&\|' but the output mentions only the user header files
+included with `\|\c
+.B #include "\c
+.I file\c
+\&"\c
+\&\|'. System header files
+included with `\|\c
+.B #include <\c
+.I file\c
+\&>\c
+\&\|' are omitted.
+.TP
+.B \-MD
+Like `\|\c
+.B \-M\c
+\&\|' but the dependency information is written to files with
+names made by replacing `\|\c
+.B .o\c
+\&\|' with `\|\c
+.B .d\c
+\&\|' at the end of the
+output file names. This is in addition to compiling the file as
+specified\(em\&`\|\c
+.B \-MD\c
+\&\|' does not inhibit ordinary compilation the way
+`\|\c
+.B \-M\c
+\&\|' does.
+
+The Mach utility `\|\c
+.B md\c
+\&\|' can be used to merge the `\|\c
+.B .d\c
+\&\|' files
+into a single dependency file suitable for using with the `\|\c
+.B make\c
+\&\|'
+command.
+.TP
+.B \-MMD
+Like `\|\c
+.B \-MD\c
+\&\|' except mention only user header files, not system
+header files.
+.TP
+.B \-H
+Print the name of each header file used, in addition to other normal
+activities.
+.TP
+.BI "-A" "question" ( answer )
+Assert the answer
+.I answer
+for
+.I question\c
+\&, in case it is tested
+with a preprocessor conditional such as `\|\c
+.BI "#if #" question ( answer )\c
+\&\|'. `\|\c
+.B \-A\-\c
+\&\|' disables the standard
+assertions that normally describe the target machine.
+.TP
+.BI "-A" "question"\c
+\&(\c
+.I answer\c
+\&)
+Assert the answer \c
+.I answer\c
+\& for \c
+.I question\c
+\&, in case it is tested
+with a preprocessor conditional such as `\|\c
+.B #if
+#\c
+.I question\c
+\&(\c
+.I answer\c
+\&)\c
+\&\|'. `\|\c
+.B \-A-\c
+\&\|' disables the standard
+assertions that normally describe the target machine.
+.TP
+.BI \-D macro
+Define macro \c
+.I macro\c
+\& with the string `\|\c
+.B 1\c
+\&\|' as its definition.
+.TP
+.BI \-D macro = defn
+Define macro \c
+.I macro\c
+\& as \c
+.I defn\c
+\&. All instances of `\|\c
+.B \-D\c
+\&\|' on
+the command line are processed before any `\|\c
+.B \-U\c
+\&\|' options.
+.TP
+.BI \-U macro
+Undefine macro \c
+.I macro\c
+\&. `\|\c
+.B \-U\c
+\&\|' options are evaluated after all `\|\c
+.B \-D\c
+\&\|' options, but before any `\|\c
+.B \-include\c
+\&\|' and `\|\c
+.B \-imacros\c
+\&\|' options.
+.TP
+.B \-dM
+Tell the preprocessor to output only a list of the macro definitions
+that are in effect at the end of preprocessing. Used with the `\|\c
+.B \-E\c
+\&\|'
+option.
+.TP
+.B \-dD
+Tell the preprocessor to pass all macro definitions into the output, in
+their proper sequence in the rest of the output.
+.TP
+.B \-dN
+Like `\|\c
+.B \-dD\c
+\&\|' except that the macro arguments and contents are omitted.
+Only `\|\c
+.B #define \c
+.I name\c
+\&\c
+\&\|' is included in the output.
+.PP
+
+.SH ASSEMBLER OPTION
+.TP
+.BI "-Wa," "option"\c
+\&
+Pass \c
+.I option\c
+\& as an option to the assembler. If \c
+.I option\c
+\&
+contains commas, it is split into multiple options at the commas.
+.PP
+
+.SH LINKER OPTIONS
+These options come into play when the compiler links object files into
+an executable output file. They are meaningless if the compiler is
+not doing a link step.
+.TP
+.I object-file-name
+A file name that does not end in a special recognized suffix is
+considered to name an object file or library. (Object files are
+distinguished from libraries by the linker according to the file
+contents.) If GCC does a link step, these object files are used as input
+to the linker.
+.TP
+.BI \-l library\c
+\&
+Use the library named \c
+.I library\c
+\& when linking.
+
+The linker searches a standard list of directories for the library,
+which is actually a file named `\|\c
+.B lib\c
+.I library\c
+\&.a\c
+\&\|'. The linker
+then uses this file as if it had been specified precisely by name.
+
+The directories searched include several standard system directories
+plus any that you specify with `\|\c
+.B \-L\c
+\&\|'.
+
+Normally the files found this way are library files\(em\&archive files
+whose members are object files. The linker handles an archive file by
+scanning through it for members which define symbols that have so far
+been referenced but not defined. However, if the linker finds an
+ordinary object file rather than a library, the object file is linked
+in the usual fashion. The only difference between using an `\|\c
+.B \-l\c
+\&\|' option and specifying a file
+name is that `\|\c
+.B \-l\c
+\&\|' surrounds
+.I library
+with `\|\c
+.B lib\c
+\&\|' and `\|\c
+.B .a\c
+\&\|' and searches several directories.
+.TP
+.B \-lobjc
+You need this special case of the
+.B \-l
+option in order to link an Objective C program.
+.TP
+.B \-nostartfiles
+Do not use the standard system startup files when linking.
+The standard libraries are used normally.
+.TP
+.B \-nostdlib
+Don't use the standard system libraries and startup files when linking.
+Only the files you specify will be passed to the linker.
+.TP
+.B \-static
+On systems that support dynamic linking, this prevents linking with the shared
+libraries. On other systems, this option has no effect.
+.TP
+.B \-shared
+Produce a shared object which can then be linked with other objects to
+form an executable. Only a few systems support this option.
+.TP
+.B \-symbolic
+Bind references to global symbols when building a shared object. Warn
+about any unresolved references (unless overridden by the link editor
+option `\|\c
+.B
+\-Xlinker \-z \-Xlinker defs\c
+\&\|'). Only a few systems support
+this option.
+.TP
+.BI "-Xlinker " "option"
+Pass \c
+.I option
+as an option to the linker. You can use this to
+supply system-specific linker options which GNU CC does not know how to
+recognize.
+
+If you want to pass an option that takes an argument, you must use
+`\|\c
+.B \-Xlinker\c
+\&\|' twice, once for the option and once for the argument.
+For example, to pass `\|\c
+.B
+\-assert definitions\c
+\&\|', you must write
+`\|\c
+.B
+\-Xlinker \-assert \-Xlinker definitions\c
+\&\|'. It does not work to write
+`\|\c
+.B
+\-Xlinker "-assert definitions"\c
+\&\|', because this passes the entire
+string as a single argument, which is not what the linker expects.
+.TP
+.BI "-Wl," "option"\c
+\&
+Pass \c
+.I option\c
+\& as an option to the linker. If \c
+.I option\c
+\& contains
+commas, it is split into multiple options at the commas.
+.TP
+.BI "-u " "symbol"
+Pretend the symbol
+.I symbol
+is undefined, to force linking of
+library modules to define it. You can use `\|\c
+.B \-u\c
+\&\|' multiple times with
+different symbols to force loading of additional library modules.
+.PP
+
+.SH DIRECTORY OPTIONS
+These options specify directories to search for header files, for
+libraries and for parts of the compiler:
+.TP
+.BI "\-I" "dir"\c
+\&
+Append directory \c
+.I dir\c
+\& to the list of directories searched for include files.
+.TP
+.B \-I\-
+Any directories you specify with `\|\c
+.B \-I\c
+\&\|' options before the `\|\c
+.B \-I\-\c
+\&\|'
+option are searched only for the case of `\|\c
+.B
+#include "\c
+.I file\c
+.B
+\&"\c
+\&\|';
+they are not searched for `\|\c
+.B #include <\c
+.I file\c
+\&>\c
+\&\|'.
+
+If additional directories are specified with `\|\c
+.B \-I\c
+\&\|' options after
+the `\|\c
+.B \-I\-\c
+\&\|', these directories are searched for all `\|\c
+.B #include\c
+\&\|'
+directives. (Ordinarily \c
+.I all\c
+\& `\|\c
+.B \-I\c
+\&\|' directories are used
+this way.)
+
+In addition, the `\|\c
+.B \-I\-\c
+\&\|' option inhibits the use of the current
+directory (where the current input file came from) as the first search
+directory for `\|\c
+.B
+#include "\c
+.I file\c
+.B
+\&"\c
+\&\|'. There is no way to
+override this effect of `\|\c
+.B \-I\-\c
+\&\|'. With `\|\c
+.B \-I.\c
+\&\|' you can specify
+searching the directory which was current when the compiler was
+invoked. That is not exactly the same as what the preprocessor does
+by default, but it is often satisfactory.
+
+`\|\c
+.B \-I\-\c
+\&\|' does not inhibit the use of the standard system directories
+for header files. Thus, `\|\c
+.B \-I\-\c
+\&\|' and `\|\c
+.B \-nostdinc\c
+\&\|' are
+independent.
+.TP
+.BI "\-L" "dir"\c
+\&
+Add directory \c
+.I dir\c
+\& to the list of directories to be searched
+for `\|\c
+.B \-l\c
+\&\|'.
+.TP
+.BI "\-B" "prefix"\c
+\&
+This option specifies where to find the executables, libraries and
+data files of the compiler itself.
+
+The compiler driver program runs one or more of the subprograms
+`\|\c
+.B cpp\c
+\&\|', `\|\c
+.B cc1\c
+\&\|' (or, for C++, `\|\c
+.B cc1plus\c
+\&\|'), `\|\c
+.B as\c
+\&\|' and `\|\c
+.B ld\c
+\&\|'. It tries
+\c
+.I prefix\c
+\& as a prefix for each program it tries to run, both with and
+without `\|\c
+.B \c
+.I machine\c
+\&/\c
+.I version\c
+\&/\c
+\&\|'.
+
+For each subprogram to be run, the compiler driver first tries the
+`\|\c
+.B \-B\c
+\&\|' prefix, if any. If that name is not found, or if `\|\c
+.B \-B\c
+\&\|'
+was not specified, the driver tries two standard prefixes, which are
+`\|\c
+.B /usr/lib/gcc/\c
+\&\|' and `\|\c
+.B /usr/local/lib/gcc-lib/\c
+\&\|'. If neither of
+those results in a file name that is found, the compiler driver
+searches for the unmodified program
+name, using the directories specified in your
+`\|\c
+.B PATH\c
+\&\|' environment variable.
+
+The run-time support file `\|\c
+.B libgcc.a\c
+\&\|' is also searched for using the
+`\|\c
+.B \-B\c
+\&\|' prefix, if needed. If it is not found there, the two
+standard prefixes above are tried, and that is all. The file is left
+out of the link if it is not found by those means. Most of the time,
+on most machines, `\|\c
+.B libgcc.a\c
+\&\|' is not actually necessary.
+
+You can get a similar result from the environment variable
+\c
+.B GCC_EXEC_PREFIX\c
+\&; if it is defined, its value is used as a prefix
+in the same way. If both the `\|\c
+.B \-B\c
+\&\|' option and the
+\c
+.B GCC_EXEC_PREFIX\c
+\& variable are present, the `\|\c
+.B \-B\c
+\&\|' option is
+used first and the environment variable value second.
+.PP
+
+.SH WARNING OPTIONS
+Warnings are diagnostic messages that report constructions which
+are not inherently erroneous but which are risky or suggest there
+may have been an error.
+
+These options control the amount and kinds of warnings produced by GNU
+CC:
+.TP
+.B \-fsyntax\-only
+Check the code for syntax errors, but don't emit any output.
+.TP
+.B \-w
+Inhibit all warning messages.
+.TP
+.B \-Wno\-import
+Inhibit warning messages about the use of
+.BR #import .
+.TP
+.B \-pedantic
+Issue all the warnings demanded by strict ANSI standard C; reject
+all programs that use forbidden extensions.
+
+Valid ANSI standard C programs should compile properly with or without
+this option (though a rare few will require `\|\c
+.B \-ansi\c
+\&\|'). However,
+without this option, certain GNU extensions and traditional C features
+are supported as well. With this option, they are rejected. There is
+no reason to \c
+.I use\c
+\& this option; it exists only to satisfy pedants.
+
+`\|\c
+.B \-pedantic\c
+\&\|' does not cause warning messages for use of the
+alternate keywords whose names begin and end with `\|\c
+.B __\c
+\&\|'. Pedantic
+warnings are also disabled in the expression that follows
+\c
+.B __extension__\c
+\&. However, only system header files should use
+these escape routes; application programs should avoid them.
+.TP
+.B \-pedantic\-errors
+Like `\|\c
+.B \-pedantic\c
+\&\|', except that errors are produced rather than
+warnings.
+.TP
+.B \-W
+Print extra warning messages for these events:
+.TP
+\ \ \ \(bu
+A nonvolatile automatic variable might be changed by a call to
+\c
+.B longjmp\c
+\&. These warnings are possible only in
+optimizing compilation.
+
+The compiler sees only the calls to \c
+.B setjmp\c
+\&. It cannot know
+where \c
+.B longjmp\c
+\& will be called; in fact, a signal handler could
+call it at any point in the code. As a result, you may get a warning
+even when there is in fact no problem because \c
+.B longjmp\c
+\& cannot
+in fact be called at the place which would cause a problem.
+.TP
+\ \ \ \(bu
+A function can return either with or without a value. (Falling
+off the end of the function body is considered returning without
+a value.) For example, this function would evoke such a
+warning:
+.sp
+.br
+foo\ (a)
+.br
+{
+.br
+\ \ if\ (a\ >\ 0)
+.br
+\ \ \ \ return\ a;
+.br
+}
+.br
+.sp
+
+Spurious warnings can occur because GNU CC does not realize that
+certain functions (including \c
+.B abort\c
+\& and \c
+.B longjmp\c
+\&)
+will never return.
+.TP
+\ \ \ \(bu
+An expression-statement contains no side effects.
+.TP
+\ \ \ \(bu
+An unsigned value is compared against zero with `\|\c
+.B >\c
+\&\|' or `\|\c
+.B <=\c
+\&\|'.
+.PP
+.TP
+.B \-Wimplicit
+Warn whenever a function or parameter is implicitly declared.
+.TP
+.B \-Wreturn\-type
+Warn whenever a function is defined with a return-type that defaults
+to \c
+.B int\c
+\&. Also warn about any \c
+.B return\c
+\& statement with no
+return-value in a function whose return-type is not \c
+.B void\c
+\&.
+.TP
+.B \-Wunused
+Warn whenever a local variable is unused aside from its declaration,
+whenever a function is declared static but never defined, and whenever
+a statement computes a result that is explicitly not used.
+.TP
+.B \-Wswitch
+Warn whenever a \c
+.B switch\c
+\& statement has an index of enumeral type
+and lacks a \c
+.B case\c
+\& for one or more of the named codes of that
+enumeration. (The presence of a \c
+.B default\c
+\& label prevents this
+warning.) \c
+.B case\c
+\& labels outside the enumeration range also
+provoke warnings when this option is used.
+.TP
+.B \-Wcomment
+Warn whenever a comment-start sequence `\|\c
+.B /*\c
+\&\|' appears in a comment.
+.TP
+.B \-Wtrigraphs
+Warn if any trigraphs are encountered (assuming they are enabled).
+.TP
+.B \-Wformat
+Check calls to \c
+.B printf\c
+\& and \c
+.B scanf\c
+\&, etc., to make sure that
+the arguments supplied have types appropriate to the format string
+specified.
+.TP
+.B \-Wchar\-subscripts
+Warn if an array subscript has type
+.BR char .
+This is a common cause of error, as programmers often forget that this
+type is signed on some machines.
+.TP
+.B \-Wuninitialized
+An automatic variable is used without first being initialized.
+
+These warnings are possible only in optimizing compilation,
+because they require data flow information that is computed only
+when optimizing. If you don't specify `\|\c
+.B \-O\c
+\&\|', you simply won't
+get these warnings.
+
+These warnings occur only for variables that are candidates for
+register allocation. Therefore, they do not occur for a variable that
+is declared \c
+.B volatile\c
+\&, or whose address is taken, or whose size
+is other than 1, 2, 4 or 8 bytes. Also, they do not occur for
+structures, unions or arrays, even when they are in registers.
+
+Note that there may be no warning about a variable that is used only
+to compute a value that itself is never used, because such
+computations may be deleted by data flow analysis before the warnings
+are printed.
+
+These warnings are made optional because GNU CC is not smart
+enough to see all the reasons why the code might be correct
+despite appearing to have an error. Here is one example of how
+this can happen:
+
+.sp
+.br
+{
+.br
+\ \ int\ x;
+.br
+\ \ switch\ (y)
+.br
+\ \ \ \ {
+.br
+\ \ \ \ case\ 1:\ x\ =\ 1;
+.br
+\ \ \ \ \ \ break;
+.br
+\ \ \ \ case\ 2:\ x\ =\ 4;
+.br
+\ \ \ \ \ \ break;
+.br
+\ \ \ \ case\ 3:\ x\ =\ 5;
+.br
+\ \ \ \ }
+.br
+\ \ foo\ (x);
+.br
+}
+.br
+.sp
+
+
+If the value of \c
+.B y\c
+\& is always 1, 2 or 3, then \c
+.B x\c
+\& is
+always initialized, but GNU CC doesn't know this. Here is
+another common case:
+
+.sp
+.br
+{
+.br
+\ \ int\ save_y;
+.br
+\ \ if\ (change_y)\ save_y\ =\ y,\ y\ =\ new_y;
+.br
+\ \ .\|.\|.
+.br
+\ \ if\ (change_y)\ y\ =\ save_y;
+.br
+}
+.br
+.sp
+
+
+This has no bug because \c
+.B save_y\c
+\& is used only if it is set.
+
+Some spurious warnings can be avoided if you declare as
+\c
+.B volatile\c
+\& all the functions you use that never return.
+.TP
+.B \-Wparentheses
+Warn if parentheses are omitted in certain contexts.
+.TP
+.B \-Wtemplate\-debugging
+When using templates in a C++ program, warn if debugging is not yet
+fully available (C++ only).
+.TP
+.B \-Wall
+All of the above `\|\c
+.B \-W\c
+\&\|' options combined. These are all the
+options which pertain to usage that we recommend avoiding and that we
+believe is easy to avoid, even in conjunction with macros.
+.PP
+
+The remaining `\|\c
+.B \-W.\|.\|.\c
+\&\|' options are not implied by `\|\c
+.B \-Wall\c
+\&\|'
+because they warn about constructions that we consider reasonable to
+use, on occasion, in clean programs.
+.TP
+.B \-Wtraditional
+Warn about certain constructs that behave differently in traditional and
+ANSI C.
+.TP
+\ \ \ \(bu
+Macro arguments occurring within string constants in the macro body.
+These would substitute the argument in traditional C, but are part of
+the constant in ANSI C.
+.TP
+\ \ \ \(bu
+A function declared external in one block and then used after the end of
+the block.
+.TP
+\ \ \ \(bu
+A \c
+.B switch\c
+\& statement has an operand of type \c
+.B long\c
+\&.
+.PP
+.TP
+.B \-Wshadow
+Warn whenever a local variable shadows another local variable.
+.TP
+.BI "\-Wid\-clash\-" "len"\c
+\&
+Warn whenever two distinct identifiers match in the first \c
+.I len\c
+\&
+characters. This may help you prepare a program that will compile
+with certain obsolete, brain-damaged compilers.
+.TP
+.B \-Wpointer\-arith
+Warn about anything that depends on the ``size of'' a function type or
+of \c
+.B void\c
+\&. GNU C assigns these types a size of 1, for
+convenience in calculations with \c
+.B void *\c
+\& pointers and pointers
+to functions.
+.TP
+.B \-Wcast\-qual
+Warn whenever a pointer is cast so as to remove a type qualifier from
+the target type. For example, warn if a \c
+.B const char *\c
+\& is cast
+to an ordinary \c
+.B char *\c
+\&.
+.TP
+.B \-Wcast\-align
+Warn whenever a pointer is cast such that the required alignment of the
+target is increased. For example, warn if a \c
+.B char *\c
+\& is cast to
+an \c
+.B int *\c
+\& on machines where integers can only be accessed at
+two- or four-byte boundaries.
+.TP
+.B \-Wwrite\-strings
+Give string constants the type \c
+.B const char[\c
+.I length\c
+\&]\c
+\& so that
+copying the address of one into a non-\c
+.B const\c
+\& \c
+.B char *\c
+\&
+pointer will get a warning. These warnings will help you find at
+compile time code that can try to write into a string constant, but
+only if you have been very careful about using \c
+.B const\c
+\& in
+declarations and prototypes. Otherwise, it will just be a nuisance;
+this is why we did not make `\|\c
+.B \-Wall\c
+\&\|' request these warnings.
+.TP
+.B \-Wconversion
+Warn if a prototype causes a type conversion that is different from what
+would happen to the same argument in the absence of a prototype. This
+includes conversions of fixed point to floating and vice versa, and
+conversions changing the width or signedness of a fixed point argument
+except when the same as the default promotion.
+.TP
+.B \-Waggregate\-return
+Warn if any functions that return structures or unions are defined or
+called. (In languages where you can return an array, this also elicits
+a warning.)
+.TP
+.B \-Wstrict\-prototypes
+Warn if a function is declared or defined without specifying the
+argument types. (An old-style function definition is permitted without
+a warning if preceded by a declaration which specifies the argument
+types.)
+.TP
+.B \-Wmissing\-prototypes
+Warn if a global function is defined without a previous prototype
+declaration. This warning is issued even if the definition itself
+provides a prototype. The aim is to detect global functions that fail
+to be declared in header files.
+.TP
+.B \-Wredundant-decls
+Warn if anything is declared more than once in the same scope, even in
+cases where multiple declaration is valid and changes nothing.
+.TP
+.B \-Wnested-externs
+Warn if an \c
+.B extern\c
+\& declaration is encountered within an function.
+.TP
+.B \-Wenum\-clash
+Warn about conversion between different enumeration types (C++ only).
+.TP
+.B \-Woverloaded\-virtual
+(C++ only.)
+In a derived class, the definitions of virtual functions must match
+the type signature of a virtual function declared in the base class.
+Use this option to request warnings when a derived class declares a
+function that may be an erroneous attempt to define a virtual
+function: that is, warn when a function with the same name as a
+virtual function in the base class, but with a type signature that
+doesn't match any virtual functions from the base class.
+.TP
+.B \-Winline
+Warn if a function can not be inlined, and either it was declared as inline,
+or else the
+.B \-finline\-functions
+option was given.
+.TP
+.B \-Werror
+Treat warnings as errors; abort compilation after any warning.
+.PP
+
+.SH DEBUGGING OPTIONS
+GNU CC has various special options that are used for debugging
+either your program or GCC:
+.TP
+.B \-g
+Produce debugging information in the operating system's native format
+(stabs, COFF, XCOFF, or DWARF). GDB can work with this debugging
+information.
+
+On most systems that use stabs format, `\|\c
+.B \-g\c
+\&\|' enables use of extra
+debugging information that only GDB can use; this extra information
+makes debugging work better in GDB but will probably make other debuggers
+crash or
+refuse to read the program. If you want to control for certain whether
+to generate the extra information, use `\|\c
+.B \-gstabs+\c
+\&\|', `\|\c
+.B \-gstabs\c
+\&\|',
+`\|\c
+.B \-gxcoff+\c
+\&\|', `\|\c
+.B \-gxcoff\c
+\&\|', `\|\c
+.B \-gdwarf+\c
+\&\|', or `\|\c
+.B \-gdwarf\c
+\&\|'
+(see below).
+
+Unlike most other C compilers, GNU CC allows you to use `\|\c
+.B \-g\c
+\&\|' with
+`\|\c
+.B \-O\c
+\&\|'. The shortcuts taken by optimized code may occasionally
+produce surprising results: some variables you declared may not exist
+at all; flow of control may briefly move where you did not expect it;
+some statements may not be executed because they compute constant
+results or their values were already at hand; some statements may
+execute in different places because they were moved out of loops.
+
+Nevertheless it proves possible to debug optimized output. This makes
+it reasonable to use the optimizer for programs that might have bugs.
+
+The following options are useful when GNU CC is generated with the
+capability for more than one debugging format.
+.TP
+.B \-ggdb
+Produce debugging information in the native format (if that is supported),
+including GDB extensions if at all possible.
+.TP
+.B \-gstabs
+Produce debugging information in stabs format (if that is supported),
+without GDB extensions. This is the format used by DBX on most BSD
+systems.
+.TP
+.B \-gstabs+
+Produce debugging information in stabs format (if that is supported),
+using GNU extensions understood only by the GNU debugger (GDB). The
+use of these extensions is likely to make other debuggers crash or
+refuse to read the program.
+.TP
+.B \-gcoff
+Produce debugging information in COFF format (if that is supported).
+This is the format used by SDB on most System V systems prior to
+System V Release 4.
+.TP
+.B \-gxcoff
+Produce debugging information in XCOFF format (if that is supported).
+This is the format used by the DBX debugger on IBM RS/6000 systems.
+.TP
+.B \-gxcoff+
+Produce debugging information in XCOFF format (if that is supported),
+using GNU extensions understood only by the GNU debugger (GDB). The
+use of these extensions is likely to make other debuggers crash or
+refuse to read the program.
+.TP
+.B \-gdwarf
+Produce debugging information in DWARF format (if that is supported).
+This is the format used by SDB on most System V Release 4 systems.
+.TP
+.B \-gdwarf+
+Produce debugging information in DWARF format (if that is supported),
+using GNU extensions understood only by the GNU debugger (GDB). The
+use of these extensions is likely to make other debuggers crash or
+refuse to read the program.
+.PP
+.BI "\-g" "level"
+.br
+.BI "\-ggdb" "level"
+.br
+.BI "\-gstabs" "level"
+.br
+.BI "\-gcoff" "level"
+.BI "\-gxcoff" "level"
+.TP
+.BI "\-gdwarf" "level"
+Request debugging information and also use \c
+.I level\c
+\& to specify how
+much information. The default level is 2.
+
+Level 1 produces minimal information, enough for making backtraces in
+parts of the program that you don't plan to debug. This includes
+descriptions of functions and external variables, but no information
+about local variables and no line numbers.
+
+Level 3 includes extra information, such as all the macro definitions
+present in the program. Some debuggers support macro expansion when
+you use `\|\c
+.B \-g3\c
+\&\|'.
+.TP
+.B \-p
+Generate extra code to write profile information suitable for the
+analysis program \c
+.B prof\c
+\&.
+.TP
+.B \-pg
+Generate extra code to write profile information suitable for the
+analysis program \c
+.B gprof\c
+\&.
+.TP
+.B \-a
+Generate extra code to write profile information for basic blocks,
+which will record the number of times each basic block is executed.
+This data could be analyzed by a program like \c
+.B tcov\c
+\&. Note,
+however, that the format of the data is not what \c
+.B tcov\c
+\& expects.
+Eventually GNU \c
+.B gprof\c
+\& should be extended to process this data.
+.TP
+.BI "\-d" "letters"\c
+\&
+Says to make debugging dumps during compilation at times specified by
+\c
+.I letters\c
+\&. This is used for debugging the compiler. The file names
+for most of the dumps are made by appending a word to the source file
+name (e.g. `\|\c
+.B foo.c.rtl\c
+\&\|' or `\|\c
+.B foo.c.jump\c
+\&\|').
+.TP
+.B \-dM
+Dump all macro definitions, at the end of preprocessing, and write no
+output.
+.TP
+.B \-dN
+Dump all macro names, at the end of preprocessing.
+.TP
+.B \-dD
+Dump all macro definitions, at the end of preprocessing, in addition to
+normal output.
+.TP
+.B \-dy
+Dump debugging information during parsing, to standard error.
+.TP
+.B \-dr
+Dump after RTL generation, to `\|\c
+.B \c
+.I file\c
+\&.rtl\c
+\&\|'.
+.TP
+.B \-dx
+Just generate RTL for a function instead of compiling it. Usually used
+with `\|\c
+.B r\c
+\&\|'.
+.TP
+.B \-dj
+Dump after first jump optimization, to `\|\c
+.B \c
+.I file\c
+\&.jump\c
+\&\|'.
+.TP
+.B \-ds
+Dump after CSE (including the jump optimization that sometimes
+follows CSE), to `\|\c
+.B \c
+.I file\c
+\&.cse\c
+\&\|'.
+.TP
+.B \-dL
+Dump after loop optimization, to `\|\c
+.B \c
+.I file\c
+\&.loop\c
+\&\|'.
+.TP
+.B \-dt
+Dump after the second CSE pass (including the jump optimization that
+sometimes follows CSE), to `\|\c
+.B \c
+.I file\c
+\&.cse2\c
+\&\|'.
+.TP
+.B \-df
+Dump after flow analysis, to `\|\c
+.B \c
+.I file\c
+\&.flow\c
+\&\|'.
+.TP
+.B \-dc
+Dump after instruction combination, to `\|\c
+.B \c
+.I file\c
+\&.combine\c
+\&\|'.
+.TP
+.B \-dS
+Dump after the first instruction scheduling pass, to
+`\|\c
+.B \c
+.I file\c
+\&.sched\c
+\&\|'.
+.TP
+.B \-dl
+Dump after local register allocation, to `\|\c
+.B \c
+.I file\c
+\&.lreg\c
+\&\|'.
+.TP
+.B \-dg
+Dump after global register allocation, to `\|\c
+.B \c
+.I file\c
+\&.greg\c
+\&\|'.
+.TP
+.B \-dR
+Dump after the second instruction scheduling pass, to
+`\|\c
+.B \c
+.I file\c
+\&.sched2\c
+\&\|'.
+.TP
+.B \-dJ
+Dump after last jump optimization, to `\|\c
+.B \c
+.I file\c
+\&.jump2\c
+\&\|'.
+.TP
+.B \-dd
+Dump after delayed branch scheduling, to `\|\c
+.B \c
+.I file\c
+\&.dbr\c
+\&\|'.
+.TP
+.B \-dk
+Dump after conversion from registers to stack, to `\|\c
+.B \c
+.I file\c
+\&.stack\c
+\&\|'.
+.TP
+.B \-da
+Produce all the dumps listed above.
+.TP
+.B \-dm
+Print statistics on memory usage, at the end of the run, to
+standard error.
+.TP
+.B \-dp
+Annotate the assembler output with a comment indicating which
+pattern and alternative was used.
+.TP
+.B \-fpretend\-float
+When running a cross-compiler, pretend that the target machine uses the
+same floating point format as the host machine. This causes incorrect
+output of the actual floating constants, but the actual instruction
+sequence will probably be the same as GNU CC would make when running on
+the target machine.
+.TP
+.B \-save\-temps
+Store the usual ``temporary'' intermediate files permanently; place them
+in the current directory and name them based on the source file. Thus,
+compiling `\|\c
+.B foo.c\c
+\&\|' with `\|\c
+.B \-c \-save\-temps\c
+\&\|' would produce files
+`\|\c
+.B foo.cpp\c
+\&\|' and `\|\c
+.B foo.s\c
+\&\|', as well as `\|\c
+.B foo.o\c
+\&\|'.
+.TP
+.B \-print\-libgcc\-file\-name
+Print the full absolute name of the library file `\|\c
+.B libgcc.a\c
+\&\|' that
+would be used when linking\(em\&and do not do anything else. With this
+option, GNU CC does not compile or link anything; it just prints the
+file name.
+.PP
+
+.SH OPTIMIZATION OPTIONS
+These options control various sorts of optimizations:
+.PP
+.B \-O
+.TP
+.B \-O1
+Optimize. Optimizing compilation takes somewhat more time, and a lot
+more memory for a large function.
+
+Without `\|\c
+.B \-O\c
+\&\|', the compiler's goal is to reduce the cost of
+compilation and to make debugging produce the expected results.
+Statements are independent: if you stop the program with a breakpoint
+between statements, you can then assign a new value to any variable or
+change the program counter to any other statement in the function and
+get exactly the results you would expect from the source code.
+
+Without `\|\c
+.B \-O\c
+\&\|', only variables declared \c
+.B register\c
+\& are
+allocated in registers. The resulting compiled code is a little worse
+than produced by PCC without `\|\c
+.B \-O\c
+\&\|'.
+
+With `\|\c
+.B \-O\c
+\&\|', the compiler tries to reduce code size and execution
+time.
+
+When you specify `\|\c
+.B \-O\c
+\&\|', `\|\c
+.B \-fthread\-jumps\c
+\&\|' and
+`\|\c
+.B \-fdelayed\-branch\c
+\&\|' are turned on. On some machines other
+flags may also be turned on.
+.TP
+.B \-O2
+Optimize even more. Nearly all supported optimizations that do not
+involve a space-speed tradeoff are performed. As compared to
+.B \-O\c
+\&,
+this option increases both compilation time and the performance of the
+generated code.
+
+.B \-O2
+turns on all
+.BI \-f flag
+options that enable more optimization, except for
+.B \-funroll\-loops\c
+\&,
+.B \-funroll\-all\-loops
+and
+.BR \-fomit\-frame\-pointer .
+.TP
+.B \-O0
+Do not optimize.
+
+If you use multiple
+.B \-O
+options, with or without level numbers, the last such option is the
+one that is effective.
+.PP
+
+Options of the form `\|\c
+.B \-f\c
+.I flag\c
+\&\c
+\&\|' specify machine-independent
+flags. Most flags have both positive and negative forms; the negative
+form of `\|\c
+.B \-ffoo\c
+\&\|' would be `\|\c
+.B \-fno\-foo\c
+\&\|'. The following list shows
+only one form\(em\&the one which is not the default.
+You can figure out the other form by either removing `\|\c
+.B no\-\c
+\&\|' or
+adding it.
+.TP
+.B \-ffloat\-store
+Do not store floating point variables in registers. This
+prevents undesirable excess precision on machines such as the
+68000 where the floating registers (of the 68881) keep more
+precision than a \c
+.B double\c
+\& is supposed to have.
+
+For most programs, the excess precision does only good, but a few
+programs rely on the precise definition of IEEE floating point.
+Use `\|\c
+.B \-ffloat\-store\c
+\&\|' for such programs.
+.TP
+.B \-fmemoize\-lookups
+.TP
+.B \-fsave\-memoized
+Use heuristics to compile faster (C++ only). These heuristics are not
+enabled by default, since they are only effective for certain input
+files. Other input files compile more slowly.
+
+The first time the compiler must build a call to a member function (or
+reference to a data member), it must (1) determine whether the class
+implements member functions of that name; (2) resolve which member
+function to call (which involves figuring out what sorts of type
+conversions need to be made); and (3) check the visibility of the member
+function to the caller. All of this adds up to slower compilation.
+Normally, the second time a call is made to that member function (or
+reference to that data member), it must go through the same lengthy
+process again. This means that code like this
+.sp
+.br
+cout\ <<\ "This\ "\ <<\ p\ <<\ "\ has\ "\ <<\ n\ <<\ "\ legs.\en";
+.br
+.sp
+makes six passes through all three steps. By using a software cache,
+a ``hit'' significantly reduces this cost. Unfortunately, using the
+cache introduces another layer of mechanisms which must be implemented,
+and so incurs its own overhead. `\|\c
+.B \-fmemoize\-lookups\c
+\&\|' enables
+the software cache.
+
+Because access privileges (visibility) to members and member functions
+may differ from one function context to the next,
+.B g++
+may need to flush the cache. With the `\|\c
+.B \-fmemoize\-lookups\c
+\&\|' flag, the cache is flushed after every
+function that is compiled. The `\|\c
+\-fsave\-memoized\c
+\&\|' flag enables the same software cache, but when the compiler
+determines that the context of the last function compiled would yield
+the same access privileges of the next function to compile, it
+preserves the cache.
+This is most helpful when defining many member functions for the same
+class: with the exception of member functions which are friends of
+other classes, each member function has exactly the same access
+privileges as every other, and the cache need not be flushed.
+.TP
+.B \-fno\-default\-inline
+Don't make member functions inline by default merely because they are
+defined inside the class scope (C++ only).
+.TP
+.B \-fno\-defer\-pop
+Always pop the arguments to each function call as soon as that
+function returns. For machines which must pop arguments after a
+function call, the compiler normally lets arguments accumulate on the
+stack for several function calls and pops them all at once.
+.TP
+.B \-fforce\-mem
+Force memory operands to be copied into registers before doing
+arithmetic on them. This may produce better code by making all
+memory references potential common subexpressions. When they are
+not common subexpressions, instruction combination should
+eliminate the separate register-load. I am interested in hearing
+about the difference this makes.
+.TP
+.B \-fforce\-addr
+Force memory address constants to be copied into registers before
+doing arithmetic on them. This may produce better code just as
+`\|\c
+.B \-fforce\-mem\c
+\&\|' may. I am interested in hearing about the
+difference this makes.
+.TP
+.B \-fomit\-frame\-pointer
+Don't keep the frame pointer in a register for functions that
+don't need one. This avoids the instructions to save, set up and
+restore frame pointers; it also makes an extra register available
+in many functions. \c
+.I It also makes debugging impossible on
+most machines.\c
+\&
+
+On some machines, such as the Vax, this flag has no effect, because
+the standard calling sequence automatically handles the frame pointer
+and nothing is saved by pretending it doesn't exist. The
+machine-description macro \c
+.B FRAME_POINTER_REQUIRED\c
+\& controls
+whether a target machine supports this flag.
+.TP
+.B \-finline\-functions
+Integrate all simple functions into their callers. The compiler
+heuristically decides which functions are simple enough to be worth
+integrating in this way.
+
+If all calls to a given function are integrated, and the function is
+declared \c
+.B static\c
+\&, then GCC normally does not output the function as
+assembler code in its own right.
+.TP
+.B \-fcaller\-saves
+Enable values to be allocated in registers that will be clobbered by
+function calls, by emitting extra instructions to save and restore the
+registers around such calls. Such allocation is done only when it
+seems to result in better code than would otherwise be produced.
+
+This option is enabled by default on certain machines, usually those
+which have no call-preserved registers to use instead.
+.TP
+.B \-fkeep\-inline\-functions
+Even if all calls to a given function are integrated, and the function
+is declared \c
+.B static\c
+\&, nevertheless output a separate run-time
+callable version of the function.
+.TP
+.B \-fno\-function\-cse
+Do not put function addresses in registers; make each instruction that
+calls a constant function contain the function's address explicitly.
+
+This option results in less efficient code, but some strange hacks
+that alter the assembler output may be confused by the optimizations
+performed when this option is not used.
+.TP
+.B \-fno\-peephole
+Disable any machine-specific peephole optimizations.
+.TP
+.B \-ffast-math
+This option allows GCC to violate some ANSI or IEEE rules/specifications
+in the interest of optimizing code for speed. For example, it allows
+the compiler to assume arguments to the \c
+.B sqrt\c
+\& function are
+non-negative numbers.
+
+This option should never be turned on by any `\|\c
+.B \-O\c
+\&\|' option since
+it can result in incorrect output for programs which depend on
+an exact implementation of IEEE or ANSI rules/specifications for
+math functions.
+.PP
+
+The following options control specific optimizations. The `\|\c
+.B \-O2\c
+\&\|'
+option turns on all of these optimizations except `\|\c
+.B \-funroll\-loops\c
+\&\|'
+and `\|\c
+.B \-funroll\-all\-loops\c
+\&\|'.
+
+The `\|\c
+.B \-O\c
+\&\|' option usually turns on
+the `\|\c
+.B \-fthread\-jumps\c
+\&\|' and `\|\c
+.B \-fdelayed\-branch\c
+\&\|' options, but
+specific machines may change the default optimizations.
+
+You can use the following flags in the rare cases when ``fine-tuning''
+of optimizations to be performed is desired.
+.TP
+.B \-fstrength\-reduce
+Perform the optimizations of loop strength reduction and
+elimination of iteration variables.
+.TP
+.B \-fthread\-jumps
+Perform optimizations where we check to see if a jump branches to a
+location where another comparison subsumed by the first is found. If
+so, the first branch is redirected to either the destination of the
+second branch or a point immediately following it, depending on whether
+the condition is known to be true or false.
+.TP
+.B \-funroll\-loops
+Perform the optimization of loop unrolling. This is only done for loops
+whose number of iterations can be determined at compile time or run time.
+.TP
+.B \-funroll\-all\-loops
+Perform the optimization of loop unrolling. This is done for all loops.
+This usually makes programs run more slowly.
+.TP
+.B \-fcse\-follow\-jumps
+In common subexpression elimination, scan through jump instructions
+when the target of the jump is not reached by any other path. For
+example, when CSE encounters an \c
+.B if\c
+\& statement with an
+\c
+.B else\c
+\& clause, CSE will follow the jump when the condition
+tested is false.
+.TP
+.B \-fcse\-skip\-blocks
+This is similar to `\|\c
+.B \-fcse\-follow\-jumps\c
+\&\|', but causes CSE to
+follow jumps which conditionally skip over blocks. When CSE
+encounters a simple \c
+.B if\c
+\& statement with no else clause,
+`\|\c
+.B \-fcse\-skip\-blocks\c
+\&\|' causes CSE to follow the jump around the
+body of the \c
+.B if\c
+\&.
+.TP
+.B \-frerun\-cse\-after\-loop
+Re-run common subexpression elimination after loop optimizations has been
+performed.
+.TP
+.B \-felide\-constructors
+Elide constructors when this seems plausible (C++ only). With this
+flag, GNU C++ initializes \c
+.B y\c
+\& directly from the call to \c
+.B foo\c
+\&
+without going through a temporary in the following code:
+
+.sp
+.br
+A\ foo\ ();
+.br
+A\ y\ =\ foo\ ();
+.br
+.sp
+
+Without this option, GNU C++ first initializes \c
+.B y\c
+\& by calling the
+appropriate constructor for type \c
+.B A\c
+\&; then assigns the result of
+\c
+.B foo\c
+\& to a temporary; and, finally, replaces the initial valyue of
+`\|\c
+.B y\c
+\&\|' with the temporary.
+
+The default behavior (`\|\c
+.B \-fno\-elide\-constructors\c
+\&\|') is specified by
+the draft ANSI C++ standard. If your program's constructors have side
+effects, using `\|\c
+.B \-felide-constructors\c
+\&\|' can make your program act
+differently, since some constructor calls may be omitted.
+.TP
+.B \-fexpensive\-optimizations
+Perform a number of minor optimizations that are relatively expensive.
+.TP
+.B \-fdelayed\-branch
+If supported for the target machine, attempt to reorder instructions
+to exploit instruction slots available after delayed branch
+instructions.
+.TP
+.B \-fschedule\-insns
+If supported for the target machine, attempt to reorder instructions to
+eliminate execution stalls due to required data being unavailable. This
+helps machines that have slow floating point or memory load instructions
+by allowing other instructions to be issued until the result of the load
+or floating point instruction is required.
+.TP
+.B \-fschedule\-insns2
+Similar to `\|\c
+.B \-fschedule\-insns\c
+\&\|', but requests an additional pass of
+instruction scheduling after register allocation has been done. This is
+especially useful on machines with a relatively small number of
+registers and where memory load instructions take more than one cycle.
+.PP
+
+.SH TARGET OPTIONS
+By default, GNU CC compiles code for the same type of machine that you
+are using. However, it can also be installed as a cross-compiler, to
+compile for some other type of machine. In fact, several different
+configurations of GNU CC, for different target machines, can be
+installed side by side. Then you specify which one to use with the
+`\|\c
+.B \-b\c
+\&\|' option.
+
+In addition, older and newer versions of GNU CC can be installed side
+by side. One of them (probably the newest) will be the default, but
+you may sometimes wish to use another.
+.TP
+.BI "\-b " "machine"\c
+\&
+The argument \c
+.I machine\c
+\& specifies the target machine for compilation.
+This is useful when you have installed GNU CC as a cross-compiler.
+
+The value to use for \c
+.I machine\c
+\& is the same as was specified as the
+machine type when configuring GNU CC as a cross-compiler. For
+example, if a cross-compiler was configured with `\|\c
+.B configure
+i386v\c
+\&\|', meaning to compile for an 80386 running System V, then you
+would specify `\|\c
+.B \-b i386v\c
+\&\|' to run that cross compiler.
+
+When you do not specify `\|\c
+.B \-b\c
+\&\|', it normally means to compile for
+the same type of machine that you are using.
+.TP
+.BI "\-V " "version"\c
+\&
+The argument \c
+.I version\c
+\& specifies which version of GNU CC to run.
+This is useful when multiple versions are installed. For example,
+\c
+.I version\c
+\& might be `\|\c
+.B 2.0\c
+\&\|', meaning to run GNU CC version 2.0.
+
+The default version, when you do not specify `\|\c
+.B \-V\c
+\&\|', is controlled
+by the way GNU CC is installed. Normally, it will be a version that
+is recommended for general use.
+.PP
+
+.SH MACHINE DEPENDENT OPTIONS
+Each of the target machine types can have its own special options,
+starting with `\|\c
+.B \-m\c
+\&\|', to choose among various hardware models or
+configurations\(em\&for example, 68010 vs 68020, floating coprocessor or
+none. A single installed version of the compiler can compile for any
+model or configuration, according to the options specified.
+
+Some configurations of the compiler also support additional special
+options, usually for command-line compatibility with other compilers on
+the same platform.
+
+These are the `\|\c
+.B \-m\c
+\&\|' options defined for the 68000 series:
+.TP
+.B \-m68000
+.TP
+.B \-mc68000
+Generate output for a 68000. This is the default when the compiler is
+configured for 68000-based systems.
+.TP
+.B \-m68020
+.TP
+.B \-mc68020
+Generate output for a 68020 (rather than a 68000). This is the
+default when the compiler is configured for 68020-based systems.
+.TP
+.B \-m68881
+Generate output containing 68881 instructions for floating point.
+This is the default for most 68020-based systems unless
+.B \-nfp
+was specified when the compiler was configured.
+.TP
+.B \-m68030
+Generate output for a 68030. This is the default when the compiler is
+configured for 68030-based systems.
+.TP
+.B \-m68040
+Generate output for a 68040. This is the default when the compiler is
+configured for 68040-based systems.
+.TP
+.B \-m68020\-40
+Generate output for a 68040, without using any of the new instructions.
+This results in code which can run relatively efficiently on either a
+68020/68881 or a 68030 or a 68040.
+.TP
+.B \-mfpa
+Generate output containing Sun FPA instructions for floating point.
+.TP
+.B \-msoft\-float
+Generate output containing library calls for floating point.
+.I
+WARNING:
+the requisite libraries are not part of GNU CC. Normally the
+facilities of the machine's usual C compiler are used, but this can't
+be done directly in cross-compilation. You must make your own
+arrangements to provide suitable library functions for cross-compilation.
+.TP
+.B \-mshort
+Consider type \c
+.B int\c
+\& to be 16 bits wide, like \c
+.B short int\c
+\&.
+.TP
+.B \-mnobitfield
+Do not use the bit-field instructions. `\|\c
+.B \-m68000\c
+\&\|' implies
+`\|\c
+.B \-mnobitfield\c
+\&\|'.
+.TP
+.B \-mbitfield
+Do use the bit-field instructions. `\|\c
+.B \-m68020\c
+\&\|' implies
+`\|\c
+.B \-mbitfield\c
+\&\|'. This is the default if you use the unmodified
+sources.
+.TP
+.B \-mrtd
+Use a different function-calling convention, in which functions
+that take a fixed number of arguments return with the \c
+.B rtd\c
+\&
+instruction, which pops their arguments while returning. This
+saves one instruction in the caller since there is no need to pop
+the arguments there.
+
+This calling convention is incompatible with the one normally
+used on Unix, so you cannot use it if you need to call libraries
+compiled with the Unix compiler.
+
+Also, you must provide function prototypes for all functions that
+take variable numbers of arguments (including \c
+.B printf\c
+\&);
+otherwise incorrect code will be generated for calls to those
+functions.
+
+In addition, seriously incorrect code will result if you call a
+function with too many arguments. (Normally, extra arguments are
+harmlessly ignored.)
+
+The \c
+.B rtd\c
+\& instruction is supported by the 68010 and 68020
+processors, but not by the 68000.
+.PP
+
+These `\|\c
+.B \-m\c
+\&\|' options are defined for the Vax:
+.TP
+.B \-munix
+Do not output certain jump instructions (\c
+.B aobleq\c
+\& and so on)
+that the Unix assembler for the Vax cannot handle across long
+ranges.
+.TP
+.B \-mgnu
+Do output those jump instructions, on the assumption that you
+will assemble with the GNU assembler.
+.TP
+.B \-mg
+Output code for g-format floating point numbers instead of d-format.
+.PP
+
+These `\|\c
+.B \-m\c
+\&\|' switches are supported on the SPARC:
+
+.PP
+.B \-mfpu
+.TP
+.B \-mhard\-float
+Generate output containing floating point instructions. This is the
+default.
+.PP
+.B \-mno\-fpu
+.TP
+.B \-msoft\-float
+Generate output containing library calls for floating point.
+.I Warning:
+there is no GNU floating-point library for SPARC.
+Normally the facilities of the machine's usual C compiler are used, but
+this cannot be done directly in cross-compilation. You must make your
+own arrangements to provide suitable library functions for
+cross-compilation.
+
+.B \-msoft\-float
+changes the calling convention in the output file;
+therefore, it is only useful if you compile
+.I all
+of a program with this option.
+.PP
+.B \-mno\-epilogue
+.TP
+.B \-mepilogue
+With
+.B \-mepilogue
+(the default), the compiler always emits code for
+function exit at the end of each function. Any function exit in
+the middle of the function (such as a return statement in C) will
+generate a jump to the exit code at the end of the function.
+
+With
+.BR \-mno\-epilogue ,
+the compiler tries to emit exit code inline at every function exit.
+.PP
+.B \-mv8
+.TP
+.B \-msparclite
+These two options select variations on the SPARC architecture.
+
+By default (unless specifically configured for the Fujitsu SPARClite),
+GCC generates code for the v7 variant of the SPARC architecture.
+
+.B \-mv8
+will give you SPARC v8 code. The only difference from v7
+code is that the compiler emits the integer multiply and integer
+divide instructions which exist in SPARC v8 but not in SPARC v7.
+
+.B \-msparclite
+will give you SPARClite code. This adds the integer
+multiply, integer divide step and scan (ffs) instructions which
+exist in SPARClite but not in SPARC v7.
+.PP
+
+These `\|\c
+.B \-m\c
+\&\|' options are defined for the Convex:
+.TP
+.B \-mc1
+Generate output for a C1. This is the default when the compiler is
+configured for a C1.
+.TP
+.B \-mc2
+Generate output for a C2. This is the default when the compiler is
+configured for a C2.
+.TP
+.B \-margcount
+Generate code which puts an argument count in the word preceding each
+argument list. Some nonportable Convex and Vax programs need this word.
+(Debuggers don't, except for functions with variable-length argument
+lists; this info is in the symbol table.)
+.TP
+.B \-mnoargcount
+Omit the argument count word. This is the default if you use the
+unmodified sources.
+.PP
+
+These `\|\c
+.B \-m\c
+\&\|' options are defined for the AMD Am29000:
+.TP
+.B \-mdw
+Generate code that assumes the DW bit is set, i.e., that byte and
+halfword operations are directly supported by the hardware. This is the
+default.
+.TP
+.B \-mnodw
+Generate code that assumes the DW bit is not set.
+.TP
+.B \-mbw
+Generate code that assumes the system supports byte and halfword write
+operations. This is the default.
+.TP
+.B \-mnbw
+Generate code that assumes the systems does not support byte and
+halfword write operations. This implies `\|\c
+.B \-mnodw\c
+\&\|'.
+.TP
+.B \-msmall
+Use a small memory model that assumes that all function addresses are
+either within a single 256 KB segment or at an absolute address of less
+than 256K. This allows the \c
+.B call\c
+\& instruction to be used instead
+of a \c
+.B const\c
+\&, \c
+.B consth\c
+\&, \c
+.B calli\c
+\& sequence.
+.TP
+.B \-mlarge
+Do not assume that the \c
+.B call\c
+\& instruction can be used; this is the
+default.
+.TP
+.B \-m29050
+Generate code for the Am29050.
+.TP
+.B \-m29000
+Generate code for the Am29000. This is the default.
+.TP
+.B \-mkernel\-registers
+Generate references to registers \c
+.B gr64-gr95\c
+\& instead of
+\c
+.B gr96-gr127\c
+\&. This option can be used when compiling kernel code
+that wants a set of global registers disjoint from that used by
+user-mode code.
+
+Note that when this option is used, register names in `\|\c
+.B \-f\c
+\&\|' flags
+must use the normal, user-mode, names.
+.TP
+.B \-muser\-registers
+Use the normal set of global registers, \c
+.B gr96-gr127\c
+\&. This is the
+default.
+.TP
+.B \-mstack\-check
+Insert a call to \c
+.B __msp_check\c
+\& after each stack adjustment. This
+is often used for kernel code.
+.PP
+
+These `\|\c
+.B \-m\c
+\&\|' options are defined for Motorola 88K architectures:
+.TP
+.B \-m88000
+Generate code that works well on both the m88100 and the
+m88110.
+.TP
+.B \-m88100
+Generate code that works best for the m88100, but that also
+runs on the m88110.
+.TP
+.B \-m88110
+Generate code that works best for the m88110, and may not run
+on the m88100.
+.TP
+.B \-midentify\-revision
+Include an \c
+.B ident\c
+\& directive in the assembler output recording the
+source file name, compiler name and version, timestamp, and compilation
+flags used.
+.TP
+.B \-mno\-underscores
+In assembler output, emit symbol names without adding an underscore
+character at the beginning of each name. The default is to use an
+underscore as prefix on each name.
+.TP
+.B \-mno\-check\-zero\-division
+.TP
+.B \-mcheck\-zero\-division
+Early models of the 88K architecture had problems with division by zero;
+in particular, many of them didn't trap. Use these options to avoid
+including (or to include explicitly) additional code to detect division
+by zero and signal an exception. All GCC configurations for the 88K use
+`\|\c
+.B \-mcheck\-zero\-division\c
+\&\|' by default.
+.TP
+.B \-mocs\-debug\-info
+.TP
+.B \-mno\-ocs\-debug\-info
+Include (or omit) additional debugging information (about
+registers used in each stack frame) as specified in the 88Open Object
+Compatibility Standard, ``OCS''. This extra information is not needed
+by GDB. The default for DG/UX, SVr4, and Delta 88 SVr3.2 is to
+include this information; other 88k configurations omit this information
+by default.
+.TP
+.B \-mocs\-frame\-position
+.TP
+.B \-mno\-ocs\-frame\-position
+Force (or do not require) register values to be stored in a particular
+place in stack frames, as specified in OCS. The DG/UX, Delta88 SVr3.2,
+and BCS configurations use `\|\c
+.B \-mocs\-frame\-position\c
+\&\|'; other 88k
+configurations have the default `\|\c
+.B \-mno\-ocs\-frame\-position\c
+\&\|'.
+.TP
+.B \-moptimize\-arg\-area
+.TP
+.B \-mno\-optimize\-arg\-area
+Control how to store function arguments in stack frames.
+`\|\c
+.B \-moptimize\-arg\-area\c
+\&\|' saves space, but may break some
+debuggers (not GDB). `\|\c
+.B \-mno\-optimize\-arg\-area\c
+\&\|' conforms better to
+standards. By default GCC does not optimize the argument area.
+.TP
+.BI "\-mshort\-data\-" "num"\c
+\&
+.I num\c
+\&
+Generate smaller data references by making them relative to \c
+.B r0\c
+\&,
+which allows loading a value using a single instruction (rather than the
+usual two). You control which data references are affected by
+specifying \c
+.I num\c
+\& with this option. For example, if you specify
+`\|\c
+.B \-mshort\-data\-512\c
+\&\|', then the data references affected are those
+involving displacements of less than 512 bytes.
+`\|\c
+.B \-mshort\-data\-\c
+.I num\c
+\&\c
+\&\|' is not effective for \c
+.I num\c
+\& greater
+than 64K.
+.PP
+.B \-mserialize-volatile
+.TP
+.B \-mno-serialize-volatile
+Do, or do not, generate code to guarantee sequential consistency of
+volatile memory references.
+
+GNU CC always guarantees consistency by default, for the preferred
+processor submodel. How this is done depends on the submodel.
+
+The m88100 processor does not reorder memory references and so always
+provides sequential consistency. If you use `\|\c
+.B \-m88100\c
+\&\|', GNU CC does
+not generate any special instructions for sequential consistency.
+
+The order of memory references made by the m88110 processor does not
+always match the order of the instructions requesting those references.
+In particular, a load instruction may execute before a preceding store
+instruction. Such reordering violates sequential consistency of
+volatile memory references, when there are multiple processors. When
+you use `\|\c
+.B \-m88000\c
+\&\|' or `\|\c
+.B \-m88110\c
+\&\|', GNU CC generates special
+instructions when appropriate, to force execution in the proper order.
+
+The extra code generated to guarantee consistency may affect the
+performance of your application. If you know that you can safely forgo
+this guarantee, you may use the option `\|\c
+.B \-mno-serialize-volatile\c
+\&\|'.
+
+If you use the `\|\c
+.B \-m88100\c
+\&\|' option but require sequential consistency
+when running on the m88110 processor, you should use
+`\|\c
+.B \-mserialize-volatile\c
+\&\|'.
+.PP
+.B \-msvr4
+.TP
+.B \-msvr3
+Turn on (`\|\c
+.B \-msvr4\c
+\&\|') or off (`\|\c
+.B \-msvr3\c
+\&\|') compiler extensions
+related to System V release 4 (SVr4). This controls the following:
+.TP
+\ \ \ \(bu
+Which variant of the assembler syntax to emit (which you can select
+independently using `\|\c
+.B \-mversion\-03.00\c
+\&\|').
+.TP
+\ \ \ \(bu
+`\|\c
+.B \-msvr4\c
+\&\|' makes the C preprocessor recognize `\|\c
+.B #pragma weak\c
+\&\|'
+.TP
+\ \ \ \(bu
+`\|\c
+.B \-msvr4\c
+\&\|' makes GCC issue additional declaration directives used in
+SVr4.
+.PP
+`\|\c
+.B \-msvr3\c
+\&\|' is the default for all m88K configurations except
+the SVr4 configuration.
+.TP
+.B \-mtrap\-large\-shift
+.TP
+.B \-mhandle\-large\-shift
+Include code to detect bit-shifts of more than 31 bits; respectively,
+trap such shifts or emit code to handle them properly. By default GCC
+makes no special provision for large bit shifts.
+.TP
+.B \-muse\-div\-instruction
+Very early models of the 88K architecture didn't have a divide
+instruction, so GCC avoids that instruction by default. Use this option
+to specify that it's safe to use the divide instruction.
+.TP
+.B \-mversion\-03.00
+In the DG/UX configuration, there are two flavors of SVr4. This option
+modifies
+.B \-msvr4
+to select whether the hybrid-COFF or real-ELF
+flavor is used. All other configurations ignore this option.
+.TP
+.B \-mwarn\-passed\-structs
+Warn when a function passes a struct as an argument or result.
+Structure-passing conventions have changed during the evolution of the C
+language, and are often the source of portability problems. By default,
+GCC issues no such warning.
+.PP
+These options are defined for the IBM RS6000:
+
+.PP
+.B \-mfp\-in\-toc
+.TP
+.B \-mno\-fp\-in\-toc
+Control whether or not floating-point constants go in the Table of
+Contents (TOC), a table of all global variable and function addresses. By
+default GCC puts floating-point constants there; if the TOC overflows,
+`\|\c
+.B \-mno\-fp\-in\-toc\c
+\&\|' will reduce the size of the TOC, which may avoid
+the overflow.
+
+.PP
+These `\|\c
+.B \-m\c
+\&\|' options are defined for the IBM RT PC:
+.TP
+.B \-min\-line\-mul
+Use an in-line code sequence for integer multiplies. This is the
+default.
+.TP
+.B \-mcall\-lib\-mul
+Call \c
+.B lmul$$\c
+\& for integer multiples.
+.TP
+.B \-mfull\-fp\-blocks
+Generate full-size floating point data blocks, including the minimum
+amount of scratch space recommended by IBM. This is the default.
+.TP
+.B \-mminimum\-fp\-blocks
+Do not include extra scratch space in floating point data blocks. This
+results in smaller code, but slower execution, since scratch space must
+be allocated dynamically.
+.TP
+.B \-mfp\-arg\-in\-fpregs
+Use a calling sequence incompatible with the IBM calling convention in
+which floating point arguments are passed in floating point registers.
+Note that \c
+.B varargs.h\c
+\& and \c
+.B stdargs.h\c
+\& will not work with
+floating point operands if this option is specified.
+.TP
+.B \-mfp\-arg\-in\-gregs
+Use the normal calling convention for floating point arguments. This is
+the default.
+.TP
+.B \-mhc\-struct\-return
+Return structures of more than one word in memory, rather than in a
+register. This provides compatibility with the MetaWare HighC (hc)
+compiler. Use `\|\c
+.B \-fpcc\-struct\-return\c
+\&\|' for compatibility with the
+Portable C Compiler (pcc).
+.TP
+.B \-mnohc\-struct\-return
+Return some structures of more than one word in registers, when
+convenient. This is the default. For compatibility with the
+IBM-supplied compilers, use either `\|\c
+.B \-fpcc\-struct\-return\c
+\&\|' or
+`\|\c
+.B \-mhc\-struct\-return\c
+\&\|'.
+.PP
+These `\|\c
+.B \-m\c
+\&\|' options are defined for the MIPS family of computers:
+.TP
+.BI "\-mcpu=" "cpu-type"
+Assume the defaults for the machine type
+.I cpu-type
+when
+scheduling instructions. The default
+.I cpu-type
+is
+.BR default ,
+which picks the longest cycles times for any of the machines, in order
+that the code run at reasonable rates on all MIPS cpu's. Other
+choices for
+.I cpu-type
+are
+.BR r2000 ,
+.BR r3000 ,
+.BR r4000 ,
+and
+.BR r6000 .
+While picking a specific
+.I cpu-type
+will schedule things appropriately for that particular chip, the
+compiler will not generate any code that does not meet level 1 of the
+MIPS ISA (instruction set architecture) without the
+.B \-mips2
+or
+.B \-mips3
+switches being used.
+.TP
+.B \-mips2
+Issue instructions from level 2 of the MIPS ISA (branch likely, square
+root instructions). The
+.B \-mcpu=r4000
+or
+.B \-mcpu=r6000
+switch must be used in conjunction with
+.BR \-mips2 .
+.TP
+.B \-mips3
+Issue instructions from level 3 of the MIPS ISA (64 bit instructions).
+The
+.B \-mcpu=r4000
+switch must be used in conjunction with
+.BR \-mips2 .
+.TP
+.B \-mint64
+.TP
+.B \-mlong64
+.TP
+.B \-mlonglong128
+These options don't work at present.
+.TP
+.B \-mmips\-as
+Generate code for the MIPS assembler, and invoke
+.B mips\-tfile
+to add normal debug information. This is the default for all
+platforms except for the OSF/1 reference platform, using the OSF/rose
+object format. If any of the
+.BR \-ggdb ,
+.BR \-gstabs ,
+or
+.B \-gstabs+
+switches are used, the
+.B mips\-tfile
+program will encapsulate the stabs within MIPS ECOFF.
+.TP
+.B \-mgas
+Generate code for the GNU assembler. This is the default on the OSF/1
+reference platform, using the OSF/rose object format.
+.TP
+.B \-mrnames
+.TP
+.B \-mno\-rnames
+The
+.B \-mrnames
+switch says to output code using the MIPS software names for the
+registers, instead of the hardware names (ie,
+.B a0
+instead of
+.BR $4 ).
+The GNU assembler does not support the
+.B \-mrnames
+switch, and the MIPS assembler will be instructed to run the MIPS C
+preprocessor over the source file. The
+.B \-mno\-rnames
+switch is default.
+.TP
+.B \-mgpopt
+.TP
+.B \-mno\-gpopt
+The
+.B \-mgpopt
+switch says to write all of the data declarations before the
+instructions in the text section, to all the MIPS assembler to
+generate one word memory references instead of using two words for
+short global or static data items. This is on by default if
+optimization is selected.
+.TP
+.B \-mstats
+.TP
+.B \-mno\-stats
+For each non-inline function processed, the
+.B \-mstats
+switch causes the compiler to emit one line to the standard error file
+to print statistics about the program (number of registers saved,
+stack size, etc.).
+.TP
+.B \-mmemcpy
+.TP
+.B \-mno\-memcpy
+The
+.B \-mmemcpy
+switch makes all block moves call the appropriate string function
+.RB ( memcpy
+or
+.BR bcopy )
+instead of possibly generating inline code.
+.TP
+.B \-mmips\-tfile
+.TP
+.B \-mno\-mips\-tfile
+The
+.B \-mno\-mips\-tfile
+switch causes the compiler not postprocess the object file with the
+.B mips\-tfile
+program, after the MIPS assembler has generated it to add debug
+support. If
+.B mips\-tfile
+is not run, then no local variables will be available to the debugger.
+In addition,
+.B stage2
+and
+.B stage3
+objects will have the temporary file names passed to the assembler
+embedded in the object file, which means the objects will not compare
+the same.
+.TP
+.B \-msoft\-float
+Generate output containing library calls for floating point.
+.I
+WARNING:
+the requisite libraries are not part of GNU CC. Normally the
+facilities of the machine's usual C compiler are used, but this can't
+be done directly in cross-compilation. You must make your own
+arrangements to provide suitable library functions for cross-compilation.
+.TP
+.B \-mhard\-float
+Generate output containing floating point instructions. This is the
+default if you use the unmodified sources.
+.TP
+.B \-mfp64
+Assume that the
+.B FR
+bit in the status word is on, and that there are 32 64-bit floating
+point registers, instead of 32 32-bit floating point registers. You
+must also specify the
+.B \-mcpu=r4000
+and
+.B \-mips3
+switches.
+.TP
+.B \-mfp32
+Assume that there are 32 32-bit floating point registers. This is the
+default.
+.PP
+.B \-mabicalls
+.TP
+.B \-mno\-abicalls
+Emit (or do not emit) the
+.BR \&.abicalls ,
+.BR \&.cpload ,
+and
+.B \&.cprestore
+pseudo operations that some System V.4 ports use for position
+independent code.
+.TP
+.B \-mhalf\-pic
+.TP
+.B \-mno\-half\-pic
+The
+.B \-mhalf\-pic
+switch says to put pointers to extern references into the data section
+and load them up, rather than put the references in the text section.
+This option does not work at present.
+.B
+.BI \-G num
+Put global and static items less than or equal to
+.I num
+bytes into the small data or bss sections instead of the normal data
+or bss section. This allows the assembler to emit one word memory
+reference instructions based on the global pointer
+.RB ( gp
+or
+.BR $28 ),
+instead of the normal two words used. By default,
+.I num
+is 8 when the MIPS assembler is used, and 0 when the GNU
+assembler is used. The
+.BI \-G num
+switch is also passed to the assembler and linker. All modules should
+be compiled with the same
+.BI \-G num
+value.
+.TP
+.B \-nocpp
+Tell the MIPS assembler to not run it's preprocessor over user
+assembler files (with a `\|\c
+.B .s\c
+\&\|' suffix) when assembling them.
+.PP
+These `\|\c
+.B \-m\c
+\&\|' options are defined for the Intel 80386 family of computers:
+
+.B \-m486
+.TP
+.B \-mno\-486
+Control whether or not code is optimized for a 486 instead of an
+386. Code generated for a 486 will run on a 386 and vice versa.
+.TP
+.B \-msoft\-float
+Generate output containing library calls for floating point.
+.I Warning:
+the requisite libraries are not part of GNU CC.
+Normally the facilities of the machine's usual C compiler are used, but
+this can't be done directly in cross-compilation. You must make your
+own arrangements to provide suitable library functions for
+cross-compilation.
+
+On machines where a function returns floating point results in the 80387
+register stack, some floating point opcodes may be emitted even if
+`\|\c
+.B \-msoft-float\c
+\&\|' is used.
+.TP
+.B \-mno-fp-ret-in-387
+Do not use the FPU registers for return values of functions.
+
+The usual calling convention has functions return values of types
+\c
+.B float\c
+\& and \c
+.B double\c
+\& in an FPU register, even if there
+is no FPU. The idea is that the operating system should emulate
+an FPU.
+
+The option `\|\c
+.B \-mno-fp-ret-in-387\c
+\&\|' causes such values to be returned
+in ordinary CPU registers instead.
+.PP
+These `\|\c
+.B \-m\c
+\&\|' options are defined for the HPPA family of computers:
+.TP
+.B \-mpa-risc-1-0
+Generate code for a PA 1.0 processor.
+.TP
+.B \-mpa-risc-1-1
+Generate code for a PA 1.1 processor.
+.TP
+.B \-mkernel
+Generate code which is suitable for use in kernels. Specifically, avoid
+\c
+.B add\c
+\& instructions in which one of the arguments is the DP register;
+generate \c
+.B addil\c
+\& instructions instead. This avoids a rather serious
+bug in the HP-UX linker.
+.TP
+.B \-mshared-libs
+Generate code that can be linked against HP-UX shared libraries. This option
+is not fully function yet, and is not on by default for any PA target. Using
+this option can cause incorrect code to be generated by the compiler.
+.TP
+.B \-mno-shared-libs
+Don't generate code that will be linked against shared libraries. This is
+the default for all PA targets.
+.TP
+.B \-mlong-calls
+Generate code which allows calls to functions greater than 256K away from
+the caller when the caller and callee are in the same source file. Do
+not turn this option on unless code refuses to link with "branch out of
+range errors" from the linker.
+.TP
+.B \-mdisable-fpregs
+Prevent floating point registers from being used in any manner. This is
+necessary for compiling kernels which perform lazy context switching of
+floating point registers. If you use this option and attempt to perform
+floating point operations, the compiler will abort.
+.TP
+.B \-mdisable-indexing
+Prevent the compiler from using indexing address modes. This avoids some
+rather obscure problems when compiling MIG generated code under MACH.
+.TP
+.B \-mtrailing-colon
+Add a colon to the end of label definitions (for ELF assemblers).
+.PP
+These `\|\c
+.B \-m\c
+\&\|' options are defined for the Intel 80960 family of computers:
+.TP
+.BI "\-m" "cpu-type"
+Assume the defaults for the machine type
+.I cpu-type
+for instruction and addressing-mode availability and alignment.
+The default
+.I cpu-type
+is
+.BR kb ;
+other choices are
+.BR ka ,
+.BR mc ,
+.BR ca ,
+.BR cf ,
+.BR sa ,
+and
+.BR sb .
+.TP
+.B \-mnumerics
+.TP
+.B \-msoft\-float
+The
+.B \-mnumerics
+option indicates that the processor does support
+floating-point instructions. The
+.B \-msoft\-float
+option indicates
+that floating-point support should not be assumed.
+.TP
+.B \-mleaf\-procedures
+.TP
+.B \-mno\-leaf\-procedures
+Do (or do not) attempt to alter leaf procedures to be callable with the
+.I bal
+instruction as well as
+.IR call .
+This will result in more
+efficient code for explicit calls when the
+.I bal
+instruction can be
+substituted by the assembler or linker, but less efficient code in other
+cases, such as calls via function pointers, or using a linker that doesn't
+support this optimization.
+.TP
+.B \-mtail\-call
+.TP
+.B \-mno\-tail\-call
+Do (or do not) make additional attempts (beyond those of the
+machine-independent portions of the compiler) to optimize tail-recursive
+calls into branches. You may not want to do this because the detection of
+cases where this is not valid is not totally complete. The default is
+.BR \-mno\-tail\-call .
+.TP
+.B \-mcomplex\-addr
+.TP
+.B \-mno\-complex\-addr
+Assume (or do not assume) that the use of a complex addressing mode is a
+win on this implementation of the i960. Complex addressing modes may not
+be worthwhile on the K-series, but they definitely are on the C-series.
+The default is currently
+.B \-mcomplex\-addr
+for all processors except
+the CB and CC.
+.TP
+.B \-mcode\-align
+.TP
+.B \-mno\-code\-align
+Align code to 8-byte boundaries for faster fetching (or don't bother).
+Currently turned on by default for C-series implementations only.
+.TP
+.B \-mic\-compat
+.TP
+.B \-mic2.0\-compat
+.TP
+.B \-mic3.0\-compat
+Enable compatibility with iC960 v2.0 or v3.0.
+.TP
+.B \-masm\-compat
+.TP
+.B \-mintel\-asm
+Enable compatibility with the iC960 assembler.
+.TP
+.B \-mstrict\-align
+.TP
+.B \-mno\-strict\-align
+Do not permit (do permit) unaligned accesses.
+.TP
+.B \-mold\-align
+Enable structure-alignment compatibility with Intel's gcc release version
+1.3 (based on gcc 1.37). Currently this is buggy in that
+.B #pragma align 1
+is always assumed as well, and cannot be turned off.
+.PP
+These `\|\c
+.B \-m\c
+\&\|' options are defined for the DEC Alpha implementations:
+.TP
+.B \-mno-soft-float
+.TP
+.B \-msoft-float
+Use (do not use) the hardware floating-point instructions for
+floating-point operations. When \c
+.B \-msoft-float\c
+\& is specified,
+functions in `\|\c
+.B libgcc1.c\c
+\&\|' will be used to perform floating-point
+operations. Unless they are replaced by routines that emulate the
+floating-point operations, or compiled in such a way as to call such
+emulations routines, these routines will issue floating-point
+operations. If you are compiling for an Alpha without floating-point
+operations, you must ensure that the library is built so as not to call
+them.
+
+Note that Alpha implementations without floating-point operations are
+required to have floating-point registers.
+.TP
+.B \-mfp-reg
+.TP
+.B \-mno-fp-regs
+Generate code that uses (does not use) the floating-point register set.
+.B \-mno-fp-regs\c
+\& implies \c
+.B \-msoft-float\c
+\&. If the floating-point
+register set is not used, floating point operands are passed in integer
+registers as if they were integers and floating-point results are passed
+in $0 instead of $f0. This is a non-standard calling sequence, so any
+function with a floating-point argument or return value called by code
+compiled with \c
+.B \-mno-fp-regs\c
+\& must also be compiled with that
+option.
+
+A typical use of this option is building a kernel that does not use,
+and hence need not save and restore, any floating-point registers.
+.PP
+These additional options are available on System V Release 4 for
+compatibility with other compilers on those systems:
+.TP
+.B \-G
+On SVr4 systems, \c
+.B gcc\c
+\& accepts the option `\|\c
+.B \-G\c
+\&\|' (and passes
+it to the system linker), for compatibility with other compilers.
+However, we suggest you use `\|\c
+.B \-symbolic\c
+\&\|' or `\|\c
+.B \-shared\c
+\&\|' as
+appropriate, instead of supplying linker options on the \c
+.B gcc\c
+\&
+command line.
+.TP
+.B \-Qy
+Identify the versions of each tool used by the compiler, in a
+\c
+.B .ident\c
+\& assembler directive in the output.
+.TP
+.B \-Qn
+Refrain from adding \c
+.B .ident\c
+\& directives to the output file (this is
+the default).
+.TP
+.BI "-YP," "dirs"\c
+\&
+Search the directories \c
+.I dirs\c
+\&, and no others, for libraries
+specified with `\|\c
+.B \-l\c
+\&\|'. You can separate directory entries in
+\c
+.I dirs\c
+\& from one another with colons.
+.TP
+.BI "-Ym," "dir"\c
+\&
+Look in the directory \c
+.I dir\c
+\& to find the M4 preprocessor.
+The assembler uses this option.
+.PP
+
+.SH CODE GENERATION OPTIONS
+These machine-independent options control the interface conventions
+used in code generation.
+
+Most of them begin with `\|\c
+\-f\c
+\&\|'. These options have both positive and negative forms; the negative form
+of `\|\c
+.B \-ffoo\c
+\&\|' would be `\|\c
+.B \-fno\-foo\c
+\&\|'. In the table below, only
+one of the forms is listed\(em\&the one which is not the default. You
+can figure out the other form by either removing `\|\c
+.B no\-\c
+\&\|' or adding
+it.
+.TP
+.B \-fnonnull\-objects
+Assume that objects reached through references are not null
+(C++ only).
+
+Normally, GNU C++ makes conservative assumptions about objects reached
+through references. For example, the compiler must check that \c
+.B a\c
+\&
+is not null in code like the following:
+
+.sp
+.br
+obj\ &a\ =\ g\ ();
+.br
+a.f\ (2);
+.br
+.sp
+
+Checking that references of this sort have non-null values requires
+extra code, however, and it is unnecessary for many programs. You can
+use `\|\c
+.B \-fnonnull-objects\c
+\&\|' to omit the checks for null, if your
+program doesn't require checking.
+.TP
+.B \-fpcc\-struct\-return
+Use the same convention for returning \c
+.B struct\c
+\& and \c
+.B union\c
+\&
+values that is used by the usual C compiler on your system. This
+convention is less efficient for small structures, and on many
+machines it fails to be reentrant; but it has the advantage of
+allowing intercallability between GCC-compiled code and PCC-compiled
+code.
+.TP
+.B \-freg\-struct\-return
+Use the convention that
+.B struct
+and
+.B union
+values are returned in registers when possible. This is more
+efficient for small structures than
+.BR \-fpcc\-struct\-return .
+
+If you specify neither
+.B \-fpcc\-struct\-return
+nor
+.BR \-freg\-struct\-return ,
+GNU CC defaults to whichever convention is standard for the target.
+If there is no standard convention, GNU CC defaults to
+.BR \-fpcc\-struct\-return .
+.TP
+.B \-fshort\-enums
+Allocate to an \c
+.B enum\c
+\& type only as many bytes as it needs for the
+declared range of possible values. Specifically, the \c
+.B enum\c
+\& type
+will be equivalent to the smallest integer type which has enough room.
+.TP
+.B \-fshort\-double
+Use the same size for
+.B double
+as for
+.B float
+\&.
+.TP
+.B \-fshared\-data
+Requests that the data and non-\c
+.B const\c
+\& variables of this
+compilation be shared data rather than private data. The distinction
+makes sense only on certain operating systems, where shared data is
+shared between processes running the same program, while private data
+exists in one copy per process.
+.TP
+.B \-fno\-common
+Allocate even uninitialized global variables in the bss section of the
+object file, rather than generating them as common blocks. This has the
+effect that if the same variable is declared (without \c
+.B extern\c
+\&) in
+two different compilations, you will get an error when you link them.
+The only reason this might be useful is if you wish to verify that the
+program will work on other systems which always work this way.
+.TP
+.B \-fno\-ident
+Ignore the `\|\c
+.B #ident\c
+\&\|' directive.
+.TP
+.B \-fno\-gnu\-linker
+Do not output global initializations (such as C++ constructors and
+destructors) in the form used by the GNU linker (on systems where the GNU
+linker is the standard method of handling them). Use this option when
+you want to use a non-GNU linker, which also requires using the
+\c
+.B collect2\c
+\& program to make sure the system linker includes
+constructors and destructors. (\c
+.B collect2\c
+\& is included in the GNU CC
+distribution.) For systems which \c
+.I must\c
+\& use \c
+.B collect2\c
+\&, the
+compiler driver \c
+.B gcc\c
+\& is configured to do this automatically.
+.TP
+.B \-finhibit-size-directive
+Don't output a \c
+.B .size\c
+\& assembler directive, or anything else that
+would cause trouble if the function is split in the middle, and the
+two halves are placed at locations far apart in memory. This option is
+used when compiling `\|\c
+.B crtstuff.c\c
+\&\|'; you should not need to use it
+for anything else.
+.TP
+.B \-fverbose-asm
+Put extra commentary information in the generated assembly code to
+make it more readable. This option is generally only of use to those
+who actually need to read the generated assembly code (perhaps while
+debugging the compiler itself).
+.TP
+.B \-fvolatile
+Consider all memory references through pointers to be volatile.
+.TP
+.B \-fvolatile\-global
+Consider all memory references to extern and global data items to
+be volatile.
+.TP
+.B \-fpic
+If supported for the target machines, generate position-independent code,
+suitable for use in a shared library.
+.TP
+.B \-fPIC
+If supported for the target machine, emit position-independent code,
+suitable for dynamic linking, even if branches need large displacements.
+.TP
+.BI "\-ffixed\-" "reg"\c
+\&
+Treat the register named \c
+.I reg\c
+\& as a fixed register; generated code
+should never refer to it (except perhaps as a stack pointer, frame
+pointer or in some other fixed role).
+
+\c
+.I reg\c
+\& must be the name of a register. The register names accepted
+are machine-specific and are defined in the \c
+.B REGISTER_NAMES\c
+\&
+macro in the machine description macro file.
+
+This flag does not have a negative form, because it specifies a
+three-way choice.
+.TP
+.BI "\-fcall\-used\-" "reg"\c
+\&
+Treat the register named \c
+.I reg\c
+\& as an allocatable register that is
+clobbered by function calls. It may be allocated for temporaries or
+variables that do not live across a call. Functions compiled this way
+will not save and restore the register \c
+.I reg\c
+\&.
+
+Use of this flag for a register that has a fixed pervasive role in the
+machine's execution model, such as the stack pointer or frame pointer,
+will produce disastrous results.
+
+This flag does not have a negative form, because it specifies a
+three-way choice.
+.TP
+.BI "\-fcall\-saved\-" "reg"\c
+\&
+Treat the register named \c
+.I reg\c
+\& as an allocatable register saved by
+functions. It may be allocated even for temporaries or variables that
+live across a call. Functions compiled this way will save and restore
+the register \c
+.I reg\c
+\& if they use it.
+
+Use of this flag for a register that has a fixed pervasive role in the
+machine's execution model, such as the stack pointer or frame pointer,
+will produce disastrous results.
+
+A different sort of disaster will result from the use of this flag for
+a register in which function values may be returned.
+
+This flag does not have a negative form, because it specifies a
+three-way choice.
+.PP
+
+.SH PRAGMAS
+Two `\|\c
+.B #pragma\c
+\&\|' directives are supported for GNU C++, to permit using the same
+header file for two purposes: as a definition of interfaces to a given
+object class, and as the full definition of the contents of that object class.
+.TP
+.B #pragma interface
+(C++ only.)
+Use this directive in header files that define object classes, to save
+space in most of the object files that use those classes. Normally,
+local copies of certain information (backup copies of inline member
+functions, debugging information, and the internal tables that
+implement virtual functions) must be kept in each object file that
+includes class definitions. You can use this pragma to avoid such
+duplication. When a header file containing `\|\c
+.B #pragma interface\c
+\&\|' is included in a compilation, this auxiliary information
+will not be generated (unless the main input source file itself uses
+`\|\c
+.B #pragma implementation\c
+\&\|'). Instead, the object files will contain references to be
+resolved at link time.
+.tr !"
+.TP
+.B #pragma implementation
+.TP
+.BI "#pragma implementation !" objects .h!
+(C++ only.)
+Use this pragma in a main input file, when you want full output from
+included header files to be generated (and made globally visible).
+The included header file, in turn, should use `\|\c
+.B #pragma interface\c
+\&\|'.
+Backup copies of inline member functions, debugging information, and
+the internal tables used to implement virtual functions are all
+generated in implementation files.
+
+If you use `\|\c
+.B #pragma implementation\c
+\&\|' with no argument, it applies to an include file with the same
+basename as your source file; for example, in `\|\c
+.B allclass.cc\c
+\&\|', `\|\c
+.B #pragma implementation\c
+\&\|' by itself is equivalent to `\|\c
+.B
+#pragma implementation "allclass.h"\c
+\&\|'. Use the string argument if you want a single implementation
+file to include code from multiple header files.
+
+There is no way to split up the contents of a single header file into
+multiple implementation files.
+.SH FILES
+.ta \w'LIBDIR/g++\-include 'u
+file.c C source file
+.br
+file.h C header (preprocessor) file
+.br
+file.i preprocessed C source file
+.br
+file.C C++ source file
+.br
+file.cc C++ source file
+.br
+file.cxx C++ source file
+.br
+file.m Objective-C source file
+.br
+file.s assembly language file
+.br
+file.o object file
+.br
+a.out link edited output
+.br
+\fITMPDIR\fR/cc\(** temporary files
+.br
+\fILIBDIR\fR/cpp preprocessor
+.br
+\fILIBDIR\fR/cc1 compiler for C
+.br
+\fILIBDIR\fR/cc1plus compiler for C++
+.br
+\fILIBDIR\fR/collect linker front end needed on some machines
+.br
+\fILIBDIR\fR/libgcc.a GCC subroutine library
+.br
+/lib/crt[01n].o start-up routine
+.br
+\fILIBDIR\fR/ccrt0 additional start-up routine for C++
+.br
+/lib/libc.a standard C library, see
+.IR intro (3)
+.br
+/usr/include standard directory for
+.B #include
+files
+.br
+\fILIBDIR\fR/include standard gcc directory for
+.B #include
+files
+.br
+\fILIBDIR\fR/g++\-include additional g++ directory for
+.B #include
+.sp
+.I LIBDIR
+is usually
+.B /usr/local/lib/\c
+.IR machine / version .
+.br
+.I TMPDIR
+comes from the environment variable
+.B TMPDIR
+(default
+.B /usr/tmp
+if available, else
+.B /tmp\c
+\&).
+.SH "SEE ALSO"
+cpp(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1).
+.br
+.RB "`\|" gcc "\|', `\|" cpp \|',
+.RB `\| as \|', `\| ld \|',
+and
+.RB `\| gdb \|'
+entries in
+.B info\c
+\&.
+.br
+.I
+Using and Porting GNU CC (for version 2.0)\c
+, Richard M. Stallman;
+.I
+The C Preprocessor\c
+, Richard M. Stallman;
+.I
+Debugging with GDB: the GNU Source-Level Debugger\c
+, Richard M. Stallman and Roland H. Pesch;
+.I
+Using as: the GNU Assembler\c
+, Dean Elsner, Jay Fenlason & friends;
+.I
+ld: the GNU linker\c
+, Steve Chamberlain and Roland Pesch.
+
+.SH BUGS
+For instructions on reporting bugs, see the GCC manual.
+
+.SH COPYING
+Copyright (c) 1991, 1992, 1993 Free Software Foundation, Inc.
+.PP
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+.PP
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the
+entire resulting derived work is distributed under the terms of a
+permission notice identical to this one.
+.PP
+Permission is granted to copy and distribute translations of this
+manual into another language, under the above conditions for modified
+versions, except that this permission notice may be included in
+translations approved by the Free Software Foundation instead of in
+the original English.
+.SH AUTHORS
+See the GNU CC Manual for the contributors to GNU CC.
diff --git a/gnu/usr.bin/cc/cc/gcc.c b/gnu/usr.bin/cc/cc/gcc.c
new file mode 100644
index 000000000000..4223d23f62bd
--- /dev/null
+++ b/gnu/usr.bin/cc/cc/gcc.c
@@ -0,0 +1,4270 @@
+/* Compiler driver program that can handle many languages.
+ Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+This paragraph is here to try to keep Sun CC from dying.
+The number of chars here seems crucial!!!! */
+
+/* This program is the user interface to the C compiler and possibly to
+other compilers. It is used because compilation is a complicated procedure
+which involves running several programs and passing temporary files between
+them, forwarding the users switches to those programs selectively,
+and deleting the temporary files at the end.
+
+CC recognizes how to compile each input file by suffixes in the file names.
+Once it knows which kind of compilation to perform, the procedure for
+compilation is specified by a string called a "spec". */
+
+#include <sys/types.h>
+#include <ctype.h>
+#include <signal.h>
+#include <sys/stat.h>
+#include <sys/file.h> /* May get R_OK, etc. on some systems. */
+
+#include "config.h"
+#include "obstack.h"
+#include "gvarargs.h"
+#include <stdio.h>
+
+#ifndef R_OK
+#define R_OK 4
+#define W_OK 2
+#define X_OK 1
+#endif
+
+/* Define a generic NULL if one hasn't already been defined. */
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef GENERIC_PTR
+#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
+#define GENERIC_PTR void *
+#else
+#define GENERIC_PTR char *
+#endif
+#endif
+
+#ifndef NULL_PTR
+#define NULL_PTR ((GENERIC_PTR)0)
+#endif
+
+#ifdef USG
+#define vfork fork
+#endif /* USG */
+
+/* On MSDOS, write temp files in current dir
+ because there's no place else we can expect to use. */
+#if __MSDOS__
+#ifndef P_tmpdir
+#define P_tmpdir "./"
+#endif
+#endif
+
+/* Test if something is a normal file. */
+#ifndef S_ISREG
+#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#endif
+
+/* Test if something is a directory. */
+#ifndef S_ISDIR
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif
+
+/* By default there is no special suffix for executables. */
+#ifndef EXECUTABLE_SUFFIX
+#define EXECUTABLE_SUFFIX ""
+#endif
+
+/* By default, colon separates directories in a path. */
+#ifndef PATH_SEPARATOR
+#define PATH_SEPARATOR ':'
+#endif
+
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free free
+
+extern void free ();
+extern char *getenv ();
+
+extern int errno, sys_nerr;
+extern char *sys_errlist[];
+
+extern int execv (), execvp ();
+
+/* If a stage of compilation returns an exit status >= 1,
+ compilation of that file ceases. */
+
+#define MIN_FATAL_STATUS 1
+
+/* Flag saying to print the full filename of libgcc.a
+ as found through our usual search mechanism. */
+
+static int print_libgcc_file_name;
+
+/* Flag indicating whether we should print the command and arguments */
+
+static int verbose_flag;
+
+/* Nonzero means write "temp" files in source directory
+ and use the source file's name in them, and don't delete them. */
+
+static int save_temps_flag;
+
+/* The compiler version specified with -V */
+
+static char *spec_version;
+
+/* The target machine specified with -b. */
+
+static char *spec_machine = "";
+
+/* Nonzero if cross-compiling.
+ When -b is used, the value comes from the `specs' file. */
+
+#ifdef CROSS_COMPILE
+static int cross_compile = 1;
+#else
+static int cross_compile = 0;
+#endif
+
+/* The number of errors that have occurred; the link phase will not be
+ run if this is non-zero. */
+static int error_count = 0;
+
+/* This is the obstack which we use to allocate many strings. */
+
+static struct obstack obstack;
+
+/* This is the obstack to build an environment variable to pass to
+ collect2 that describes all of the relevant switches of what to
+ pass the compiler in building the list of pointers to constructors
+ and destructors. */
+
+static struct obstack collect_obstack;
+
+extern char *version_string;
+
+static void set_spec ();
+static struct compiler *lookup_compiler ();
+static char *find_a_file ();
+static void add_prefix ();
+static char *skip_whitespace ();
+static void record_temp_file ();
+static char *handle_braces ();
+static char *save_string ();
+static char *concat ();
+static int do_spec ();
+static int do_spec_1 ();
+static char *find_file ();
+static int is_directory ();
+static void validate_switches ();
+static void validate_all_switches ();
+static void give_switch ();
+static void pfatal_with_name ();
+static void perror_with_name ();
+static void perror_exec ();
+static void fatal ();
+static void error ();
+void fancy_abort ();
+char *xmalloc ();
+char *xrealloc ();
+
+/* Specs are strings containing lines, each of which (if not blank)
+is made up of a program name, and arguments separated by spaces.
+The program name must be exact and start from root, since no path
+is searched and it is unreliable to depend on the current working directory.
+Redirection of input or output is not supported; the subprograms must
+accept filenames saying what files to read and write.
+
+In addition, the specs can contain %-sequences to substitute variable text
+or for conditional text. Here is a table of all defined %-sequences.
+Note that spaces are not generated automatically around the results of
+expanding these sequences; therefore, you can concatenate them together
+or with constant text in a single argument.
+
+ %% substitute one % into the program name or argument.
+ %i substitute the name of the input file being processed.
+ %b substitute the basename of the input file being processed.
+ This is the substring up to (and not including) the last period
+ and not including the directory.
+ %g substitute the temporary-file-name-base. This is a string chosen
+ once per compilation. Different temporary file names are made by
+ concatenation of constant strings on the end, as in `%g.s'.
+ %g also has the same effect of %d.
+ %u like %g, but make the temporary file name unique.
+ %U returns the last file name generated with %u.
+ %d marks the argument containing or following the %d as a
+ temporary file name, so that that file will be deleted if CC exits
+ successfully. Unlike %g, this contributes no text to the argument.
+ %w marks the argument containing or following the %w as the
+ "output file" of this compilation. This puts the argument
+ into the sequence of arguments that %o will substitute later.
+ %W{...}
+ like %{...} but mark last argument supplied within
+ as a file to be deleted on failure.
+ %o substitutes the names of all the output files, with spaces
+ automatically placed around them. You should write spaces
+ around the %o as well or the results are undefined.
+ %o is for use in the specs for running the linker.
+ Input files whose names have no recognized suffix are not compiled
+ at all, but they are included among the output files, so they will
+ be linked.
+ %p substitutes the standard macro predefinitions for the
+ current target machine. Use this when running cpp.
+ %P like %p, but puts `__' before and after the name of each macro.
+ (Except macros that already have __.)
+ This is for ANSI C.
+ %I Substitute a -iprefix option made from GCC_EXEC_PREFIX.
+ %s current argument is the name of a library or startup file of some sort.
+ Search for that file in a standard list of directories
+ and substitute the full name found.
+ %eSTR Print STR as an error message. STR is terminated by a newline.
+ Use this when inconsistent options are detected.
+ %x{OPTION} Accumulate an option for %X.
+ %X Output the accumulated linker options specified by compilations.
+ %Y Output the accumulated assembler options specified by compilations.
+ %a process ASM_SPEC as a spec.
+ This allows config.h to specify part of the spec for running as.
+ %A process ASM_FINAL_SPEC as a spec. A capital A is actually
+ used here. This can be used to run a post-processor after the
+ assembler has done it's job.
+ %D Dump out a -L option for each directory in startfile_prefix.
+ %l process LINK_SPEC as a spec.
+ %L process LIB_SPEC as a spec.
+ %S process STARTFILE_SPEC as a spec. A capital S is actually used here.
+ %E process ENDFILE_SPEC as a spec. A capital E is actually used here.
+ %c process SIGNED_CHAR_SPEC as a spec.
+ %C process CPP_SPEC as a spec. A capital C is actually used here.
+ %1 process CC1_SPEC as a spec.
+ %2 process CC1PLUS_SPEC as a spec.
+ %| output "-" if the input for the current command is coming from a pipe.
+ %* substitute the variable part of a matched option. (See below.)
+ Note that each comma in the substituted string is replaced by
+ a single space.
+ %{S} substitutes the -S switch, if that switch was given to CC.
+ If that switch was not specified, this substitutes nothing.
+ Here S is a metasyntactic variable.
+ %{S*} substitutes all the switches specified to CC whose names start
+ with -S. This is used for -o, -D, -I, etc; switches that take
+ arguments. CC considers `-o foo' as being one switch whose
+ name starts with `o'. %{o*} would substitute this text,
+ including the space; thus, two arguments would be generated.
+ %{S*:X} substitutes X if one or more switches whose names start with -S are
+ specified to CC. Note that the tail part of the -S option
+ (i.e. the part matched by the `*') will be substituted for each
+ occurrence of %* within X.
+ %{S:X} substitutes X, but only if the -S switch was given to CC.
+ %{!S:X} substitutes X, but only if the -S switch was NOT given to CC.
+ %{|S:X} like %{S:X}, but if no S switch, substitute `-'.
+ %{|!S:X} like %{!S:X}, but if there is an S switch, substitute `-'.
+ %{.S:X} substitutes X, but only if processing a file with suffix S.
+ %{!.S:X} substitutes X, but only if NOT processing a file with suffix S.
+ %(Spec) processes a specification defined in a specs file as *Spec:
+ %[Spec] as above, but put __ around -D arguments
+
+The conditional text X in a %{S:X} or %{!S:X} construct may contain
+other nested % constructs or spaces, or even newlines. They are
+processed as usual, as described above.
+
+The character | is used to indicate that a command should be piped to
+the following command, but only if -pipe is specified.
+
+Note that it is built into CC which switches take arguments and which
+do not. You might think it would be useful to generalize this to
+allow each compiler's spec to say which switches take arguments. But
+this cannot be done in a consistent fashion. CC cannot even decide
+which input files have been specified without knowing which switches
+take arguments, and it must know which input files to compile in order
+to tell which compilers to run.
+
+CC also knows implicitly that arguments starting in `-l' are to be
+treated as compiler output files, and passed to the linker in their
+proper position among the other output files. */
+
+/* Define the macros used for specs %a, %l, %L, %S, %c, %C, %1. */
+
+/* config.h can define ASM_SPEC to provide extra args to the assembler
+ or extra switch-translations. */
+#ifndef ASM_SPEC
+#define ASM_SPEC ""
+#endif
+
+/* config.h can define ASM_FINAL_SPEC to run a post processor after
+ the assembler has run. */
+#ifndef ASM_FINAL_SPEC
+#define ASM_FINAL_SPEC ""
+#endif
+
+/* config.h can define CPP_SPEC to provide extra args to the C preprocessor
+ or extra switch-translations. */
+#ifndef CPP_SPEC
+#define CPP_SPEC ""
+#endif
+
+/* config.h can define CC1_SPEC to provide extra args to cc1 and cc1plus
+ or extra switch-translations. */
+#ifndef CC1_SPEC
+#define CC1_SPEC ""
+#endif
+
+/* config.h can define CC1PLUS_SPEC to provide extra args to cc1plus
+ or extra switch-translations. */
+#ifndef CC1PLUS_SPEC
+#define CC1PLUS_SPEC ""
+#endif
+
+/* config.h can define LINK_SPEC to provide extra args to the linker
+ or extra switch-translations. */
+#ifndef LINK_SPEC
+#define LINK_SPEC ""
+#endif
+
+/* config.h can define LIB_SPEC to override the default libraries. */
+#ifndef LIB_SPEC
+#define LIB_SPEC "%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
+#endif
+
+/* config.h can define STARTFILE_SPEC to override the default crt0 files. */
+#ifndef STARTFILE_SPEC
+#define STARTFILE_SPEC \
+ "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}"
+#endif
+
+/* config.h can define SWITCHES_NEED_SPACES to control passing -o and -L.
+ Make the string nonempty to require spaces there. */
+#ifndef SWITCHES_NEED_SPACES
+#define SWITCHES_NEED_SPACES ""
+#endif
+
+/* config.h can define ENDFILE_SPEC to override the default crtn files. */
+#ifndef ENDFILE_SPEC
+#define ENDFILE_SPEC ""
+#endif
+
+/* This spec is used for telling cpp whether char is signed or not. */
+#ifndef SIGNED_CHAR_SPEC
+/* Use #if rather than ?:
+ because MIPS C compiler rejects like ?: in initializers. */
+#if DEFAULT_SIGNED_CHAR
+#define SIGNED_CHAR_SPEC "%{funsigned-char:-D__CHAR_UNSIGNED__}"
+#else
+#define SIGNED_CHAR_SPEC "%{!fsigned-char:-D__CHAR_UNSIGNED__}"
+#endif
+#endif
+
+static char *cpp_spec = CPP_SPEC;
+static char *cpp_predefines = CPP_PREDEFINES;
+static char *cc1_spec = CC1_SPEC;
+static char *cc1plus_spec = CC1PLUS_SPEC;
+static char *signed_char_spec = SIGNED_CHAR_SPEC;
+static char *asm_spec = ASM_SPEC;
+static char *asm_final_spec = ASM_FINAL_SPEC;
+static char *link_spec = LINK_SPEC;
+static char *lib_spec = LIB_SPEC;
+static char *endfile_spec = ENDFILE_SPEC;
+static char *startfile_spec = STARTFILE_SPEC;
+static char *switches_need_spaces = SWITCHES_NEED_SPACES;
+
+/* This defines which switch letters take arguments. */
+
+#ifndef SWITCH_TAKES_ARG
+#define SWITCH_TAKES_ARG(CHAR) \
+ ((CHAR) == 'D' || (CHAR) == 'U' || (CHAR) == 'o' \
+ || (CHAR) == 'e' || (CHAR) == 'T' || (CHAR) == 'u' \
+ || (CHAR) == 'I' || (CHAR) == 'm' \
+ || (CHAR) == 'L' || (CHAR) == 'A')
+#endif
+
+/* This defines which multi-letter switches take arguments. */
+
+#define DEFAULT_WORD_SWITCH_TAKES_ARG(STR) \
+ (!strcmp (STR, "Tdata") || !strcmp (STR, "Ttext") \
+ || !strcmp (STR, "Tbss") || !strcmp (STR, "include") \
+ || !strcmp (STR, "imacros") || !strcmp (STR, "aux-info") \
+ || !strcmp (STR, "idirafter") || !strcmp (STR, "iprefix") \
+ || !strcmp (STR, "iwithprefix"))
+
+#ifndef WORD_SWITCH_TAKES_ARG
+#define WORD_SWITCH_TAKES_ARG(STR) DEFAULT_WORD_SWITCH_TAKES_ARG (STR)
+#endif
+
+/* Record the mapping from file suffixes for compilation specs. */
+
+struct compiler
+{
+ char *suffix; /* Use this compiler for input files
+ whose names end in this suffix. */
+
+ char *spec[4]; /* To use this compiler, concatenate these
+ specs and pass to do_spec. */
+};
+
+/* Pointer to a vector of `struct compiler' that gives the spec for
+ compiling a file, based on its suffix.
+ A file that does not end in any of these suffixes will be passed
+ unchanged to the loader and nothing else will be done to it.
+
+ An entry containing two 0s is used to terminate the vector.
+
+ If multiple entries match a file, the last matching one is used. */
+
+static struct compiler *compilers;
+
+/* Number of entries in `compilers', not counting the null terminator. */
+
+static int n_compilers;
+
+/* The default list of file name suffixes and their compilation specs. */
+
+static struct compiler default_compilers[] =
+{
+ {".c", "@c"},
+ {"@c",
+ "gcpp -lang-c %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
+ %{C:%{!E:%eGNU C does not support -C without using -E}}\
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d}\
+ -undef -D__GNUC__=2 %{ansi:-trigraphs -$ -D__STRICT_ANSI__}\
+ %{!undef:%{!ansi:%p} %P} %{trigraphs} \
+ %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
+ %{traditional-cpp:-traditional}\
+ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*}\
+ %i %{!M:%{!MM:%{!E:%{!pipe:%g.i}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
+ "%{!M:%{!MM:%{!E:gcc1 %{!pipe:%g.i} %1 \
+ %{!Q:-quiet} -dumpbase %b.c %{d*} %{m*} %{a}\
+ %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi} \
+ %{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\
+ %{aux-info*}\
+ %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
+ %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
+ %{!S:as %{R} %{j} %{J} %{h} %{d2} %a %Y\
+ %{c:%W{o*}%{!o*:-o %w%b.o}}%{!c:-o %d%w%u.o}\
+ %{!pipe:%g.s} %A\n }}}}"},
+ {"-",
+ "%{E:gcpp -lang-c %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
+ %{C:%{!E:%eGNU C does not support -C without using -E}}\
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d}\
+ -undef -D__GNUC__=2 %{ansi:-trigraphs -$ -D__STRICT_ANSI__}\
+ %{!undef:%{!ansi:%p} %P} %{trigraphs}\
+ %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
+ %{traditional-cpp:-traditional}\
+ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*}\
+ %i %W{o*}}\
+ %{!E:%e-E required when input is from standard input}"},
+ {".m", "@objective-c"},
+ {"@objective-c",
+ "gcpp -lang-objc %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
+ %{C:%{!E:%eGNU C does not support -C without using -E}}\
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d}\
+ -undef -D__OBJC__ -D__GNUC__=2 %{ansi:-trigraphs -$ -D__STRICT_ANSI__}\
+ %{!undef:%{!ansi:%p} %P} %{trigraphs}\
+ %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
+ %{traditional-cpp:-traditional}\
+ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*}\
+ %i %{!M:%{!MM:%{!E:%{!pipe:%g.i}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
+ "%{!M:%{!MM:%{!E:gcc1obj %{!pipe:%g.i} %1 \
+ %{!Q:-quiet} -dumpbase %b.m %{d*} %{m*} %{a}\
+ %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi} \
+ %{traditional} %{v:-version} %{pg:-p} %{p} %{f*} \
+ -lang-objc %{gen-decls} \
+ %{aux-info*}\
+ %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
+ %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
+ %{!S:as %{R} %{j} %{J} %{h} %{d2} %a %Y\
+ %{c:%W{o*}%{!o*:-o %w%b.o}}%{!c:-o %d%w%u.o}\
+ %{!pipe:%g.s} %A\n }}}}"},
+ {".h", "@c-header"},
+ {"@c-header",
+ "%{!E:%eCompilation of header file requested} \
+ gcpp %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
+ %{C:%{!E:%eGNU C does not support -C without using -E}}\
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} \
+ -undef -D__GNUC__=2 %{ansi:-trigraphs -$ -D__STRICT_ANSI__}\
+ %{!undef:%{!ansi:%p} %P} %{trigraphs}\
+ %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
+ %{traditional-cpp:-traditional}\
+ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*}\
+ %i %W{o*}"},
+ {".cc", "@c++"},
+ {".cxx", "@c++"},
+ {".C", "@c++"},
+ {"@c++",
+ "gcpp -lang-c++ %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
+ %{C:%{!E:%eGNU C++ does not support -C without using -E}}\
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} \
+ -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus \
+ %{ansi:-trigraphs -$ -D__STRICT_ANSI__} %{!undef:%{!ansi:%p} %P}\
+ %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
+ %{traditional-cpp:-traditional} %{trigraphs}\
+ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*}\
+ %i %{!M:%{!MM:%{!E:%{!pipe:%g.i}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
+ "%{!M:%{!MM:%{!E:gcc1plus %{!pipe:%g.i} %1 %2\
+ %{!Q:-quiet} -dumpbase %b.cc %{d*} %{m*} %{a}\
+ %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi} %{traditional}\
+ %{v:-version} %{pg:-p} %{p} %{f*} %{+e*}\
+ %{aux-info*}\
+ %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
+ %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
+ %{!S:as %{R} %{j} %{J} %{h} %{d2} %a %Y\
+ %{c:%W{o*}%{!o*:-o %w%b.o}}%{!c:-o %d%w%u.o}\
+ %{!pipe:%g.s} %A\n }}}}"},
+ {".i", "@cpp-output"},
+ {"@cpp-output",
+ "gcc1 %i %1 %{!Q:-quiet} %{d*} %{m*} %{a}\
+ %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi} %{traditional}\
+ %{v:-version} %{pg:-p} %{p} %{f*}\
+ %{aux-info*}\
+ %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
+ %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
+ %{!S:as %{R} %{j} %{J} %{h} %{d2} %a %Y\
+ %{c:%W{o*}%{!o*:-o %w%b.o}}%{!c:-o %d%w%u.o} %{!pipe:%g.s} %A\n }"},
+ {".ii", "@c++-cpp-output"},
+ {"@c++-cpp-output",
+ "gcc1plus %i %1 %2 %{!Q:-quiet} %{d*} %{m*} %{a}\
+ %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi} %{traditional}\
+ %{v:-version} %{pg:-p} %{p} %{f*} %{+e*}\
+ %{aux-info*}\
+ %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
+ %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
+ %{!S:as %{R} %{j} %{J} %{h} %{d2} %a %Y\
+ %{c:%W{o*}%{!o*:-o %w%b.o}}%{!c:-o %d%w%u.o}\
+ %{!pipe:%g.s} %A\n }"},
+ {".s", "@assembler"},
+ {"@assembler",
+ "%{!S:as %{R} %{j} %{J} %{h} %{d2} %a %Y\
+ %{c:%W{o*}%{!o*:-o %w%b.o}}%{!c:-o %d%w%u.o} %i %A\n }"},
+ {".S", "@assembler-with-cpp"},
+ {"@assembler-with-cpp",
+ "gcpp -lang-asm %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
+ %{C:%{!E:%eGNU C does not support -C without using -E}}\
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{trigraphs} \
+ -undef -$ %{!undef:%p %P} -D__ASSEMBLER__ \
+ %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
+ %{traditional-cpp:-traditional}\
+ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*}\
+ %i %{!M:%{!MM:%{!E:%{!pipe:%g.s}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
+ "%{!M:%{!MM:%{!E:%{!S:as %{R} %{j} %{J} %{h} %{d2} %a %Y\
+ %{c:%W{o*}%{!o*:-o %w%b.o}}%{!c:-o %d%w%u.o}\
+ %{!pipe:%g.s} %A\n }}}}"},
+/***** ljo's Fortran rule *****/
+ {".f", "@f2c"},
+ {"@f2c",
+ "f2c %{checksubscripts:-C} %{I2} %{onetrip} %{honorcase:-U} %{u} %{w}\
+ %{ANSIC:-A} %{a} %{C++}\
+ %{c} %{E} %{ec} %{ext} %{f} %{72} %{g} %{h} %{i2} %{kr}\
+ %{P} %{p} %{r} %{r8} %{s} %{w8} %{z} %{N*}\
+ %i %{!pipe: -o %g.c} %{pipe:-o -}|\n",
+ "gcpp -lang-c %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
+ %{C:%{!E:%eGNU C does not support -C without using -E}}\
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d}\
+ -undef -D__GNUC__=2 %{ansi:-trigraphs -$ -D__STRICT_ANSI__}\
+ %{!undef:%{!ansi:%p} %P} %{trigraphs} \
+ %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
+ %{traditional-cpp:-traditional}\
+ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*}\
+ %{pipe:-} %{!pipe:%g.c} %{!M:%{!MM:%{!E:%{!pipe:%g.i}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
+ "%{!M:%{!MM:%{!E:gcc1 %{!pipe:%g.i} %1 \
+ %{!Q:-quiet} -dumpbase %b.c %{d*} %{m*} %{a}\
+ %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi} \
+ %{traditional} %{v:-version} %{pg:-p} %{p} %{f*}\
+ %{aux-info*}\
+ %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
+ %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
+ %{!S:as %{R} %{j} %{J} %{h} %{d2} %a %Y\
+ %{c:%W{o*}%{!o*:-o %w%b.o}}%{!c:-o %d%w%u.o}\
+ %{!pipe:%g.s} %A\n }}}}"},
+/***** End of ljo's Fortran rule *****/
+ /* Mark end of table */
+ {0, 0}
+};
+
+/* Number of elements in default_compilers, not counting the terminator. */
+
+static int n_default_compilers
+ = (sizeof default_compilers / sizeof (struct compiler)) - 1;
+
+/* Here is the spec for running the linker, after compiling all files. */
+
+/* -u* was put back because both BSD and SysV seem to support it. */
+/* %{static:} simply prevents an error message if the target machine
+ doesn't handle -static. */
+#ifdef LINK_LIBGCC_SPECIAL_1
+/* Have gcc do the search for libgcc.a, but generate -L options as usual. */
+static char *link_command_spec = "\
+%{!fsyntax-only: \
+ %{!c:%{!M:%{!MM:%{!E:%{!S:ld %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} \
+ %{r} %{s} %{T*} %{t} %{u*} %{x} %{z} %{Z} \
+ %{!A:%{!nostartfiles:%{!nostdlib:%S}}} %{static:}\
+ %{L*} %D %o %{!nostdlib:libgcc.a%s %L libgcc.a%s %{!A:%E}}\n }}}}}}";
+#else
+#ifdef LINK_LIBGCC_SPECIAL
+/* Have gcc do the search for libgcc.a, and don't generate -L options. */
+static char *link_command_spec = "\
+%{!fsyntax-only: \
+ %{!c:%{!M:%{!MM:%{!E:%{!S:ld %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} \
+ %{r} %{s} %{T*} %{t} %{u*} %{x} %{z} %{Z} \
+ %{!A:%{!nostartfiles:%{!nostdlib:%S}}} %{static:}\
+ %{L*} %o %{!nostdlib:libgcc.a%s %L libgcc.a%s %{!A:%E}}\n }}}}}}";
+#else
+/* Use -L and have the linker do the search for -lgcc. */
+static char *link_command_spec = "\
+%{!fsyntax-only: \
+ %{!c:%{!M:%{!MM:%{!E:%{!S:ld %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} \
+ %{r} %{s} %{T*} %{t} %{u*} %{x} %{z} %{Z} \
+ %{!A:%{!nostartfiles:%{!nostdlib:%S}}} %{static:}\
+ %{L*} %D %o %{!nostdlib:-lgcc %L -lgcc %{!A:%E}}\n }}}}}}";
+#endif
+#endif
+
+/* A vector of options to give to the linker.
+ These options are accumulated by -Xlinker and -Wl,
+ and substituted into the linker command with %X. */
+static int n_linker_options;
+static char **linker_options;
+
+/* A vector of options to give to the assembler.
+ These options are accumulated by -Wa,
+ and substituted into the assembler command with %X. */
+static int n_assembler_options;
+static char **assembler_options;
+
+/* Define how to map long options into short ones. */
+
+/* This structure describes one mapping. */
+struct option_map
+{
+ /* The long option's name. */
+ char *name;
+ /* The equivalent short option. */
+ char *equivalent;
+ /* Argument info. A string of flag chars; NULL equals no options.
+ a => argument required.
+ o => argument optional.
+ j => join argument to equivalent, making one word.
+ * => allow other text after NAME as an argument. */
+ char *arg_info;
+};
+
+/* This is the table of mappings. Mappings are tried sequentially
+ for each option encountered; the first one that matches, wins. */
+
+struct option_map option_map[] =
+ {
+ {"--profile-blocks", "-a", 0},
+ {"--target", "-b", "a"},
+ {"--compile", "-c", 0},
+ {"--dump", "-d", "a"},
+ {"--entry", "-e", 0},
+ {"--debug", "-g", "oj"},
+ {"--include", "-include", "a"},
+ {"--imacros", "-imacros", "a"},
+ {"--include-prefix", "-iprefix", "a"},
+ {"--include-directory-after", "-idirafter", "a"},
+ {"--include-with-prefix", "-iwithprefix", "a"},
+ {"--machine-", "-m", "*j"},
+ {"--machine", "-m", "aj"},
+ {"--no-standard-includes", "-nostdinc", 0},
+ {"--no-standard-libraries", "-nostdlib", 0},
+ {"--no-precompiled-includes", "-noprecomp", 0},
+ {"--output", "-o", "a"},
+ {"--profile", "-p", 0},
+ {"--quiet", "-q", 0},
+ {"--silent", "-q", 0},
+ {"--force-link", "-u", "a"},
+ {"--verbose", "-v", 0},
+ {"--no-warnings", "-w", 0},
+ {"--language", "-x", "a"},
+
+ {"--assert", "-A", "a"},
+ {"--prefix", "-B", "a"},
+ {"--comments", "-C", 0},
+ {"--define-macro", "-D", "a"},
+ {"--preprocess", "-E", 0},
+ {"--trace-includes", "-H", 0},
+ {"--include-directory", "-I", "a"},
+ {"--include-barrier", "-I-", 0},
+ {"--library-directory", "-L", "a"},
+ {"--dependencies", "-M", 0},
+ {"--user-dependencies", "-MM", 0},
+ {"--write-dependencies", "-MD", 0},
+ {"--write-user-dependencies", "-MMD", 0},
+ {"--optimize", "-O", "oj"},
+ {"--no-line-commands", "-P", 0},
+ {"--assemble", "-S", 0},
+ {"--undefine-macro", "-U", "a"},
+ {"--use-version", "-V", "a"},
+ {"--for-assembler", "-Wa", "a"},
+ {"--extra-warnings", "-W", 0},
+ {"--all-warnings", "-Wall", 0},
+ {"--warn-", "-W", "*j"},
+ {"--for-linker", "-Xlinker", "a"},
+
+ {"--ansi", "-ansi", 0},
+ {"--traditional", "-traditional", 0},
+ {"--traditional-cpp", "-traditional-cpp", 0},
+ {"--trigraphs", "-trigraphs", 0},
+ {"--pipe", "-pipe", 0},
+ {"--dumpbase", "-dumpbase", "a"},
+ {"--pedantic", "-pedantic", 0},
+ {"--pedantic-errors", "-pedantic-errors", 0},
+ {"--save-temps", "-save-temps", 0},
+ {"--print-libgcc-file-name", "-print-libgcc-file-name", 0},
+ {"--static", "-static", 0},
+ {"--shared", "-shared", 0},
+ {"--symbolic", "-symbolic", 0},
+ {"--", "-f", "*j"}
+ };
+
+/* Translate the options described by *ARGCP and *ARGVP.
+ Make a new vector and store it back in *ARGVP,
+ and store its length in *ARGVC. */
+
+static void
+translate_options (argcp, argvp)
+ int *argcp;
+ char ***argvp;
+{
+ int i, j;
+ int argc = *argcp;
+ char **argv = *argvp;
+ char **newv = (char **) xmalloc ((argc + 2) * 2 * sizeof (char *));
+ int newindex = 0;
+
+ i = 0;
+ newv[newindex++] = argv[i++];
+
+ while (i < argc)
+ {
+ /* Translate -- options. */
+ if (argv[i][0] == '-' && argv[i][1] == '-')
+ {
+ /* Find a mapping that applies to this option. */
+ for (j = 0; j < sizeof (option_map) / sizeof (option_map[0]); j++)
+ {
+ int optlen = strlen (option_map[j].name);
+ int complen = strlen (argv[i]);
+ char *arginfo = option_map[j].arg_info;
+
+ if (arginfo == 0)
+ arginfo = "";
+ if (complen > optlen)
+ complen = optlen;
+ if (!strncmp (argv[i], option_map[j].name, complen))
+ {
+ int extra = strlen (argv[i]) > optlen;
+ char *arg = 0;
+
+ if (extra)
+ {
+ /* If the option has an argument, accept that. */
+ if (argv[i][optlen] == '=')
+ arg = argv[i] + optlen + 1;
+ /* If this mapping allows extra text at end of name,
+ accept that as "argument". */
+ else if (index (arginfo, '*') != 0)
+ arg = argv[i] + optlen;
+ /* Otherwise, extra text at end means mismatch.
+ Try other mappings. */
+ else
+ continue;
+ }
+ else if (index (arginfo, '*') != 0)
+ error ("Incomplete `%s' option", option_map[j].name);
+
+ /* Handle arguments. */
+ if (index (arginfo, 'o') != 0)
+ {
+ if (arg == 0)
+ {
+ if (i + 1 == argc)
+ error ("Missing argument to `%s' option",
+ option_map[j].name);
+ arg = argv[++i];
+ }
+ }
+ else if (index (arginfo, 'a') == 0)
+ {
+ if (arg != 0)
+ error ("Extraneous argument to `%s' option",
+ option_map[j].name);
+ arg = 0;
+ }
+
+ /* Store the translation as one argv elt or as two. */
+ if (arg != 0 && index (arginfo, 'j') != 0)
+ newv[newindex++] = concat (option_map[j].equivalent,
+ arg, "");
+ else if (arg != 0)
+ {
+ newv[newindex++] = option_map[j].equivalent;
+ newv[newindex++] = arg;
+ }
+ else
+ newv[newindex++] = option_map[j].equivalent;
+
+ break;
+ }
+ }
+ i++;
+ }
+ /* Handle old-fashioned options--just copy them through,
+ with their arguments. */
+ else if (argv[i][0] == '-')
+ {
+ char *p = argv[i] + 1;
+ int c = *p;
+ int nskip = 1;
+
+ if (SWITCH_TAKES_ARG (c) > (p[1] != 0))
+ nskip += SWITCH_TAKES_ARG (c) - (p[1] != 0);
+ else if (WORD_SWITCH_TAKES_ARG (p))
+ nskip += WORD_SWITCH_TAKES_ARG (p);
+
+ while (nskip > 0)
+ {
+ newv[newindex++] = argv[i++];
+ nskip--;
+ }
+ }
+ else
+ /* Ordinary operands, or +e options. */
+ newv[newindex++] = argv[i++];
+ }
+
+ newv[newindex] = 0;
+
+ *argvp = newv;
+ *argcp = newindex;
+}
+
+/* Read compilation specs from a file named FILENAME,
+ replacing the default ones.
+
+ A suffix which starts with `*' is a definition for
+ one of the machine-specific sub-specs. The "suffix" should be
+ *asm, *cc1, *cpp, *link, *startfile, *signed_char, etc.
+ The corresponding spec is stored in asm_spec, etc.,
+ rather than in the `compilers' vector.
+
+ Anything invalid in the file is a fatal error. */
+
+static void
+read_specs (filename)
+ char *filename;
+{
+ int desc;
+ struct stat statbuf;
+ char *buffer;
+ register char *p;
+
+ if (verbose_flag)
+ fprintf (stderr, "Reading specs from %s\n", filename);
+
+ /* Open and stat the file. */
+ desc = open (filename, 0, 0);
+ if (desc < 0)
+ pfatal_with_name (filename);
+ if (stat (filename, &statbuf) < 0)
+ pfatal_with_name (filename);
+
+ /* Read contents of file into BUFFER. */
+ buffer = xmalloc ((unsigned) statbuf.st_size + 1);
+ read (desc, buffer, (unsigned) statbuf.st_size);
+ buffer[statbuf.st_size] = 0;
+ close (desc);
+
+ /* Scan BUFFER for specs, putting them in the vector. */
+ p = buffer;
+ while (1)
+ {
+ char *suffix;
+ char *spec;
+ char *in, *out, *p1, *p2;
+
+ /* Advance P in BUFFER to the next nonblank nocomment line. */
+ p = skip_whitespace (p);
+ if (*p == 0)
+ break;
+
+ /* Find the colon that should end the suffix. */
+ p1 = p;
+ while (*p1 && *p1 != ':' && *p1 != '\n') p1++;
+ /* The colon shouldn't be missing. */
+ if (*p1 != ':')
+ fatal ("specs file malformed after %d characters", p1 - buffer);
+ /* Skip back over trailing whitespace. */
+ p2 = p1;
+ while (p2 > buffer && (p2[-1] == ' ' || p2[-1] == '\t')) p2--;
+ /* Copy the suffix to a string. */
+ suffix = save_string (p, p2 - p);
+ /* Find the next line. */
+ p = skip_whitespace (p1 + 1);
+ if (p[1] == 0)
+ fatal ("specs file malformed after %d characters", p - buffer);
+ p1 = p;
+ /* Find next blank line. */
+ while (*p1 && !(*p1 == '\n' && p1[1] == '\n')) p1++;
+ /* Specs end at the blank line and do not include the newline. */
+ spec = save_string (p, p1 - p);
+ p = p1;
+
+ /* Delete backslash-newline sequences from the spec. */
+ in = spec;
+ out = spec;
+ while (*in != 0)
+ {
+ if (in[0] == '\\' && in[1] == '\n')
+ in += 2;
+ else if (in[0] == '#')
+ {
+ while (*in && *in != '\n') in++;
+ }
+ else
+ *out++ = *in++;
+ }
+ *out = 0;
+
+ if (suffix[0] == '*')
+ {
+ if (! strcmp (suffix, "*link_command"))
+ link_command_spec = spec;
+ else
+ set_spec (suffix + 1, spec);
+ }
+ else
+ {
+ /* Add this pair to the vector. */
+ compilers
+ = ((struct compiler *)
+ xrealloc (compilers, (n_compilers + 2) * sizeof (struct compiler)));
+ compilers[n_compilers].suffix = suffix;
+ bzero (compilers[n_compilers].spec,
+ sizeof compilers[n_compilers].spec);
+ compilers[n_compilers].spec[0] = spec;
+ n_compilers++;
+ }
+
+ if (*suffix == 0)
+ link_command_spec = spec;
+ }
+
+ if (link_command_spec == 0)
+ fatal ("spec file has no spec for linking");
+}
+
+static char *
+skip_whitespace (p)
+ char *p;
+{
+ while (1)
+ {
+ /* A fully-blank line is a delimiter in the SPEC file and shouldn't
+ be considered whitespace. */
+ if (p[0] == '\n' && p[1] == '\n' && p[2] == '\n')
+ return p + 1;
+ else if (*p == '\n' || *p == ' ' || *p == '\t')
+ p++;
+ else if (*p == '#')
+ {
+ while (*p != '\n') p++;
+ p++;
+ }
+ else
+ break;
+ }
+
+ return p;
+}
+
+/* Structure to keep track of the specs that have been defined so far. These
+ are accessed using %(specname) or %[specname] in a compiler or link spec. */
+
+struct spec_list
+{
+ char *name; /* Name of the spec. */
+ char *spec; /* The spec itself. */
+ struct spec_list *next; /* Next spec in linked list. */
+};
+
+/* List of specs that have been defined so far. */
+
+static struct spec_list *specs = (struct spec_list *) 0;
+
+/* Change the value of spec NAME to SPEC. If SPEC is empty, then the spec is
+ removed; If the spec starts with a + then SPEC is added to the end of the
+ current spec. */
+
+static void
+set_spec (name, spec)
+ char *name;
+ char *spec;
+{
+ struct spec_list *sl;
+ char *old_spec;
+
+ /* See if the spec already exists */
+ for (sl = specs; sl; sl = sl->next)
+ if (strcmp (sl->name, name) == 0)
+ break;
+
+ if (!sl)
+ {
+ /* Not found - make it */
+ sl = (struct spec_list *) xmalloc (sizeof (struct spec_list));
+ sl->name = save_string (name, strlen (name));
+ sl->spec = save_string ("", 0);
+ sl->next = specs;
+ specs = sl;
+ }
+
+ old_spec = sl->spec;
+ if (name && spec[0] == '+' && isspace (spec[1]))
+ sl->spec = concat (old_spec, spec + 1, "");
+ else
+ sl->spec = save_string (spec, strlen (spec));
+
+ if (! strcmp (name, "asm"))
+ asm_spec = sl->spec;
+ else if (! strcmp (name, "asm_final"))
+ asm_final_spec = sl->spec;
+ else if (! strcmp (name, "cc1"))
+ cc1_spec = sl->spec;
+ else if (! strcmp (name, "cc1plus"))
+ cc1plus_spec = sl->spec;
+ else if (! strcmp (name, "cpp"))
+ cpp_spec = sl->spec;
+ else if (! strcmp (name, "endfile"))
+ endfile_spec = sl->spec;
+ else if (! strcmp (name, "lib"))
+ lib_spec = sl->spec;
+ else if (! strcmp (name, "link"))
+ link_spec = sl->spec;
+ else if (! strcmp (name, "predefines"))
+ cpp_predefines = sl->spec;
+ else if (! strcmp (name, "signed_char"))
+ signed_char_spec = sl->spec;
+ else if (! strcmp (name, "startfile"))
+ startfile_spec = sl->spec;
+ else if (! strcmp (name, "switches_need_spaces"))
+ switches_need_spaces = sl->spec;
+ else if (! strcmp (name, "cross_compile"))
+ cross_compile = atoi (sl->spec);
+ /* Free the old spec */
+ if (old_spec)
+ free (old_spec);
+}
+
+/* Accumulate a command (program name and args), and run it. */
+
+/* Vector of pointers to arguments in the current line of specifications. */
+
+static char **argbuf;
+
+/* Number of elements allocated in argbuf. */
+
+static int argbuf_length;
+
+/* Number of elements in argbuf currently in use (containing args). */
+
+static int argbuf_index;
+
+/* This is the list of suffixes and codes (%g/%u/%U) and the associated
+ temp file. Used only if MKTEMP_EACH_FILE. */
+
+static struct temp_name {
+ char *suffix; /* suffix associated with the code. */
+ int length; /* strlen (suffix). */
+ int unique; /* Indicates whether %g or %u/%U was used. */
+ char *filename; /* associated filename. */
+ int filename_length; /* strlen (filename). */
+ struct temp_name *next;
+} *temp_names;
+
+/* Number of commands executed so far. */
+
+static int execution_count;
+
+/* Number of commands that exited with a signal. */
+
+static int signal_count;
+
+/* Name with which this program was invoked. */
+
+static char *programname;
+
+/* Structures to keep track of prefixes to try when looking for files. */
+
+struct prefix_list
+{
+ char *prefix; /* String to prepend to the path. */
+ struct prefix_list *next; /* Next in linked list. */
+ int require_machine_suffix; /* Don't use without machine_suffix. */
+ /* 2 means try both machine_suffix and just_machine_suffix. */
+ int *used_flag_ptr; /* 1 if a file was found with this prefix. */
+};
+
+struct path_prefix
+{
+ struct prefix_list *plist; /* List of prefixes to try */
+ int max_len; /* Max length of a prefix in PLIST */
+ char *name; /* Name of this list (used in config stuff) */
+};
+
+/* List of prefixes to try when looking for executables. */
+
+static struct path_prefix exec_prefix = { 0, 0, "exec" };
+
+/* List of prefixes to try when looking for startup (crt0) files. */
+
+static struct path_prefix startfile_prefix = { 0, 0, "startfile" };
+
+/* Suffix to attach to directories searched for commands.
+ This looks like `MACHINE/VERSION/'. */
+
+static char *machine_suffix = 0;
+
+/* Suffix to attach to directories searched for commands.
+ This is just `MACHINE/'. */
+
+static char *just_machine_suffix = 0;
+
+/* Adjusted value of GCC_EXEC_PREFIX envvar. */
+
+static char *gcc_exec_prefix;
+
+/* Default prefixes to attach to command names. */
+
+#ifdef CROSS_COMPILE /* Don't use these prefixes for a cross compiler. */
+#undef MD_EXEC_PREFIX
+#undef MD_STARTFILE_PREFIX
+#undef MD_STARTFILE_PREFIX_1
+#endif
+
+#ifndef STANDARD_EXEC_PREFIX
+#define STANDARD_EXEC_PREFIX "/usr/libexec/"
+#endif /* !defined STANDARD_EXEC_PREFIX */
+
+static char *standard_exec_prefix = STANDARD_EXEC_PREFIX;
+static char *standard_exec_prefix_1 = "";
+#ifdef MD_EXEC_PREFIX
+static char *md_exec_prefix = MD_EXEC_PREFIX;
+#endif
+
+#ifndef STANDARD_STARTFILE_PREFIX
+#define STANDARD_STARTFILE_PREFIX "/usr/lib/"
+#endif /* !defined STANDARD_STARTFILE_PREFIX */
+
+#ifdef MD_STARTFILE_PREFIX
+static char *md_startfile_prefix = MD_STARTFILE_PREFIX;
+#endif
+#ifdef MD_STARTFILE_PREFIX_1
+static char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1;
+#endif
+static char *standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
+static char *standard_startfile_prefix_1 = "/lib/";
+static char *standard_startfile_prefix_2 = "/usr/lib/";
+
+#ifndef TOOLDIR_BASE_PREFIX
+#define TOOLDIR_BASE_PREFIX "/usr/local/"
+#endif
+static char *tooldir_base_prefix = TOOLDIR_BASE_PREFIX;
+static char *tooldir_prefix;
+
+/* Clear out the vector of arguments (after a command is executed). */
+
+static void
+clear_args ()
+{
+ argbuf_index = 0;
+}
+
+/* Add one argument to the vector at the end.
+ This is done when a space is seen or at the end of the line.
+ If DELETE_ALWAYS is nonzero, the arg is a filename
+ and the file should be deleted eventually.
+ If DELETE_FAILURE is nonzero, the arg is a filename
+ and the file should be deleted if this compilation fails. */
+
+static void
+store_arg (arg, delete_always, delete_failure)
+ char *arg;
+ int delete_always, delete_failure;
+{
+ if (argbuf_index + 1 == argbuf_length)
+ {
+ argbuf = (char **) xrealloc (argbuf, (argbuf_length *= 2) * sizeof (char *));
+ }
+
+ argbuf[argbuf_index++] = arg;
+ argbuf[argbuf_index] = 0;
+
+ if (delete_always || delete_failure)
+ record_temp_file (arg, delete_always, delete_failure);
+}
+
+/* Record the names of temporary files we tell compilers to write,
+ and delete them at the end of the run. */
+
+/* This is the common prefix we use to make temp file names.
+ It is chosen once for each run of this program.
+ It is substituted into a spec by %g.
+ Thus, all temp file names contain this prefix.
+ In practice, all temp file names start with this prefix.
+
+ This prefix comes from the envvar TMPDIR if it is defined;
+ otherwise, from the P_tmpdir macro if that is defined;
+ otherwise, in /usr/tmp or /tmp. */
+
+static char *temp_filename;
+
+/* Length of the prefix. */
+
+static int temp_filename_length;
+
+/* Define the list of temporary files to delete. */
+
+struct temp_file
+{
+ char *name;
+ struct temp_file *next;
+};
+
+/* Queue of files to delete on success or failure of compilation. */
+static struct temp_file *always_delete_queue;
+/* Queue of files to delete on failure of compilation. */
+static struct temp_file *failure_delete_queue;
+
+/* Record FILENAME as a file to be deleted automatically.
+ ALWAYS_DELETE nonzero means delete it if all compilation succeeds;
+ otherwise delete it in any case.
+ FAIL_DELETE nonzero means delete it if a compilation step fails;
+ otherwise delete it in any case. */
+
+static void
+record_temp_file (filename, always_delete, fail_delete)
+ char *filename;
+ int always_delete;
+ int fail_delete;
+{
+ register char *name;
+ name = xmalloc (strlen (filename) + 1);
+ strcpy (name, filename);
+
+ if (always_delete)
+ {
+ register struct temp_file *temp;
+ for (temp = always_delete_queue; temp; temp = temp->next)
+ if (! strcmp (name, temp->name))
+ goto already1;
+ temp = (struct temp_file *) xmalloc (sizeof (struct temp_file));
+ temp->next = always_delete_queue;
+ temp->name = name;
+ always_delete_queue = temp;
+ already1:;
+ }
+
+ if (fail_delete)
+ {
+ register struct temp_file *temp;
+ for (temp = failure_delete_queue; temp; temp = temp->next)
+ if (! strcmp (name, temp->name))
+ goto already2;
+ temp = (struct temp_file *) xmalloc (sizeof (struct temp_file));
+ temp->next = failure_delete_queue;
+ temp->name = name;
+ failure_delete_queue = temp;
+ already2:;
+ }
+}
+
+/* Delete all the temporary files whose names we previously recorded. */
+
+static void
+delete_temp_files ()
+{
+ register struct temp_file *temp;
+
+ for (temp = always_delete_queue; temp; temp = temp->next)
+ {
+#ifdef DEBUG
+ int i;
+ printf ("Delete %s? (y or n) ", temp->name);
+ fflush (stdout);
+ i = getchar ();
+ if (i != '\n')
+ while (getchar () != '\n') ;
+ if (i == 'y' || i == 'Y')
+#endif /* DEBUG */
+ {
+ struct stat st;
+ if (stat (temp->name, &st) >= 0)
+ {
+ /* Delete only ordinary files. */
+ if (S_ISREG (st.st_mode))
+ if (unlink (temp->name) < 0)
+ if (verbose_flag)
+ perror_with_name (temp->name);
+ }
+ }
+ }
+
+ always_delete_queue = 0;
+}
+
+/* Delete all the files to be deleted on error. */
+
+static void
+delete_failure_queue ()
+{
+ register struct temp_file *temp;
+
+ for (temp = failure_delete_queue; temp; temp = temp->next)
+ {
+#ifdef DEBUG
+ int i;
+ printf ("Delete %s? (y or n) ", temp->name);
+ fflush (stdout);
+ i = getchar ();
+ if (i != '\n')
+ while (getchar () != '\n') ;
+ if (i == 'y' || i == 'Y')
+#endif /* DEBUG */
+ {
+ if (unlink (temp->name) < 0)
+ if (verbose_flag)
+ perror_with_name (temp->name);
+ }
+ }
+}
+
+static void
+clear_failure_queue ()
+{
+ failure_delete_queue = 0;
+}
+
+/* Compute a string to use as the base of all temporary file names.
+ It is substituted for %g. */
+
+static void
+choose_temp_base ()
+{
+ char *base = getenv ("TMPDIR");
+ int len;
+
+ if (base == (char *)0)
+ {
+#ifdef P_tmpdir
+ if (access (P_tmpdir, R_OK | W_OK) == 0)
+ base = P_tmpdir;
+#endif
+ if (base == (char *)0)
+ {
+ if (access ("/usr/tmp", R_OK | W_OK) == 0)
+ base = "/usr/tmp/";
+ else
+ base = "/tmp/";
+ }
+ }
+
+ len = strlen (base);
+ temp_filename = xmalloc (len + sizeof("/ccXXXXXX"));
+ strcpy (temp_filename, base);
+ if (len > 0 && temp_filename[len-1] != '/')
+ temp_filename[len++] = '/';
+ strcpy (temp_filename + len, "ccXXXXXX");
+
+ mktemp (temp_filename);
+ temp_filename_length = strlen (temp_filename);
+ if (temp_filename_length == 0)
+ abort ();
+}
+
+
+/* Routine to add variables to the environment. We do this to pass
+ the pathname of the gcc driver, and the directories search to the
+ collect2 program, which is being run as ld. This way, we can be
+ sure of executing the right compiler when collect2 wants to build
+ constructors and destructors. Since the environment variables we
+ use come from an obstack, we don't have to worry about allocating
+ space for them. */
+
+#ifndef HAVE_PUTENV
+
+void
+putenv (str)
+ char *str;
+{
+#ifndef VMS /* nor about VMS */
+
+ extern char **environ;
+ char **old_environ = environ;
+ char **envp;
+ int num_envs = 0;
+ int name_len = 1;
+ int str_len = strlen (str);
+ char *p = str;
+ int ch;
+
+ while ((ch = *p++) != '\0' && ch != '=')
+ name_len++;
+
+ if (!ch)
+ abort ();
+
+ /* Search for replacing an existing environment variable, and
+ count the number of total environment variables. */
+ for (envp = old_environ; *envp; envp++)
+ {
+ num_envs++;
+ if (!strncmp (str, *envp, name_len))
+ {
+ *envp = str;
+ return;
+ }
+ }
+
+ /* Add a new environment variable */
+ environ = (char **) xmalloc (sizeof (char *) * (num_envs+2));
+ *environ = str;
+ bcopy (old_environ, environ+1, sizeof (char *) * (num_envs+1));
+
+#endif /* VMS */
+}
+
+#endif /* HAVE_PUTENV */
+
+
+/* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables for collect. */
+
+static void
+putenv_from_prefixes (paths, env_var)
+ struct path_prefix *paths;
+ char *env_var;
+{
+ int suffix_len = (machine_suffix) ? strlen (machine_suffix) : 0;
+ int just_suffix_len
+ = (just_machine_suffix) ? strlen (just_machine_suffix) : 0;
+ int first_time = TRUE;
+ struct prefix_list *pprefix;
+
+ obstack_grow (&collect_obstack, env_var, strlen (env_var));
+
+ for (pprefix = paths->plist; pprefix != 0; pprefix = pprefix->next)
+ {
+ int len = strlen (pprefix->prefix);
+
+ if (machine_suffix
+ && is_directory (pprefix->prefix, machine_suffix, 0))
+ {
+ if (!first_time)
+ obstack_1grow (&collect_obstack, PATH_SEPARATOR);
+
+ first_time = FALSE;
+ obstack_grow (&collect_obstack, pprefix->prefix, len);
+ obstack_grow (&collect_obstack, machine_suffix, suffix_len);
+ }
+
+ if (just_machine_suffix
+ && pprefix->require_machine_suffix == 2
+ && is_directory (pprefix->prefix, just_machine_suffix, 0))
+ {
+ if (!first_time)
+ obstack_1grow (&collect_obstack, PATH_SEPARATOR);
+
+ first_time = FALSE;
+ obstack_grow (&collect_obstack, pprefix->prefix, len);
+ obstack_grow (&collect_obstack, just_machine_suffix,
+ just_suffix_len);
+ }
+
+ if (!pprefix->require_machine_suffix)
+ {
+ if (!first_time)
+ obstack_1grow (&collect_obstack, PATH_SEPARATOR);
+
+ first_time = FALSE;
+ obstack_grow (&collect_obstack, pprefix->prefix, len);
+ }
+ }
+ obstack_1grow (&collect_obstack, '\0');
+ putenv (obstack_finish (&collect_obstack));
+}
+
+
+/* Search for NAME using the prefix list PREFIXES. MODE is passed to
+ access to check permissions.
+ Return 0 if not found, otherwise return its name, allocated with malloc. */
+
+static char *
+find_a_file (pprefix, name, mode)
+ struct path_prefix *pprefix;
+ char *name;
+ int mode;
+{
+ char *temp;
+ char *file_suffix = ((mode & X_OK) != 0 ? EXECUTABLE_SUFFIX : "");
+ struct prefix_list *pl;
+ int len = pprefix->max_len + strlen (name) + strlen (file_suffix) + 1;
+
+ if (machine_suffix)
+ len += strlen (machine_suffix);
+
+ temp = xmalloc (len);
+
+ /* Determine the filename to execute (special case for absolute paths). */
+
+ if (*name == '/')
+ {
+ if (access (name, mode))
+ {
+ strcpy (temp, name);
+ return temp;
+ }
+ }
+ else
+ for (pl = pprefix->plist; pl; pl = pl->next)
+ {
+ if (machine_suffix)
+ {
+ strcpy (temp, pl->prefix);
+ strcat (temp, machine_suffix);
+ strcat (temp, name);
+ if (access (temp, mode) == 0)
+ {
+ if (pl->used_flag_ptr != 0)
+ *pl->used_flag_ptr = 1;
+ return temp;
+ }
+ /* Some systems have a suffix for executable files.
+ So try appending that. */
+ if (file_suffix[0] != 0)
+ {
+ strcat (temp, file_suffix);
+ if (access (temp, mode) == 0)
+ {
+ if (pl->used_flag_ptr != 0)
+ *pl->used_flag_ptr = 1;
+ return temp;
+ }
+ }
+ }
+ /* Certain prefixes are tried with just the machine type,
+ not the version. This is used for finding as, ld, etc. */
+ if (just_machine_suffix && pl->require_machine_suffix == 2)
+ {
+ strcpy (temp, pl->prefix);
+ strcat (temp, just_machine_suffix);
+ strcat (temp, name);
+ if (access (temp, mode) == 0)
+ {
+ if (pl->used_flag_ptr != 0)
+ *pl->used_flag_ptr = 1;
+ return temp;
+ }
+ /* Some systems have a suffix for executable files.
+ So try appending that. */
+ if (file_suffix[0] != 0)
+ {
+ strcat (temp, file_suffix);
+ if (access (temp, mode) == 0)
+ {
+ if (pl->used_flag_ptr != 0)
+ *pl->used_flag_ptr = 1;
+ return temp;
+ }
+ }
+ }
+ /* Certain prefixes can't be used without the machine suffix
+ when the machine or version is explicitly specified. */
+ if (!pl->require_machine_suffix)
+ {
+ strcpy (temp, pl->prefix);
+ strcat (temp, name);
+ if (access (temp, mode) == 0)
+ {
+ if (pl->used_flag_ptr != 0)
+ *pl->used_flag_ptr = 1;
+ return temp;
+ }
+ /* Some systems have a suffix for executable files.
+ So try appending that. */
+ if (file_suffix[0] != 0)
+ {
+ strcat (temp, file_suffix);
+ if (access (temp, mode) == 0)
+ {
+ if (pl->used_flag_ptr != 0)
+ *pl->used_flag_ptr = 1;
+ return temp;
+ }
+ }
+ }
+ }
+
+ free (temp);
+ return 0;
+}
+
+/* Add an entry for PREFIX in PLIST. If FIRST is set, it goes
+ at the start of the list, otherwise it goes at the end.
+
+ If WARN is nonzero, we will warn if no file is found
+ through this prefix. WARN should point to an int
+ which will be set to 1 if this entry is used.
+
+ REQUIRE_MACHINE_SUFFIX is 1 if this prefix can't be used without
+ the complete value of machine_suffix.
+ 2 means try both machine_suffix and just_machine_suffix. */
+
+static void
+add_prefix (pprefix, prefix, first, require_machine_suffix, warn)
+ struct path_prefix *pprefix;
+ char *prefix;
+ int first;
+ int require_machine_suffix;
+ int *warn;
+{
+ struct prefix_list *pl, **prev;
+ int len;
+
+ if (!first && pprefix->plist)
+ {
+ for (pl = pprefix->plist; pl->next; pl = pl->next)
+ ;
+ prev = &pl->next;
+ }
+ else
+ prev = &pprefix->plist;
+
+ /* Keep track of the longest prefix */
+
+ len = strlen (prefix);
+ if (len > pprefix->max_len)
+ pprefix->max_len = len;
+
+ pl = (struct prefix_list *) xmalloc (sizeof (struct prefix_list));
+ pl->prefix = save_string (prefix, len);
+ pl->require_machine_suffix = require_machine_suffix;
+ pl->used_flag_ptr = warn;
+ if (warn)
+ *warn = 0;
+
+ if (*prev)
+ pl->next = *prev;
+ else
+ pl->next = (struct prefix_list *) 0;
+ *prev = pl;
+}
+
+/* Print warnings for any prefixes in the list PPREFIX that were not used. */
+
+static void
+unused_prefix_warnings (pprefix)
+ struct path_prefix *pprefix;
+{
+ struct prefix_list *pl = pprefix->plist;
+
+ while (pl)
+ {
+ if (pl->used_flag_ptr != 0 && !*pl->used_flag_ptr)
+ {
+ error ("file path prefix `%s' never used",
+ pl->prefix);
+ /* Prevent duplicate warnings. */
+ *pl->used_flag_ptr = 1;
+ }
+ pl = pl->next;
+ }
+}
+
+/* Get rid of all prefixes built up so far in *PLISTP. */
+
+static void
+free_path_prefix (pprefix)
+ struct path_prefix *pprefix;
+{
+ struct prefix_list *pl = pprefix->plist;
+ struct prefix_list *temp;
+
+ while (pl)
+ {
+ temp = pl;
+ pl = pl->next;
+ free (temp->prefix);
+ free ((char *) temp);
+ }
+ pprefix->plist = (struct prefix_list *) 0;
+}
+
+/* stdin file number. */
+#define STDIN_FILE_NO 0
+
+/* stdout file number. */
+#define STDOUT_FILE_NO 1
+
+/* value of `pipe': port index for reading. */
+#define READ_PORT 0
+
+/* value of `pipe': port index for writing. */
+#define WRITE_PORT 1
+
+/* Pipe waiting from last process, to be used as input for the next one.
+ Value is STDIN_FILE_NO if no pipe is waiting
+ (i.e. the next command is the first of a group). */
+
+static int last_pipe_input;
+
+/* Fork one piped subcommand. FUNC is the system call to use
+ (either execv or execvp). ARGV is the arg vector to use.
+ NOT_LAST is nonzero if this is not the last subcommand
+ (i.e. its output should be piped to the next one.) */
+
+#ifndef OS2
+#ifdef __MSDOS__
+
+/* Declare these to avoid compilation error. They won't be called. */
+int execv(const char *a, const char **b){}
+int execvp(const char *a, const char **b){}
+
+static int
+pexecute (search_flag, program, argv, not_last)
+ int search_flag;
+ char *program;
+ char *argv[];
+ int not_last;
+{
+ char *scmd;
+ FILE *argfile;
+ int i;
+
+ scmd = (char *)malloc (strlen (program) + strlen (temp_filename) + 6);
+ sprintf (scmd, "%s @%s.gp", program, temp_filename);
+ argfile = fopen (scmd+strlen (program) + 2, "w");
+ if (argfile == 0)
+ pfatal_with_name (scmd + strlen (program) + 2);
+
+ for (i=1; argv[i]; i++)
+ {
+ char *cp;
+ for (cp = argv[i]; *cp; cp++)
+ {
+ if (*cp == '"' || *cp == '\'' || *cp == '\\' || isspace (*cp))
+ fputc ('\\', argfile);
+ fputc (*cp, argfile);
+ }
+ fputc ('\n', argfile);
+ }
+ fclose (argfile);
+
+ i = system (scmd);
+
+ remove (scmd + strlen (program) + 2);
+ return i << 8;
+}
+
+#else /* not __MSDOS__ */
+
+static int
+pexecute (search_flag, program, argv, not_last)
+ int search_flag;
+ char *program;
+ char *argv[];
+ int not_last;
+{
+ int (*func)() = (search_flag ? execv : execvp);
+ int pid;
+ int pdes[2];
+ int input_desc = last_pipe_input;
+ int output_desc = STDOUT_FILE_NO;
+ int retries, sleep_interval;
+
+ /* If this isn't the last process, make a pipe for its output,
+ and record it as waiting to be the input to the next process. */
+
+ if (not_last)
+ {
+ if (pipe (pdes) < 0)
+ pfatal_with_name ("pipe");
+ output_desc = pdes[WRITE_PORT];
+ last_pipe_input = pdes[READ_PORT];
+ }
+ else
+ last_pipe_input = STDIN_FILE_NO;
+
+ /* Fork a subprocess; wait and retry if it fails. */
+ sleep_interval = 1;
+ for (retries = 0; retries < 4; retries++)
+ {
+ pid = vfork ();
+ if (pid >= 0)
+ break;
+ sleep (sleep_interval);
+ sleep_interval *= 2;
+ }
+
+ switch (pid)
+ {
+ case -1:
+#ifdef vfork
+ pfatal_with_name ("fork");
+#else
+ pfatal_with_name ("vfork");
+#endif
+ /* NOTREACHED */
+ return 0;
+
+ case 0: /* child */
+ /* Move the input and output pipes into place, if nec. */
+ if (input_desc != STDIN_FILE_NO)
+ {
+ close (STDIN_FILE_NO);
+ dup (input_desc);
+ close (input_desc);
+ }
+ if (output_desc != STDOUT_FILE_NO)
+ {
+ close (STDOUT_FILE_NO);
+ dup (output_desc);
+ close (output_desc);
+ }
+
+ /* Close the parent's descs that aren't wanted here. */
+ if (last_pipe_input != STDIN_FILE_NO)
+ close (last_pipe_input);
+
+ /* Exec the program. */
+ (*func) (program, argv);
+ perror_exec (program);
+ exit (-1);
+ /* NOTREACHED */
+ return 0;
+
+ default:
+ /* In the parent, after forking.
+ Close the descriptors that we made for this child. */
+ if (input_desc != STDIN_FILE_NO)
+ close (input_desc);
+ if (output_desc != STDOUT_FILE_NO)
+ close (output_desc);
+
+ /* Return child's process number. */
+ return pid;
+ }
+}
+
+#endif /* not __MSDOS__ */
+#else /* not OS2 */
+
+static int
+pexecute (search_flag, program, argv, not_last)
+ int search_flag;
+ char *program;
+ char *argv[];
+ int not_last;
+{
+ return (search_flag ? spawnv : spawnvp) (1, program, argv);
+}
+#endif /* not OS2 */
+
+/* Execute the command specified by the arguments on the current line of spec.
+ When using pipes, this includes several piped-together commands
+ with `|' between them.
+
+ Return 0 if successful, -1 if failed. */
+
+static int
+execute ()
+{
+ int i;
+ int n_commands; /* # of command. */
+ char *string;
+ struct command
+ {
+ char *prog; /* program name. */
+ char **argv; /* vector of args. */
+ int pid; /* pid of process for this command. */
+ };
+
+ struct command *commands; /* each command buffer with above info. */
+
+ /* Count # of piped commands. */
+ for (n_commands = 1, i = 0; i < argbuf_index; i++)
+ if (strcmp (argbuf[i], "|") == 0)
+ n_commands++;
+
+ /* Get storage for each command. */
+ commands
+ = (struct command *) alloca (n_commands * sizeof (struct command));
+
+ /* Split argbuf into its separate piped processes,
+ and record info about each one.
+ Also search for the programs that are to be run. */
+
+ commands[0].prog = argbuf[0]; /* first command. */
+ commands[0].argv = &argbuf[0];
+ string = find_a_file (&exec_prefix, commands[0].prog, X_OK);
+ if (string)
+ commands[0].argv[0] = string;
+
+ for (n_commands = 1, i = 0; i < argbuf_index; i++)
+ if (strcmp (argbuf[i], "|") == 0)
+ { /* each command. */
+#ifdef __MSDOS__
+ fatal ("-pipe not supported under MS-DOS");
+#endif
+ argbuf[i] = 0; /* termination of command args. */
+ commands[n_commands].prog = argbuf[i + 1];
+ commands[n_commands].argv = &argbuf[i + 1];
+ string = find_a_file (&exec_prefix, commands[n_commands].prog, X_OK);
+ if (string)
+ commands[n_commands].argv[0] = string;
+ n_commands++;
+ }
+
+ argbuf[argbuf_index] = 0;
+
+ /* If -v, print what we are about to do, and maybe query. */
+
+ if (verbose_flag)
+ {
+ /* Print each piped command as a separate line. */
+ for (i = 0; i < n_commands ; i++)
+ {
+ char **j;
+
+ for (j = commands[i].argv; *j; j++)
+ fprintf (stderr, " %s", *j);
+
+ /* Print a pipe symbol after all but the last command. */
+ if (i + 1 != n_commands)
+ fprintf (stderr, " |");
+ fprintf (stderr, "\n");
+ }
+ fflush (stderr);
+#ifdef DEBUG
+ fprintf (stderr, "\nGo ahead? (y or n) ");
+ fflush (stderr);
+ i = getchar ();
+ if (i != '\n')
+ while (getchar () != '\n') ;
+ if (i != 'y' && i != 'Y')
+ return 0;
+#endif /* DEBUG */
+ }
+
+ /* Run each piped subprocess. */
+
+ last_pipe_input = STDIN_FILE_NO;
+ for (i = 0; i < n_commands; i++)
+ {
+ char *string = commands[i].argv[0];
+
+ commands[i].pid = pexecute (string != commands[i].prog,
+ string, commands[i].argv,
+ i + 1 < n_commands);
+
+ if (string != commands[i].prog)
+ free (string);
+ }
+
+ execution_count++;
+
+ /* Wait for all the subprocesses to finish.
+ We don't care what order they finish in;
+ we know that N_COMMANDS waits will get them all. */
+
+ {
+ int ret_code = 0;
+
+ for (i = 0; i < n_commands; i++)
+ {
+ int status;
+ int pid;
+ char *prog;
+
+#ifdef __MSDOS__
+ status = pid = commands[i].pid;
+#else
+ pid = wait (&status);
+#endif
+ if (pid < 0)
+ abort ();
+
+ if (status != 0)
+ {
+ int j;
+ for (j = 0; j < n_commands; j++)
+ if (commands[j].pid == pid)
+ prog = commands[j].prog;
+
+ if ((status & 0x7F) != 0)
+ {
+ fatal ("Internal compiler error: program %s got fatal signal %d",
+ prog, (status & 0x7F));
+ signal_count++;
+ }
+ if (((status & 0xFF00) >> 8) >= MIN_FATAL_STATUS)
+ ret_code = -1;
+ }
+ }
+ return ret_code;
+ }
+}
+
+/* Find all the switches given to us
+ and make a vector describing them.
+ The elements of the vector are strings, one per switch given.
+ If a switch uses following arguments, then the `part1' field
+ is the switch itself and the `args' field
+ is a null-terminated vector containing the following arguments.
+ The `valid' field is nonzero if any spec has looked at this switch;
+ if it remains zero at the end of the run, it must be meaningless. */
+
+struct switchstr
+{
+ char *part1;
+ char **args;
+ int valid;
+};
+
+static struct switchstr *switches;
+
+static int n_switches;
+
+struct infile
+{
+ char *name;
+ char *language;
+};
+
+/* Also a vector of input files specified. */
+
+static struct infile *infiles;
+
+static int n_infiles;
+
+/* And a vector of corresponding output files is made up later. */
+
+static char **outfiles;
+
+/* Create the vector `switches' and its contents.
+ Store its length in `n_switches'. */
+
+static void
+process_command (argc, argv)
+ int argc;
+ char **argv;
+{
+ register int i;
+ char *temp;
+ char *spec_lang = 0;
+ int last_language_n_infiles;
+
+ gcc_exec_prefix = getenv ("GCC_EXEC_PREFIX");
+
+ n_switches = 0;
+ n_infiles = 0;
+
+ /* Default for -V is our version number, ending at first space. */
+ spec_version = save_string (version_string, strlen (version_string));
+ for (temp = spec_version; *temp && *temp != ' '; temp++);
+ if (*temp) *temp = '\0';
+
+ /* Set up the default search paths. */
+
+ if (gcc_exec_prefix)
+ {
+ add_prefix (&exec_prefix, gcc_exec_prefix, 0, 0, NULL_PTR);
+ add_prefix (&startfile_prefix, gcc_exec_prefix, 0, 0, NULL_PTR);
+ }
+
+ /* COMPILER_PATH and LIBRARY_PATH have values
+ that are lists of directory names with colons. */
+
+ temp = getenv ("COMPILER_PATH");
+ if (temp)
+ {
+ char *startp, *endp;
+ char *nstore = (char *) alloca (strlen (temp) + 3);
+
+ startp = endp = temp;
+ while (1)
+ {
+ if (*endp == PATH_SEPARATOR || *endp == 0)
+ {
+ strncpy (nstore, startp, endp-startp);
+ if (endp == startp)
+ {
+ strcpy (nstore, "./");
+ }
+ else if (endp[-1] != '/')
+ {
+ nstore[endp-startp] = '/';
+ nstore[endp-startp+1] = 0;
+ }
+ else
+ nstore[endp-startp] = 0;
+ add_prefix (&exec_prefix, nstore, 0, 0, NULL_PTR);
+ if (*endp == 0)
+ break;
+ endp = startp = endp + 1;
+ }
+ else
+ endp++;
+ }
+ }
+
+ temp = getenv ("LIBRARY_PATH");
+ if (temp)
+ {
+ char *startp, *endp;
+ char *nstore = (char *) alloca (strlen (temp) + 3);
+
+ startp = endp = temp;
+ while (1)
+ {
+ if (*endp == PATH_SEPARATOR || *endp == 0)
+ {
+ strncpy (nstore, startp, endp-startp);
+ if (endp == startp)
+ {
+ strcpy (nstore, "./");
+ }
+ else if (endp[-1] != '/')
+ {
+ nstore[endp-startp] = '/';
+ nstore[endp-startp+1] = 0;
+ }
+ else
+ nstore[endp-startp] = 0;
+ add_prefix (&startfile_prefix, nstore, 0, 0, NULL_PTR);
+ if (*endp == 0)
+ break;
+ endp = startp = endp + 1;
+ }
+ else
+ endp++;
+ }
+ }
+
+ /* Use LPATH like LIBRARY_PATH (for the CMU build program). */
+ temp = getenv ("LPATH");
+ if (temp)
+ {
+ char *startp, *endp;
+ char *nstore = (char *) alloca (strlen (temp) + 3);
+
+ startp = endp = temp;
+ while (1)
+ {
+ if (*endp == PATH_SEPARATOR || *endp == 0)
+ {
+ strncpy (nstore, startp, endp-startp);
+ if (endp == startp)
+ {
+ strcpy (nstore, "./");
+ }
+ else if (endp[-1] != '/')
+ {
+ nstore[endp-startp] = '/';
+ nstore[endp-startp+1] = 0;
+ }
+ else
+ nstore[endp-startp] = 0;
+ add_prefix (&startfile_prefix, nstore, 0, 0, NULL_PTR);
+ if (*endp == 0)
+ break;
+ endp = startp = endp + 1;
+ }
+ else
+ endp++;
+ }
+ }
+
+ /* Convert new-style -- options to old-style. */
+ translate_options (&argc, &argv);
+
+ /* Scan argv twice. Here, the first time, just count how many switches
+ there will be in their vector, and how many input files in theirs.
+ Here we also parse the switches that cc itself uses (e.g. -v). */
+
+ for (i = 1; i < argc; i++)
+ {
+ if (! strcmp (argv[i], "-dumpspecs"))
+ {
+ printf ("*asm:\n%s\n\n", asm_spec);
+ printf ("*asm_final:\n%s\n\n", asm_final_spec);
+ printf ("*cpp:\n%s\n\n", cpp_spec);
+ printf ("*cc1:\n%s\n\n", cc1_spec);
+ printf ("*cc1plus:\n%s\n\n", cc1plus_spec);
+ printf ("*endfile:\n%s\n\n", endfile_spec);
+ printf ("*link:\n%s\n\n", link_spec);
+ printf ("*lib:\n%s\n\n", lib_spec);
+ printf ("*startfile:\n%s\n\n", startfile_spec);
+ printf ("*switches_need_spaces:\n%s\n\n", switches_need_spaces);
+ printf ("*signed_char:\n%s\n\n", signed_char_spec);
+ printf ("*predefines:\n%s\n\n", cpp_predefines);
+ printf ("*cross_compile:\n%d\n\n", cross_compile);
+
+ exit (0);
+ }
+ else if (! strcmp (argv[i], "-dumpversion"))
+ {
+ printf ("%s\n", version_string);
+ exit (0);
+ }
+ else if (! strcmp (argv[i], "-print-libgcc-file-name"))
+ {
+ print_libgcc_file_name = 1;
+ }
+ else if (! strcmp (argv[i], "-Xlinker"))
+ {
+ /* Pass the argument of this option to the linker when we link. */
+
+ if (i + 1 == argc)
+ fatal ("argument to `-Xlinker' is missing");
+
+ n_linker_options++;
+ if (!linker_options)
+ linker_options
+ = (char **) xmalloc (n_linker_options * sizeof (char **));
+ else
+ linker_options
+ = (char **) xrealloc (linker_options,
+ n_linker_options * sizeof (char **));
+
+ linker_options[n_linker_options - 1] = argv[++i];
+ }
+ else if (! strncmp (argv[i], "-Wl,", 4))
+ {
+ int prev, j;
+ /* Pass the rest of this option to the linker when we link. */
+
+ n_linker_options++;
+ if (!linker_options)
+ linker_options
+ = (char **) xmalloc (n_linker_options * sizeof (char **));
+ else
+ linker_options
+ = (char **) xrealloc (linker_options,
+ n_linker_options * sizeof (char **));
+
+ /* Split the argument at commas. */
+ prev = 4;
+ for (j = 4; argv[i][j]; j++)
+ if (argv[i][j] == ',')
+ {
+ linker_options[n_linker_options - 1]
+ = save_string (argv[i] + prev, j - prev);
+ n_linker_options++;
+ linker_options
+ = (char **) xrealloc (linker_options,
+ n_linker_options * sizeof (char **));
+ prev = j + 1;
+ }
+ /* Record the part after the last comma. */
+ linker_options[n_linker_options - 1] = argv[i] + prev;
+ }
+ else if (! strncmp (argv[i], "-Wa,", 4))
+ {
+ int prev, j;
+ /* Pass the rest of this option to the assembler. */
+
+ n_assembler_options++;
+ if (!assembler_options)
+ assembler_options
+ = (char **) xmalloc (n_assembler_options * sizeof (char **));
+ else
+ assembler_options
+ = (char **) xrealloc (assembler_options,
+ n_assembler_options * sizeof (char **));
+
+ /* Split the argument at commas. */
+ prev = 4;
+ for (j = 4; argv[i][j]; j++)
+ if (argv[i][j] == ',')
+ {
+ assembler_options[n_assembler_options - 1]
+ = save_string (argv[i] + prev, j - prev);
+ n_assembler_options++;
+ assembler_options
+ = (char **) xrealloc (assembler_options,
+ n_assembler_options * sizeof (char **));
+ prev = j + 1;
+ }
+ /* Record the part after the last comma. */
+ assembler_options[n_assembler_options - 1] = argv[i] + prev;
+ }
+ else if (argv[i][0] == '+' && argv[i][1] == 'e')
+ /* The +e options to the C++ front-end. */
+ n_switches++;
+ else if (argv[i][0] == '-' && argv[i][1] != 0 && argv[i][1] != 'l')
+ {
+ register char *p = &argv[i][1];
+ register int c = *p;
+
+ switch (c)
+ {
+ case 'b':
+ if (p[1] == 0 && i + 1 == argc)
+ fatal ("argument to `-b' is missing");
+ if (p[1] == 0)
+ spec_machine = argv[++i];
+ else
+ spec_machine = p + 1;
+ break;
+
+ case 'B':
+ {
+ int *temp = (int *) xmalloc (sizeof (int));
+ char *value;
+ if (p[1] == 0 && i + 1 == argc)
+ fatal ("argument to `-B' is missing");
+ if (p[1] == 0)
+ value = argv[++i];
+ else
+ value = p + 1;
+ add_prefix (&exec_prefix, value, 1, 0, temp);
+ add_prefix (&startfile_prefix, value, 1, 0, temp);
+ }
+ break;
+
+ case 'v': /* Print our subcommands and print versions. */
+ n_switches++;
+ /* If they do anything other than exactly `-v', don't set
+ verbose_flag; rather, continue on to give the error. */
+ if (p[1] != 0)
+ break;
+ verbose_flag++;
+ break;
+
+ case 'V':
+ if (p[1] == 0 && i + 1 == argc)
+ fatal ("argument to `-V' is missing");
+ if (p[1] == 0)
+ spec_version = argv[++i];
+ else
+ spec_version = p + 1;
+ break;
+
+ case 's':
+ if (!strcmp (p, "save-temps"))
+ {
+ save_temps_flag = 1;
+ n_switches++;
+ break;
+ }
+ default:
+ n_switches++;
+
+ if (SWITCH_TAKES_ARG (c) > (p[1] != 0))
+ i += SWITCH_TAKES_ARG (c) - (p[1] != 0);
+ else if (WORD_SWITCH_TAKES_ARG (p))
+ i += WORD_SWITCH_TAKES_ARG (p);
+ }
+ }
+ else
+ n_infiles++;
+ }
+
+ /* Set up the search paths before we go looking for config files. */
+
+ /* These come before the md prefixes so that we will find gcc's subcommands
+ (such as cpp) rather than those of the host system. */
+ /* Use 2 as fourth arg meaning try just the machine as a suffix,
+ as well as trying the machine and the version. */
+ add_prefix (&exec_prefix, standard_exec_prefix, 0, 2, NULL_PTR);
+ add_prefix (&exec_prefix, standard_exec_prefix_1, 0, 2, NULL_PTR);
+
+ add_prefix (&startfile_prefix, standard_exec_prefix, 0, 1, NULL_PTR);
+ add_prefix (&startfile_prefix, standard_exec_prefix_1, 0, 1, NULL_PTR);
+
+ tooldir_prefix = concat (tooldir_base_prefix, spec_machine, "/");
+
+ /* If tooldir is relative, base it on exec_prefix. A relative
+ tooldir lets us move the installed tree as a unit.
+
+ If GCC_EXEC_PREFIX is defined, then we want to add two relative
+ directories, so that we can search both the user specified directory
+ and the standard place. */
+
+ if (*tooldir_prefix != '/')
+ {
+ if (gcc_exec_prefix)
+ {
+ char *gcc_exec_tooldir_prefix
+ = concat (concat (gcc_exec_prefix, spec_machine, "/"),
+ concat (spec_version, "/", tooldir_prefix),
+ "");
+
+ add_prefix (&exec_prefix, concat (gcc_exec_tooldir_prefix, "bin", "/"),
+ 0, 0, NULL_PTR);
+ add_prefix (&startfile_prefix, concat (gcc_exec_tooldir_prefix, "lib", "/"),
+ 0, 0, NULL_PTR);
+ }
+
+ tooldir_prefix = concat (concat (standard_exec_prefix, spec_machine, "/"),
+ concat (spec_version, "/", tooldir_prefix),
+ "");
+ }
+
+ add_prefix (&exec_prefix, concat (tooldir_prefix, "bin", "/"),
+ 0, 0, NULL_PTR);
+ add_prefix (&startfile_prefix, concat (tooldir_prefix, "lib", "/"),
+ 0, 0, NULL_PTR);
+
+ /* More prefixes are enabled in main, after we read the specs file
+ and determine whether this is cross-compilation or not. */
+
+
+ /* Then create the space for the vectors and scan again. */
+
+ switches = ((struct switchstr *)
+ xmalloc ((n_switches + 1) * sizeof (struct switchstr)));
+ infiles = (struct infile *) xmalloc ((n_infiles + 1) * sizeof (struct infile));
+ n_switches = 0;
+ n_infiles = 0;
+ last_language_n_infiles = -1;
+
+ /* This, time, copy the text of each switch and store a pointer
+ to the copy in the vector of switches.
+ Store all the infiles in their vector. */
+
+ for (i = 1; i < argc; i++)
+ {
+ /* Just skip the switches that were handled by the preceding loop. */
+ if (!strcmp (argv[i], "-Xlinker"))
+ i++;
+ else if (! strncmp (argv[i], "-Wl,", 4))
+ ;
+ else if (! strncmp (argv[i], "-Wa,", 4))
+ ;
+ else if (! strcmp (argv[i], "-print-libgcc-file-name"))
+ ;
+ else if (argv[i][0] == '+' && argv[i][1] == 'e')
+ {
+ /* Compensate for the +e options to the C++ front-end;
+ they're there simply for cfront call-compatibility. We do
+ some magic in default_compilers to pass them down properly.
+ Note we deliberately start at the `+' here, to avoid passing
+ -e0 or -e1 down into the linker. */
+ switches[n_switches].part1 = &argv[i][0];
+ switches[n_switches].args = 0;
+ switches[n_switches].valid = 0;
+ n_switches++;
+ }
+ else if (argv[i][0] == '-' && argv[i][1] != 0 && argv[i][1] != 'l')
+ {
+ register char *p = &argv[i][1];
+ register int c = *p;
+
+ if (c == 'B' || c == 'b' || c == 'V')
+ {
+ /* Skip a separate arg, if any. */
+ if (p[1] == 0)
+ i++;
+ continue;
+ }
+ if (c == 'x')
+ {
+ if (p[1] == 0 && i + 1 == argc)
+ fatal ("argument to `-x' is missing");
+ if (p[1] == 0)
+ spec_lang = argv[++i];
+ else
+ spec_lang = p + 1;
+ if (! strcmp (spec_lang, "none"))
+ /* Suppress the warning if -xnone comes after the last input file,
+ because alternate command interfaces like g++ might find it
+ useful to place -xnone after each input file. */
+ spec_lang = 0;
+ else
+ last_language_n_infiles = n_infiles;
+ continue;
+ }
+ switches[n_switches].part1 = p;
+ /* Deal with option arguments in separate argv elements. */
+ if ((SWITCH_TAKES_ARG (c) > (p[1] != 0))
+ || WORD_SWITCH_TAKES_ARG (p)) {
+ int j = 0;
+ int n_args = WORD_SWITCH_TAKES_ARG (p);
+
+ if (n_args == 0) {
+ /* Count only the option arguments in separate argv elements. */
+ n_args = SWITCH_TAKES_ARG (c) - (p[1] != 0);
+ }
+ if (i + n_args >= argc)
+ fatal ("argument to `-%s' is missing", p);
+ switches[n_switches].args
+ = (char **) xmalloc ((n_args + 1) * sizeof (char *));
+ while (j < n_args)
+ switches[n_switches].args[j++] = argv[++i];
+ /* Null-terminate the vector. */
+ switches[n_switches].args[j] = 0;
+ } else if (*switches_need_spaces != 0 && (c == 'o' || c == 'L')) {
+ /* On some systems, ld cannot handle -o or -L without space.
+ So split the -o or -L from its argument. */
+ switches[n_switches].part1 = (c == 'o' ? "o" : "L");
+ switches[n_switches].args = (char **) xmalloc (2 * sizeof (char *));
+ switches[n_switches].args[0] = xmalloc (strlen (p));
+ strcpy (switches[n_switches].args[0], &p[1]);
+ switches[n_switches].args[1] = 0;
+ } else
+ switches[n_switches].args = 0;
+ switches[n_switches].valid = 0;
+ /* This is always valid, since gcc.c itself understands it. */
+ if (!strcmp (p, "save-temps"))
+ switches[n_switches].valid = 1;
+ n_switches++;
+ }
+ else
+ {
+ if ((argv[i][0] != '-' || argv[i][1] != 'l')
+ && access (argv[i], R_OK) < 0)
+ {
+ perror_with_name (argv[i]);
+ error_count++;
+ }
+ else
+ {
+ infiles[n_infiles].language = spec_lang;
+ infiles[n_infiles++].name = argv[i];
+ }
+ }
+ }
+
+ if (n_infiles == last_language_n_infiles)
+ error ("Warning: `-x %s' after last input file has no effect", spec_lang);
+
+ switches[n_switches].part1 = 0;
+ infiles[n_infiles].name = 0;
+
+ /* If we have a GCC_EXEC_PREFIX envvar, modify it for cpp's sake. */
+ if (gcc_exec_prefix)
+ {
+ temp = (char *) xmalloc (strlen (gcc_exec_prefix) + strlen (spec_version)
+ + strlen (spec_machine) + 3);
+ strcpy (temp, gcc_exec_prefix);
+ strcat (temp, spec_machine);
+ strcat (temp, "/");
+ strcat (temp, spec_version);
+ strcat (temp, "/");
+ gcc_exec_prefix = temp;
+ }
+}
+
+/* Process a spec string, accumulating and running commands. */
+
+/* These variables describe the input file name.
+ input_file_number is the index on outfiles of this file,
+ so that the output file name can be stored for later use by %o.
+ input_basename is the start of the part of the input file
+ sans all directory names, and basename_length is the number
+ of characters starting there excluding the suffix .c or whatever. */
+
+static char *input_filename;
+static int input_file_number;
+static int input_filename_length;
+static int basename_length;
+static char *input_basename;
+static char *input_suffix;
+
+/* These are variables used within do_spec and do_spec_1. */
+
+/* Nonzero if an arg has been started and not yet terminated
+ (with space, tab or newline). */
+static int arg_going;
+
+/* Nonzero means %d or %g has been seen; the next arg to be terminated
+ is a temporary file name. */
+static int delete_this_arg;
+
+/* Nonzero means %w has been seen; the next arg to be terminated
+ is the output file name of this compilation. */
+static int this_is_output_file;
+
+/* Nonzero means %s has been seen; the next arg to be terminated
+ is the name of a library file and we should try the standard
+ search dirs for it. */
+static int this_is_library_file;
+
+/* Nonzero means that the input of this command is coming from a pipe. */
+static int input_from_pipe;
+
+/* Process the spec SPEC and run the commands specified therein.
+ Returns 0 if the spec is successfully processed; -1 if failed. */
+
+static int
+do_spec (spec)
+ char *spec;
+{
+ int value;
+
+ clear_args ();
+ arg_going = 0;
+ delete_this_arg = 0;
+ this_is_output_file = 0;
+ this_is_library_file = 0;
+ input_from_pipe = 0;
+
+ value = do_spec_1 (spec, 0, NULL_PTR);
+
+ /* Force out any unfinished command.
+ If -pipe, this forces out the last command if it ended in `|'. */
+ if (value == 0)
+ {
+ if (argbuf_index > 0 && !strcmp (argbuf[argbuf_index - 1], "|"))
+ argbuf_index--;
+
+ if (argbuf_index > 0)
+ value = execute ();
+ }
+
+ return value;
+}
+
+/* Process the sub-spec SPEC as a portion of a larger spec.
+ This is like processing a whole spec except that we do
+ not initialize at the beginning and we do not supply a
+ newline by default at the end.
+ INSWITCH nonzero means don't process %-sequences in SPEC;
+ in this case, % is treated as an ordinary character.
+ This is used while substituting switches.
+ INSWITCH nonzero also causes SPC not to terminate an argument.
+
+ Value is zero unless a line was finished
+ and the command on that line reported an error. */
+
+static int
+do_spec_1 (spec, inswitch, soft_matched_part)
+ char *spec;
+ int inswitch;
+ char *soft_matched_part;
+{
+ register char *p = spec;
+ register int c;
+ int i;
+ char *string;
+ int value;
+
+ while (c = *p++)
+ /* If substituting a switch, treat all chars like letters.
+ Otherwise, NL, SPC, TAB and % are special. */
+ switch (inswitch ? 'a' : c)
+ {
+ case '\n':
+ /* End of line: finish any pending argument,
+ then run the pending command if one has been started. */
+ if (arg_going)
+ {
+ obstack_1grow (&obstack, 0);
+ string = obstack_finish (&obstack);
+ if (this_is_library_file)
+ string = find_file (string);
+ store_arg (string, delete_this_arg, this_is_output_file);
+ if (this_is_output_file)
+ outfiles[input_file_number] = string;
+ }
+ arg_going = 0;
+
+ if (argbuf_index > 0 && !strcmp (argbuf[argbuf_index - 1], "|"))
+ {
+ int i;
+ for (i = 0; i < n_switches; i++)
+ if (!strcmp (switches[i].part1, "pipe"))
+ break;
+
+ /* A `|' before the newline means use a pipe here,
+ but only if -pipe was specified.
+ Otherwise, execute now and don't pass the `|' as an arg. */
+ if (i < n_switches)
+ {
+ input_from_pipe = 1;
+ switches[i].valid = 1;
+ break;
+ }
+ else
+ argbuf_index--;
+ }
+
+ if (argbuf_index > 0)
+ {
+ value = execute ();
+ if (value)
+ return value;
+ }
+ /* Reinitialize for a new command, and for a new argument. */
+ clear_args ();
+ arg_going = 0;
+ delete_this_arg = 0;
+ this_is_output_file = 0;
+ this_is_library_file = 0;
+ input_from_pipe = 0;
+ break;
+
+ case '|':
+ /* End any pending argument. */
+ if (arg_going)
+ {
+ obstack_1grow (&obstack, 0);
+ string = obstack_finish (&obstack);
+ if (this_is_library_file)
+ string = find_file (string);
+ store_arg (string, delete_this_arg, this_is_output_file);
+ if (this_is_output_file)
+ outfiles[input_file_number] = string;
+ }
+
+ /* Use pipe */
+ obstack_1grow (&obstack, c);
+ arg_going = 1;
+ break;
+
+ case '\t':
+ case ' ':
+ /* Space or tab ends an argument if one is pending. */
+ if (arg_going)
+ {
+ obstack_1grow (&obstack, 0);
+ string = obstack_finish (&obstack);
+ if (this_is_library_file)
+ string = find_file (string);
+ store_arg (string, delete_this_arg, this_is_output_file);
+ if (this_is_output_file)
+ outfiles[input_file_number] = string;
+ }
+ /* Reinitialize for a new argument. */
+ arg_going = 0;
+ delete_this_arg = 0;
+ this_is_output_file = 0;
+ this_is_library_file = 0;
+ break;
+
+ case '%':
+ switch (c = *p++)
+ {
+ case 0:
+ fatal ("Invalid specification! Bug in cc.");
+
+ case 'b':
+ obstack_grow (&obstack, input_basename, basename_length);
+ arg_going = 1;
+ break;
+
+ case 'd':
+ delete_this_arg = 2;
+ break;
+
+ /* Dump out the directories specified with LIBRARY_PATH,
+ followed by the absolute directories
+ that we search for startfiles. */
+ case 'D':
+ {
+ struct prefix_list *pl = startfile_prefix.plist;
+ int bufsize = 100;
+ char *buffer = (char *) xmalloc (bufsize);
+ int idx;
+
+ for (; pl; pl = pl->next)
+ {
+#ifdef RELATIVE_PREFIX_NOT_LINKDIR
+ /* Used on systems which record the specified -L dirs
+ and use them to search for dynamic linking. */
+ /* Relative directories always come from -B,
+ and it is better not to use them for searching
+ at run time. In particular, stage1 loses */
+ if (pl->prefix[0] != '/')
+ continue;
+#endif
+ if (machine_suffix)
+ {
+ if (is_directory (pl->prefix, machine_suffix, 1))
+ {
+ do_spec_1 ("-L", 0, NULL_PTR);
+#ifdef SPACE_AFTER_L_OPTION
+ do_spec_1 (" ", 0, NULL_PTR);
+#endif
+ do_spec_1 (pl->prefix, 1, NULL_PTR);
+ /* Remove slash from machine_suffix. */
+ if (strlen (machine_suffix) >= bufsize)
+ bufsize = strlen (machine_suffix) * 2 + 1;
+ buffer = (char *) xrealloc (buffer, bufsize);
+ strcpy (buffer, machine_suffix);
+ idx = strlen (buffer);
+ if (buffer[idx - 1] == '/')
+ buffer[idx - 1] = 0;
+ do_spec_1 (buffer, 1, NULL_PTR);
+ /* Make this a separate argument. */
+ do_spec_1 (" ", 0, NULL_PTR);
+ }
+ }
+ if (!pl->require_machine_suffix)
+ {
+ if (is_directory (pl->prefix, "", 1))
+ {
+ do_spec_1 ("-L", 0, NULL_PTR);
+#ifdef SPACE_AFTER_L_OPTION
+ do_spec_1 (" ", 0, NULL_PTR);
+#endif
+ /* Remove slash from pl->prefix. */
+ if (strlen (pl->prefix) >= bufsize)
+ bufsize = strlen (pl->prefix) * 2 + 1;
+ buffer = (char *) xrealloc (buffer, bufsize);
+ strcpy (buffer, pl->prefix);
+ idx = strlen (buffer);
+ if (buffer[idx - 1] == '/')
+ buffer[idx - 1] = 0;
+ do_spec_1 (buffer, 1, NULL_PTR);
+ /* Make this a separate argument. */
+ do_spec_1 (" ", 0, NULL_PTR);
+ }
+ }
+ }
+ free (buffer);
+ }
+ break;
+
+ case 'e':
+ /* {...:%efoo} means report an error with `foo' as error message
+ and don't execute any more commands for this file. */
+ {
+ char *q = p;
+ char *buf;
+ while (*p != 0 && *p != '\n') p++;
+ buf = (char *) alloca (p - q + 1);
+ strncpy (buf, q, p - q);
+ buf[p - q] = 0;
+ error ("%s", buf);
+ return -1;
+ }
+ break;
+
+ case 'g':
+ case 'u':
+ case 'U':
+ if (save_temps_flag)
+ obstack_grow (&obstack, input_basename, basename_length);
+ else
+ {
+#ifdef MKTEMP_EACH_FILE
+ /* ??? This has a problem: the total number of
+ values mktemp can return is limited.
+ That matters for the names of object files.
+ In 2.4, do something about that. */
+ struct temp_name *t;
+ char *suffix = p;
+ while (*p == '.' || isalpha (*p))
+ p++;
+
+ /* See if we already have an association of %g/%u/%U and
+ suffix. */
+ for (t = temp_names; t; t = t->next)
+ if (t->length == p - suffix
+ && strncmp (t->suffix, suffix, p - suffix) == 0
+ && t->unique == (c != 'g'))
+ break;
+
+ /* Make a new association if needed. %u requires one. */
+ if (t == 0 || c == 'u')
+ {
+ if (t == 0)
+ {
+ t = (struct temp_name *) xmalloc (sizeof (struct temp_name));
+ t->next = temp_names;
+ temp_names = t;
+ }
+ t->length = p - suffix;
+ t->suffix = save_string (suffix, p - suffix);
+ t->unique = (c != 'g');
+ choose_temp_base ();
+ t->filename = temp_filename;
+ t->filename_length = temp_filename_length;
+ }
+
+ obstack_grow (&obstack, t->filename, t->filename_length);
+ delete_this_arg = 1;
+#else
+ obstack_grow (&obstack, temp_filename, temp_filename_length);
+ if (c == 'u' || c == 'U')
+ {
+ static int unique;
+ char buff[9];
+ if (c == 'u')
+ unique++;
+ sprintf (buff, "%d", unique);
+ obstack_grow (&obstack, buff, strlen (buff));
+ }
+#endif
+ delete_this_arg = 1;
+ }
+ arg_going = 1;
+ break;
+
+ case 'i':
+ obstack_grow (&obstack, input_filename, input_filename_length);
+ arg_going = 1;
+ break;
+
+ case 'I':
+ if (gcc_exec_prefix)
+ {
+ do_spec_1 ("-iprefix", 1, NULL_PTR);
+ /* Make this a separate argument. */
+ do_spec_1 (" ", 0, NULL_PTR);
+ do_spec_1 (gcc_exec_prefix, 1, NULL_PTR);
+ do_spec_1 (" ", 0, NULL_PTR);
+ }
+ break;
+
+ case 'o':
+ {
+ register int f;
+ for (f = 0; f < n_infiles; f++)
+ store_arg (outfiles[f], 0, 0);
+ }
+ break;
+
+ case 's':
+ this_is_library_file = 1;
+ break;
+
+ case 'w':
+ this_is_output_file = 1;
+ break;
+
+ case 'W':
+ {
+ int index = argbuf_index;
+ /* Handle the {...} following the %W. */
+ if (*p != '{')
+ abort ();
+ p = handle_braces (p + 1);
+ if (p == 0)
+ return -1;
+ /* If any args were output, mark the last one for deletion
+ on failure. */
+ if (argbuf_index != index)
+ record_temp_file (argbuf[argbuf_index - 1], 0, 1);
+ break;
+ }
+
+ /* %x{OPTION} records OPTION for %X to output. */
+ case 'x':
+ {
+ char *p1 = p;
+ char *string;
+
+ /* Skip past the option value and make a copy. */
+ if (*p != '{')
+ abort ();
+ while (*p++ != '}')
+ ;
+ string = save_string (p1 + 1, p - p1 - 2);
+
+ /* See if we already recorded this option. */
+ for (i = 0; i < n_linker_options; i++)
+ if (! strcmp (string, linker_options[i]))
+ {
+ free (string);
+ return 0;
+ }
+
+ /* This option is new; add it. */
+ n_linker_options++;
+ if (!linker_options)
+ linker_options
+ = (char **) xmalloc (n_linker_options * sizeof (char **));
+ else
+ linker_options
+ = (char **) xrealloc (linker_options,
+ n_linker_options * sizeof (char **));
+
+ linker_options[n_linker_options - 1] = string;
+ }
+ break;
+
+ /* Dump out the options accumulated previously using %x,
+ -Xlinker and -Wl,. */
+ case 'X':
+ for (i = 0; i < n_linker_options; i++)
+ {
+ do_spec_1 (linker_options[i], 1, NULL_PTR);
+ /* Make each accumulated option a separate argument. */
+ do_spec_1 (" ", 0, NULL_PTR);
+ }
+ break;
+
+ /* Dump out the options accumulated previously using -Wa,. */
+ case 'Y':
+ for (i = 0; i < n_assembler_options; i++)
+ {
+ do_spec_1 (assembler_options[i], 1, NULL_PTR);
+ /* Make each accumulated option a separate argument. */
+ do_spec_1 (" ", 0, NULL_PTR);
+ }
+ break;
+
+ /* Here are digits and numbers that just process
+ a certain constant string as a spec. */
+
+ case '1':
+ value = do_spec_1 (cc1_spec, 0, NULL_PTR);
+ if (value != 0)
+ return value;
+ break;
+
+ case '2':
+ value = do_spec_1 (cc1plus_spec, 0, NULL_PTR);
+ if (value != 0)
+ return value;
+ break;
+
+ case 'a':
+ value = do_spec_1 (asm_spec, 0, NULL_PTR);
+ if (value != 0)
+ return value;
+ break;
+
+ case 'A':
+ value = do_spec_1 (asm_final_spec, 0, NULL_PTR);
+ if (value != 0)
+ return value;
+ break;
+
+ case 'c':
+ value = do_spec_1 (signed_char_spec, 0, NULL_PTR);
+ if (value != 0)
+ return value;
+ break;
+
+ case 'C':
+ value = do_spec_1 (cpp_spec, 0, NULL_PTR);
+ if (value != 0)
+ return value;
+ break;
+
+ case 'E':
+ value = do_spec_1 (endfile_spec, 0, NULL_PTR);
+ if (value != 0)
+ return value;
+ break;
+
+ case 'l':
+ value = do_spec_1 (link_spec, 0, NULL_PTR);
+ if (value != 0)
+ return value;
+ break;
+
+ case 'L':
+ value = do_spec_1 (lib_spec, 0, NULL_PTR);
+ if (value != 0)
+ return value;
+ break;
+
+ case 'p':
+ {
+ char *x = (char *) alloca (strlen (cpp_predefines) + 1);
+ char *buf = x;
+ char *y;
+
+ /* Copy all of the -D options in CPP_PREDEFINES into BUF. */
+ y = cpp_predefines;
+ while (*y != 0)
+ {
+ if (! strncmp (y, "-D", 2))
+ /* Copy the whole option. */
+ while (*y && *y != ' ' && *y != '\t')
+ *x++ = *y++;
+ else if (*y == ' ' || *y == '\t')
+ /* Copy whitespace to the result. */
+ *x++ = *y++;
+ /* Don't copy other options. */
+ else
+ y++;
+ }
+
+ *x = 0;
+
+ value = do_spec_1 (buf, 0, NULL_PTR);
+ if (value != 0)
+ return value;
+ }
+ break;
+
+ case 'P':
+ {
+ char *x = (char *) alloca (strlen (cpp_predefines) * 4 + 1);
+ char *buf = x;
+ char *y;
+
+ /* Copy all of CPP_PREDEFINES into BUF,
+ but put __ after every -D and at the end of each arg. */
+ y = cpp_predefines;
+ while (*y != 0)
+ {
+ if (! strncmp (y, "-D", 2))
+ {
+ int flag = 0;
+
+ *x++ = *y++;
+ *x++ = *y++;
+
+ if (strncmp (y, "__", 2))
+ {
+ /* Stick __ at front of macro name. */
+ *x++ = '_';
+ *x++ = '_';
+ /* Arrange to stick __ at the end as well. */
+ flag = 1;
+ }
+
+ /* Copy the macro name. */
+ while (*y && *y != '=' && *y != ' ' && *y != '\t')
+ *x++ = *y++;
+
+ if (flag)
+ {
+ *x++ = '_';
+ *x++ = '_';
+ }
+
+ /* Copy the value given, if any. */
+ while (*y && *y != ' ' && *y != '\t')
+ *x++ = *y++;
+ }
+ else if (*y == ' ' || *y == '\t')
+ /* Copy whitespace to the result. */
+ *x++ = *y++;
+ /* Don't copy -A options */
+ else
+ y++;
+ }
+ *x++ = ' ';
+
+ /* Copy all of CPP_PREDEFINES into BUF,
+ but put __ after every -D. */
+ y = cpp_predefines;
+ while (*y != 0)
+ {
+ if (! strncmp (y, "-D", 2))
+ {
+ *x++ = *y++;
+ *x++ = *y++;
+
+ if (strncmp (y, "__", 2))
+ {
+ /* Stick __ at front of macro name. */
+ *x++ = '_';
+ *x++ = '_';
+ }
+
+ /* Copy the macro name. */
+ while (*y && *y != '=' && *y != ' ' && *y != '\t')
+ *x++ = *y++;
+
+ /* Copy the value given, if any. */
+ while (*y && *y != ' ' && *y != '\t')
+ *x++ = *y++;
+ }
+ else if (*y == ' ' || *y == '\t')
+ /* Copy whitespace to the result. */
+ *x++ = *y++;
+ /* Don't copy -A options */
+ else
+ y++;
+ }
+ *x++ = ' ';
+
+ /* Copy all of the -A options in CPP_PREDEFINES into BUF. */
+ y = cpp_predefines;
+ while (*y != 0)
+ {
+ if (! strncmp (y, "-A", 2))
+ /* Copy the whole option. */
+ while (*y && *y != ' ' && *y != '\t')
+ *x++ = *y++;
+ else if (*y == ' ' || *y == '\t')
+ /* Copy whitespace to the result. */
+ *x++ = *y++;
+ /* Don't copy other options. */
+ else
+ y++;
+ }
+
+ *x = 0;
+
+ value = do_spec_1 (buf, 0, NULL_PTR);
+ if (value != 0)
+ return value;
+ }
+ break;
+
+ case 'S':
+ value = do_spec_1 (startfile_spec, 0, NULL_PTR);
+ if (value != 0)
+ return value;
+ break;
+
+ /* Here we define characters other than letters and digits. */
+
+ case '{':
+ p = handle_braces (p);
+ if (p == 0)
+ return -1;
+ break;
+
+ case '%':
+ obstack_1grow (&obstack, '%');
+ break;
+
+ case '*':
+ do_spec_1 (soft_matched_part, 1, NULL_PTR);
+ do_spec_1 (" ", 0, NULL_PTR);
+ break;
+
+ /* Process a string found as the value of a spec given by name.
+ This feature allows individual machine descriptions
+ to add and use their own specs.
+ %[...] modifies -D options the way %P does;
+ %(...) uses the spec unmodified. */
+ case '(':
+ case '[':
+ {
+ char *name = p;
+ struct spec_list *sl;
+ int len;
+
+ /* The string after the S/P is the name of a spec that is to be
+ processed. */
+ while (*p && *p != ')' && *p != ']')
+ p++;
+
+ /* See if it's in the list */
+ for (len = p - name, sl = specs; sl; sl = sl->next)
+ if (strncmp (sl->name, name, len) == 0 && !sl->name[len])
+ {
+ name = sl->spec;
+ break;
+ }
+
+ if (sl)
+ {
+ if (c == '(')
+ {
+ value = do_spec_1 (name, 0, NULL_PTR);
+ if (value != 0)
+ return value;
+ }
+ else
+ {
+ char *x = (char *) alloca (strlen (name) * 2 + 1);
+ char *buf = x;
+ char *y = name;
+
+ /* Copy all of NAME into BUF, but put __ after
+ every -D and at the end of each arg, */
+ while (1)
+ {
+ if (! strncmp (y, "-D", 2))
+ {
+ *x++ = '-';
+ *x++ = 'D';
+ *x++ = '_';
+ *x++ = '_';
+ y += 2;
+ }
+ else if (*y == ' ' || *y == 0)
+ {
+ *x++ = '_';
+ *x++ = '_';
+ if (*y == 0)
+ break;
+ else
+ *x++ = *y++;
+ }
+ else
+ *x++ = *y++;
+ }
+ *x = 0;
+
+ value = do_spec_1 (buf, 0, NULL_PTR);
+ if (value != 0)
+ return value;
+ }
+ }
+
+ /* Discard the closing paren or bracket. */
+ if (*p)
+ p++;
+ }
+ break;
+
+ case '|':
+ if (input_from_pipe)
+ do_spec_1 ("-", 0, NULL_PTR);
+ break;
+
+ default:
+ abort ();
+ }
+ break;
+
+ case '\\':
+ /* Backslash: treat next character as ordinary. */
+ c = *p++;
+
+ /* fall through */
+ default:
+ /* Ordinary character: put it into the current argument. */
+ obstack_1grow (&obstack, c);
+ arg_going = 1;
+ }
+
+ return 0; /* End of string */
+}
+
+/* Return 0 if we call do_spec_1 and that returns -1. */
+
+static char *
+handle_braces (p)
+ register char *p;
+{
+ register char *q;
+ char *filter;
+ int pipe = 0;
+ int negate = 0;
+ int suffix = 0;
+
+ if (*p == '|')
+ /* A `|' after the open-brace means,
+ if the test fails, output a single minus sign rather than nothing.
+ This is used in %{|!pipe:...}. */
+ pipe = 1, ++p;
+
+ if (*p == '!')
+ /* A `!' after the open-brace negates the condition:
+ succeed if the specified switch is not present. */
+ negate = 1, ++p;
+
+ if (*p == '.')
+ /* A `.' after the open-brace means test against the current suffix. */
+ {
+ if (pipe)
+ abort ();
+
+ suffix = 1;
+ ++p;
+ }
+
+ filter = p;
+ while (*p != ':' && *p != '}') p++;
+ if (*p != '}')
+ {
+ register int count = 1;
+ q = p + 1;
+ while (count > 0)
+ {
+ if (*q == '{')
+ count++;
+ else if (*q == '}')
+ count--;
+ else if (*q == 0)
+ abort ();
+ q++;
+ }
+ }
+ else
+ q = p + 1;
+
+ if (suffix)
+ {
+ int found = (input_suffix != 0
+ && strlen (input_suffix) == p - filter
+ && strncmp (input_suffix, filter, p - filter) == 0);
+
+ if (p[0] == '}')
+ abort ();
+
+ if (negate != found
+ && do_spec_1 (save_string (p + 1, q - p - 2), 0, NULL_PTR) < 0)
+ return 0;
+
+ return q;
+ }
+ else if (p[-1] == '*' && p[0] == '}')
+ {
+ /* Substitute all matching switches as separate args. */
+ register int i;
+ --p;
+ for (i = 0; i < n_switches; i++)
+ if (!strncmp (switches[i].part1, filter, p - filter))
+ give_switch (i, 0);
+ }
+ else
+ {
+ /* Test for presence of the specified switch. */
+ register int i;
+ int present = 0;
+
+ /* If name specified ends in *, as in {x*:...},
+ check for %* and handle that case. */
+ if (p[-1] == '*' && !negate)
+ {
+ int substitution;
+ char *r = p;
+
+ /* First see whether we have %*. */
+ substitution = 0;
+ while (r < q)
+ {
+ if (*r == '%' && r[1] == '*')
+ substitution = 1;
+ r++;
+ }
+ /* If we do, handle that case. */
+ if (substitution)
+ {
+ /* Substitute all matching switches as separate args.
+ But do this by substituting for %*
+ in the text that follows the colon. */
+
+ unsigned hard_match_len = p - filter - 1;
+ char *string = save_string (p + 1, q - p - 2);
+
+ for (i = 0; i < n_switches; i++)
+ if (!strncmp (switches[i].part1, filter, hard_match_len))
+ {
+ do_spec_1 (string, 0, &switches[i].part1[hard_match_len]);
+ /* Pass any arguments this switch has. */
+ give_switch (i, 1);
+ }
+
+ return q;
+ }
+ }
+
+ /* If name specified ends in *, as in {x*:...},
+ check for presence of any switch name starting with x. */
+ if (p[-1] == '*')
+ {
+ for (i = 0; i < n_switches; i++)
+ {
+ unsigned hard_match_len = p - filter - 1;
+
+ if (!strncmp (switches[i].part1, filter, hard_match_len))
+ {
+ switches[i].valid = 1;
+ present = 1;
+ }
+ }
+ }
+ /* Otherwise, check for presence of exact name specified. */
+ else
+ {
+ for (i = 0; i < n_switches; i++)
+ {
+ if (!strncmp (switches[i].part1, filter, p - filter)
+ && switches[i].part1[p - filter] == 0)
+ {
+ switches[i].valid = 1;
+ present = 1;
+ break;
+ }
+ }
+ }
+
+ /* If it is as desired (present for %{s...}, absent for %{-s...})
+ then substitute either the switch or the specified
+ conditional text. */
+ if (present != negate)
+ {
+ if (*p == '}')
+ {
+ give_switch (i, 0);
+ }
+ else
+ {
+ if (do_spec_1 (save_string (p + 1, q - p - 2), 0, NULL_PTR) < 0)
+ return 0;
+ }
+ }
+ else if (pipe)
+ {
+ /* Here if a %{|...} conditional fails: output a minus sign,
+ which means "standard output" or "standard input". */
+ do_spec_1 ("-", 0, NULL_PTR);
+ }
+ }
+
+ return q;
+}
+
+/* Pass a switch to the current accumulating command
+ in the same form that we received it.
+ SWITCHNUM identifies the switch; it is an index into
+ the vector of switches gcc received, which is `switches'.
+ This cannot fail since it never finishes a command line.
+
+ If OMIT_FIRST_WORD is nonzero, then we omit .part1 of the argument. */
+
+static void
+give_switch (switchnum, omit_first_word)
+ int switchnum;
+ int omit_first_word;
+{
+ if (!omit_first_word)
+ {
+ do_spec_1 ("-", 0, NULL_PTR);
+ do_spec_1 (switches[switchnum].part1, 1, NULL_PTR);
+ }
+ do_spec_1 (" ", 0, NULL_PTR);
+ if (switches[switchnum].args != 0)
+ {
+ char **p;
+ for (p = switches[switchnum].args; *p; p++)
+ {
+ do_spec_1 (*p, 1, NULL_PTR);
+ do_spec_1 (" ", 0, NULL_PTR);
+ }
+ }
+ switches[switchnum].valid = 1;
+}
+
+/* Search for a file named NAME trying various prefixes including the
+ user's -B prefix and some standard ones.
+ Return the absolute file name found. If nothing is found, return NAME. */
+
+static char *
+find_file (name)
+ char *name;
+{
+ char *newname;
+
+ newname = find_a_file (&startfile_prefix, name, R_OK);
+ return newname ? newname : name;
+}
+
+/* Determine whether a directory exists. If LINKER, return 0 for
+ certain fixed names not needed by the linker. If not LINKER, it is
+ only important to return 0 if the host machine has a small ARG_MAX
+ limit. */
+
+static int
+is_directory (path1, path2, linker)
+ char *path1;
+ char *path2;
+ int linker;
+{
+ int len1 = strlen (path1);
+ int len2 = strlen (path2);
+ char *path = (char *) alloca (3 + len1 + len2);
+ char *cp;
+ struct stat st;
+
+#ifndef SMALL_ARG_MAX
+ if (! linker)
+ return 1;
+#endif
+
+ /* Construct the path from the two parts. Ensure the string ends with "/.".
+ The resulting path will be a directory even if the given path is a
+ symbolic link. */
+ bcopy (path1, path, len1);
+ bcopy (path2, path + len1, len2);
+ cp = path + len1 + len2;
+ if (cp[-1] != '/')
+ *cp++ = '/';
+ *cp++ = '.';
+ *cp = '\0';
+
+ /* Exclude directories that the linker is known to search. */
+ if (linker
+ && ((cp - path == 6 && strcmp (path, "/lib/.") == 0)
+ || (cp - path == 10 && strcmp (path, "/usr/lib/.") == 0)))
+ return 0;
+
+ return (stat (path, &st) >= 0 && S_ISDIR (st.st_mode));
+}
+
+/* On fatal signals, delete all the temporary files. */
+
+static void
+fatal_error (signum)
+ int signum;
+{
+ signal (signum, SIG_DFL);
+ delete_failure_queue ();
+ delete_temp_files ();
+ /* Get the same signal again, this time not handled,
+ so its normal effect occurs. */
+ kill (getpid (), signum);
+}
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ register int i;
+ int j;
+ int value;
+ int linker_was_run = 0;
+ char *explicit_link_files;
+ char *specs_file;
+ char *p;
+
+ p = argv[0] + strlen (argv[0]);
+ while (p != argv[0] && p[-1] != '/') --p;
+ programname = p;
+
+ if (signal (SIGINT, SIG_IGN) != SIG_IGN)
+ signal (SIGINT, fatal_error);
+#ifdef SIGHUP
+ if (signal (SIGHUP, SIG_IGN) != SIG_IGN)
+ signal (SIGHUP, fatal_error);
+#endif
+ if (signal (SIGTERM, SIG_IGN) != SIG_IGN)
+ signal (SIGTERM, fatal_error);
+#ifdef SIGPIPE
+ if (signal (SIGPIPE, SIG_IGN) != SIG_IGN)
+ signal (SIGPIPE, fatal_error);
+#endif
+
+ argbuf_length = 10;
+ argbuf = (char **) xmalloc (argbuf_length * sizeof (char *));
+
+ obstack_init (&obstack);
+
+ /* Set up to remember the pathname of gcc and any options
+ needed for collect. We use argv[0] instead of programname because
+ we need the complete pathname. */
+ obstack_init (&collect_obstack);
+ obstack_grow (&collect_obstack, "COLLECT_GCC=", sizeof ("COLLECT_GCC=")-1);
+ obstack_grow (&collect_obstack, argv[0], strlen (argv[0])+1);
+ putenv (obstack_finish (&collect_obstack));
+
+ /* Choose directory for temp files. */
+
+ choose_temp_base ();
+
+ /* Make a table of what switches there are (switches, n_switches).
+ Make a table of specified input files (infiles, n_infiles).
+ Decode switches that are handled locally. */
+
+ process_command (argc, argv);
+
+ /* Initialize the vector of specs to just the default.
+ This means one element containing 0s, as a terminator. */
+
+ compilers = (struct compiler *) xmalloc (sizeof default_compilers);
+ bcopy (default_compilers, compilers, sizeof default_compilers);
+ n_compilers = n_default_compilers;
+
+ /* Read specs from a file if there is one. */
+
+ machine_suffix = concat (spec_machine, "/", concat (spec_version, "/", ""));
+ just_machine_suffix = concat (spec_machine, "/", "");
+
+ specs_file = find_a_file (&startfile_prefix, "specs", R_OK);
+ /* Read the specs file unless it is a default one. */
+ if (specs_file != 0 && strcmp (specs_file, "specs"))
+ read_specs (specs_file);
+
+ /* If not cross-compiling, look for startfiles in the standard places. */
+ /* The fact that these are done here, after reading the specs file,
+ means that it cannot be found in these directories.
+ But that's okay. It should never be there anyway. */
+ if (!cross_compile)
+ {
+#ifdef MD_EXEC_PREFIX
+ add_prefix (&exec_prefix, md_exec_prefix, 0, 0, NULL_PTR);
+ add_prefix (&startfile_prefix, md_exec_prefix, 0, 0, NULL_PTR);
+#endif
+
+#ifdef MD_STARTFILE_PREFIX
+ add_prefix (&startfile_prefix, md_startfile_prefix, 0, 0, NULL_PTR);
+#endif
+
+#ifdef MD_STARTFILE_PREFIX_1
+ add_prefix (&startfile_prefix, md_startfile_prefix_1, 0, 0, NULL_PTR);
+#endif
+
+ add_prefix (&startfile_prefix, standard_startfile_prefix, 0, 0,
+ NULL_PTR);
+ add_prefix (&startfile_prefix, standard_startfile_prefix_1, 0, 0,
+ NULL_PTR);
+ add_prefix (&startfile_prefix, standard_startfile_prefix_2, 0, 0,
+ NULL_PTR);
+#if 0 /* Can cause surprises, and one can use -B./ instead. */
+ add_prefix (&startfile_prefix, "./", 0, 1, NULL_PTR);
+#endif
+ }
+
+ /* Now we have the specs.
+ Set the `valid' bits for switches that match anything in any spec. */
+
+ validate_all_switches ();
+
+ /* Warn about any switches that no pass was interested in. */
+
+ for (i = 0; i < n_switches; i++)
+ if (! switches[i].valid)
+ error ("unrecognized option `-%s'", switches[i].part1);
+
+ if (print_libgcc_file_name)
+ {
+ printf ("%s\n", find_file ("libgcc.a"));
+ exit (0);
+ }
+
+ /* Obey some of the options. */
+
+ if (verbose_flag)
+ {
+ fprintf (stderr, "gcc version %s\n", version_string);
+ if (n_infiles == 0)
+ exit (0);
+ }
+
+ if (n_infiles == 0)
+ fatal ("No input files specified.");
+
+ /* Make a place to record the compiler output file names
+ that correspond to the input files. */
+
+ outfiles = (char **) xmalloc (n_infiles * sizeof (char *));
+ bzero (outfiles, n_infiles * sizeof (char *));
+
+ /* Record which files were specified explicitly as link input. */
+
+ explicit_link_files = xmalloc (n_infiles);
+ bzero (explicit_link_files, n_infiles);
+
+ for (i = 0; i < n_infiles; i++)
+ {
+ register struct compiler *cp = 0;
+ int this_file_error = 0;
+
+ /* Tell do_spec what to substitute for %i. */
+
+ input_filename = infiles[i].name;
+ input_filename_length = strlen (input_filename);
+ input_file_number = i;
+
+ /* Use the same thing in %o, unless cp->spec says otherwise. */
+
+ outfiles[i] = input_filename;
+
+ /* Figure out which compiler from the file's suffix. */
+
+ cp = lookup_compiler (infiles[i].name, input_filename_length,
+ infiles[i].language);
+
+ if (cp)
+ {
+ /* Ok, we found an applicable compiler. Run its spec. */
+ /* First say how much of input_filename to substitute for %b */
+ register char *p;
+ int len;
+
+ input_basename = input_filename;
+ for (p = input_filename; *p; p++)
+ if (*p == '/')
+ input_basename = p + 1;
+
+ /* Find a suffix starting with the last period,
+ and set basename_length to exclude that suffix. */
+ basename_length = strlen (input_basename);
+ p = input_basename + basename_length;
+ while (p != input_basename && *p != '.') --p;
+ if (*p == '.' && p != input_basename)
+ {
+ basename_length = p - input_basename;
+ input_suffix = p + 1;
+ }
+ else
+ input_suffix = "";
+
+ len = 0;
+ for (j = 0; j < sizeof cp->spec / sizeof cp->spec[0]; j++)
+ if (cp->spec[j])
+ len += strlen (cp->spec[j]);
+
+ p = (char *) xmalloc (len + 1);
+
+ len = 0;
+ for (j = 0; j < sizeof cp->spec / sizeof cp->spec[0]; j++)
+ if (cp->spec[j])
+ {
+ strcpy (p + len, cp->spec[j]);
+ len += strlen (cp->spec[j]);
+ }
+
+ value = do_spec (p);
+ free (p);
+ if (value < 0)
+ this_file_error = 1;
+ }
+
+ /* If this file's name does not contain a recognized suffix,
+ record it as explicit linker input. */
+
+ else
+ explicit_link_files[i] = 1;
+
+ /* Clear the delete-on-failure queue, deleting the files in it
+ if this compilation failed. */
+
+ if (this_file_error)
+ {
+ delete_failure_queue ();
+ error_count++;
+ }
+ /* If this compilation succeeded, don't delete those files later. */
+ clear_failure_queue ();
+ }
+
+ /* Run ld to link all the compiler output files. */
+
+ if (error_count == 0)
+ {
+ int tmp = execution_count;
+ int i;
+ int first_time;
+
+ /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables
+ for collect. */
+ putenv_from_prefixes (&exec_prefix, "COMPILER_PATH=");
+ putenv_from_prefixes (&startfile_prefix, "LIBRARY_PATH=");
+
+ /* Build COLLECT_GCC_OPTIONS to have all of the options specified to
+ the compiler. */
+ obstack_grow (&collect_obstack, "COLLECT_GCC_OPTIONS=",
+ sizeof ("COLLECT_GCC_OPTIONS=")-1);
+
+ first_time = TRUE;
+ for (i = 0; i < n_switches; i++)
+ {
+ char **args;
+ if (!first_time)
+ obstack_grow (&collect_obstack, " ", 1);
+
+ first_time = FALSE;
+ obstack_grow (&collect_obstack, "-", 1);
+ obstack_grow (&collect_obstack, switches[i].part1,
+ strlen (switches[i].part1));
+
+ for (args = switches[i].args; args && *args; args++)
+ {
+ obstack_grow (&collect_obstack, " ", 1);
+ obstack_grow (&collect_obstack, *args, strlen (*args));
+ }
+ }
+ obstack_grow (&collect_obstack, "\0", 1);
+ putenv (obstack_finish (&collect_obstack));
+
+ value = do_spec (link_command_spec);
+ if (value < 0)
+ error_count = 1;
+ linker_was_run = (tmp != execution_count);
+ }
+
+ /* Warn if a -B option was specified but the prefix was never used. */
+ unused_prefix_warnings (&exec_prefix);
+ unused_prefix_warnings (&startfile_prefix);
+
+ /* If options said don't run linker,
+ complain about input files to be given to the linker. */
+
+ if (! linker_was_run && error_count == 0)
+ for (i = 0; i < n_infiles; i++)
+ if (explicit_link_files[i])
+ error ("%s: linker input file unused since linking not done",
+ outfiles[i]);
+
+ /* Delete some or all of the temporary files we made. */
+
+ if (error_count)
+ delete_failure_queue ();
+ delete_temp_files ();
+
+ exit (error_count > 0 ? (signal_count ? 2 : 1) : 0);
+ /* NOTREACHED */
+ return 0;
+}
+
+/* Find the proper compilation spec for the file name NAME,
+ whose length is LENGTH. LANGUAGE is the specified language,
+ or 0 if none specified. */
+
+static struct compiler *
+lookup_compiler (name, length, language)
+ char *name;
+ int length;
+ char *language;
+{
+ struct compiler *cp;
+
+ /* Look for the language, if one is spec'd. */
+ if (language != 0)
+ {
+ for (cp = compilers + n_compilers - 1; cp >= compilers; cp--)
+ {
+ if (language != 0)
+ {
+ if (cp->suffix[0] == '@'
+ && !strcmp (cp->suffix + 1, language))
+ return cp;
+ }
+ }
+ error ("language %s not recognized", language);
+ }
+
+ /* Look for a suffix. */
+ for (cp = compilers + n_compilers - 1; cp >= compilers; cp--)
+ {
+ if (/* The suffix `-' matches only the file name `-'. */
+ (!strcmp (cp->suffix, "-") && !strcmp (name, "-"))
+ ||
+ (strlen (cp->suffix) < length
+ /* See if the suffix matches the end of NAME. */
+ && !strcmp (cp->suffix,
+ name + length - strlen (cp->suffix))))
+ {
+ if (cp->spec[0][0] == '@')
+ {
+ struct compiler *new;
+ /* An alias entry maps a suffix to a language.
+ Search for the language; pass 0 for NAME and LENGTH
+ to avoid infinite recursion if language not found.
+ Construct the new compiler spec. */
+ language = cp->spec[0] + 1;
+ new = (struct compiler *) xmalloc (sizeof (struct compiler));
+ new->suffix = cp->suffix;
+ bcopy (lookup_compiler (NULL_PTR, 0, language)->spec,
+ new->spec, sizeof new->spec);
+ return new;
+ }
+ /* A non-alias entry: return it. */
+ return cp;
+ }
+ }
+
+ return 0;
+}
+
+char *
+xmalloc (size)
+ unsigned size;
+{
+ register char *value = (char *) malloc (size);
+ if (value == 0)
+ fatal ("virtual memory exhausted");
+ return value;
+}
+
+char *
+xrealloc (ptr, size)
+ char *ptr;
+ unsigned size;
+{
+ register char *value = (char *) realloc (ptr, size);
+ if (value == 0)
+ fatal ("virtual memory exhausted");
+ return value;
+}
+
+/* Return a newly-allocated string whose contents concatenate those of s1, s2, s3. */
+
+static char *
+concat (s1, s2, s3)
+ char *s1, *s2, *s3;
+{
+ int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
+ char *result = xmalloc (len1 + len2 + len3 + 1);
+
+ strcpy (result, s1);
+ strcpy (result + len1, s2);
+ strcpy (result + len1 + len2, s3);
+ *(result + len1 + len2 + len3) = 0;
+
+ return result;
+}
+
+static char *
+save_string (s, len)
+ char *s;
+ int len;
+{
+ register char *result = xmalloc (len + 1);
+
+ bcopy (s, result, len);
+ result[len] = 0;
+ return result;
+}
+
+static void
+pfatal_with_name (name)
+ char *name;
+{
+ char *s;
+
+ if (errno < sys_nerr)
+ s = concat ("%s: ", sys_errlist[errno], "");
+ else
+ s = "cannot open %s";
+ fatal (s, name);
+}
+
+static void
+perror_with_name (name)
+ char *name;
+{
+ char *s;
+
+ if (errno < sys_nerr)
+ s = concat ("%s: ", sys_errlist[errno], "");
+ else
+ s = "cannot open %s";
+ error (s, name);
+}
+
+static void
+perror_exec (name)
+ char *name;
+{
+ char *s;
+
+ if (errno < sys_nerr)
+ s = concat ("installation problem, cannot exec %s: ",
+ sys_errlist[errno], "");
+ else
+ s = "installation problem, cannot exec %s";
+ error (s, name);
+}
+
+/* More 'friendly' abort that prints the line and file.
+ config.h can #define abort fancy_abort if you like that sort of thing. */
+
+void
+fancy_abort ()
+{
+ fatal ("Internal gcc abort.");
+}
+
+#ifdef HAVE_VPRINTF
+
+/* Output an error message and exit */
+
+static void
+fatal (va_alist)
+ va_dcl
+{
+ va_list ap;
+ char *format;
+
+ va_start (ap);
+ format = va_arg (ap, char *);
+ fprintf (stderr, "%s: ", programname);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
+ fprintf (stderr, "\n");
+ delete_temp_files ();
+ exit (1);
+}
+
+static void
+error (va_alist)
+ va_dcl
+{
+ va_list ap;
+ char *format;
+
+ va_start (ap);
+ format = va_arg (ap, char *);
+ fprintf (stderr, "%s: ", programname);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
+
+ fprintf (stderr, "\n");
+}
+
+#else /* not HAVE_VPRINTF */
+
+static void
+fatal (msg, arg1, arg2)
+ char *msg, *arg1, *arg2;
+{
+ error (msg, arg1, arg2);
+ delete_temp_files ();
+ exit (1);
+}
+
+static void
+error (msg, arg1, arg2)
+ char *msg, *arg1, *arg2;
+{
+ fprintf (stderr, "%s: ", programname);
+ fprintf (stderr, msg, arg1, arg2);
+ fprintf (stderr, "\n");
+}
+
+#endif /* not HAVE_VPRINTF */
+
+
+static void
+validate_all_switches ()
+{
+ struct compiler *comp;
+ register char *p;
+ register char c;
+ struct spec_list *spec;
+
+ for (comp = compilers; comp->spec[0]; comp++)
+ {
+ int i;
+ for (i = 0; i < sizeof comp->spec / sizeof comp->spec[0] && comp->spec[i]; i++)
+ {
+ p = comp->spec[i];
+ while (c = *p++)
+ if (c == '%' && *p == '{')
+ /* We have a switch spec. */
+ validate_switches (p + 1);
+ }
+ }
+
+ /* look through the linked list of extra specs read from the specs file */
+ for (spec = specs; spec ; spec = spec->next)
+ {
+ p = spec->spec;
+ while (c = *p++)
+ if (c == '%' && *p == '{')
+ /* We have a switch spec. */
+ validate_switches (p + 1);
+ }
+
+ p = link_command_spec;
+ while (c = *p++)
+ if (c == '%' && *p == '{')
+ /* We have a switch spec. */
+ validate_switches (p + 1);
+
+ /* Now notice switches mentioned in the machine-specific specs. */
+
+ p = asm_spec;
+ while (c = *p++)
+ if (c == '%' && *p == '{')
+ /* We have a switch spec. */
+ validate_switches (p + 1);
+
+ p = asm_final_spec;
+ while (c = *p++)
+ if (c == '%' && *p == '{')
+ /* We have a switch spec. */
+ validate_switches (p + 1);
+
+ p = cpp_spec;
+ while (c = *p++)
+ if (c == '%' && *p == '{')
+ /* We have a switch spec. */
+ validate_switches (p + 1);
+
+ p = signed_char_spec;
+ while (c = *p++)
+ if (c == '%' && *p == '{')
+ /* We have a switch spec. */
+ validate_switches (p + 1);
+
+ p = cc1_spec;
+ while (c = *p++)
+ if (c == '%' && *p == '{')
+ /* We have a switch spec. */
+ validate_switches (p + 1);
+
+ p = cc1plus_spec;
+ while (c = *p++)
+ if (c == '%' && *p == '{')
+ /* We have a switch spec. */
+ validate_switches (p + 1);
+
+ p = link_spec;
+ while (c = *p++)
+ if (c == '%' && *p == '{')
+ /* We have a switch spec. */
+ validate_switches (p + 1);
+
+ p = lib_spec;
+ while (c = *p++)
+ if (c == '%' && *p == '{')
+ /* We have a switch spec. */
+ validate_switches (p + 1);
+
+ p = startfile_spec;
+ while (c = *p++)
+ if (c == '%' && *p == '{')
+ /* We have a switch spec. */
+ validate_switches (p + 1);
+}
+
+/* Look at the switch-name that comes after START
+ and mark as valid all supplied switches that match it. */
+
+static void
+validate_switches (start)
+ char *start;
+{
+ register char *p = start;
+ char *filter;
+ register int i;
+ int suffix = 0;
+
+ if (*p == '|')
+ ++p;
+
+ if (*p == '!')
+ ++p;
+
+ if (*p == '.')
+ suffix = 1, ++p;
+
+ filter = p;
+ while (*p != ':' && *p != '}') p++;
+
+ if (suffix)
+ ;
+ else if (p[-1] == '*')
+ {
+ /* Mark all matching switches as valid. */
+ --p;
+ for (i = 0; i < n_switches; i++)
+ if (!strncmp (switches[i].part1, filter, p - filter))
+ switches[i].valid = 1;
+ }
+ else
+ {
+ /* Mark an exact matching switch as valid. */
+ for (i = 0; i < n_switches; i++)
+ {
+ if (!strncmp (switches[i].part1, filter, p - filter)
+ && switches[i].part1[p - filter] == 0)
+ switches[i].valid = 1;
+ }
+ }
+}
diff --git a/gnu/usr.bin/cc/cc1/Makefile b/gnu/usr.bin/cc/cc1/Makefile
new file mode 100644
index 000000000000..6e26b5140699
--- /dev/null
+++ b/gnu/usr.bin/cc/cc1/Makefile
@@ -0,0 +1,23 @@
+# @(#)Makefile 6.2 (Berkeley) 2/2/91
+
+PROG= gcc1
+BINDIR= /usr/libexec
+SRCS= c-parse.c c-lang.c c-lex.c c-pragma.c c-decl.c \
+ c-typeck.c c-convert.c c-aux-info.c c-iterate.c
+
+CFLAGS+= -I. -I$(.CURDIR) -I$(.CURDIR)/../lib
+YFLAGS=
+NOMAN= noman
+
+.if exists(${.CURDIR}/../lib/obj)
+LDADD= -L${.CURDIR}/../lib/obj -lgcc2
+DPADD= ${.CURDIR}/../lib/obj/libgcc2.a
+.else
+LDADD= -L${.CURDIR}/../lib/ -lgcc2
+DPADD= ${.CURDIR}/../lib/libgcc2.a
+.endif
+
+LDADD+= -lgnumalloc
+DPADD+= ${LIBGNUMALLOC}
+
+.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/cc/cc1/c-aux-info.c b/gnu/usr.bin/cc/cc1/c-aux-info.c
new file mode 100644
index 000000000000..2e1506447e35
--- /dev/null
+++ b/gnu/usr.bin/cc/cc1/c-aux-info.c
@@ -0,0 +1,642 @@
+/* Generate information regarding function declarations and definitions based
+ on information stored in GCC's tree structure. This code implements the
+ -aux-info option.
+
+ This code was written by Ron Guilmette (rfg@mcc.com).
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <stdio.h>
+#include "config.h"
+#include "flags.h"
+#include "tree.h"
+#include "c-tree.h"
+
+extern char* xmalloc ();
+
+enum formals_style_enum {
+ ansi,
+ k_and_r_names,
+ k_and_r_decls
+};
+typedef enum formals_style_enum formals_style;
+
+
+static char* data_type;
+
+static char * concat ();
+static char * concat3 ();
+static char * gen_formal_list_for_type ();
+static int deserves_ellipsis ();
+static char * gen_formal_list_for_func_def ();
+static char * gen_type ();
+static char * gen_decl ();
+void gen_aux_info_record ();
+
+/* Take two strings and mash them together into a newly allocated area. */
+
+static char*
+concat (s1, s2)
+ char* s1;
+ char* s2;
+{
+ int size1, size2;
+ char* ret_val;
+
+ if (!s1)
+ s1 = "";
+ if (!s2)
+ s2 = "";
+
+ size1 = strlen (s1);
+ size2 = strlen (s2);
+ ret_val = xmalloc (size1 + size2 + 1);
+ strcpy (ret_val, s1);
+ strcpy (&ret_val[size1], s2);
+ return ret_val;
+}
+
+/* Take three strings and mash them together into a newly allocated area. */
+
+static char*
+concat3 (s1, s2, s3)
+ char* s1;
+ char* s2;
+ char* s3;
+{
+ int size1, size2, size3;
+ char* ret_val;
+
+ if (!s1)
+ s1 = "";
+ if (!s2)
+ s2 = "";
+ if (!s3)
+ s3 = "";
+
+ size1 = strlen (s1);
+ size2 = strlen (s2);
+ size3 = strlen (s3);
+ ret_val = xmalloc (size1 + size2 + size3 + 1);
+ strcpy (ret_val, s1);
+ strcpy (&ret_val[size1], s2);
+ strcpy (&ret_val[size1+size2], s3);
+ return ret_val;
+}
+
+/* Given a string representing an entire type or an entire declaration
+ which only lacks the actual "data-type" specifier (at its left end),
+ affix the data-type specifier to the left end of the given type
+ specification or object declaration.
+
+ Because of C language weirdness, the data-type specifier (which normally
+ goes in at the very left end) may have to be slipped in just to the
+ right of any leading "const" or "volatile" qualifiers (there may be more
+ than one). Actually this may not be strictly necessary because it seems
+ that GCC (at least) accepts `<data-type> const foo;' and treats it the
+ same as `const <data-type> foo;' but people are accustomed to seeing
+ `const char *foo;' and *not* `char const *foo;' so we try to create types
+ that look as expected. */
+
+static char*
+affix_data_type (type_or_decl)
+ char *type_or_decl;
+{
+ char *p = type_or_decl;
+ char *qualifiers_then_data_type;
+ char saved;
+
+ /* Skip as many leading const's or volatile's as there are. */
+
+ for (;;)
+ {
+ if (!strncmp (p, "volatile ", 9))
+ {
+ p += 9;
+ continue;
+ }
+ if (!strncmp (p, "const ", 6))
+ {
+ p += 6;
+ continue;
+ }
+ break;
+ }
+
+ /* p now points to the place where we can insert the data type. We have to
+ add a blank after the data-type of course. */
+
+ if (p == type_or_decl)
+ return concat3 (data_type, " ", type_or_decl);
+
+ saved = *p;
+ *p = '\0';
+ qualifiers_then_data_type = concat (type_or_decl, data_type);
+ *p = saved;
+ return concat3 (qualifiers_then_data_type, " ", p);
+}
+
+/* Given a tree node which represents some "function type", generate the
+ source code version of a formal parameter list (of some given style) for
+ this function type. Return the whole formal parameter list (including
+ a pair of surrounding parens) as a string. Note that if the style
+ we are currently aiming for is non-ansi, then we just return a pair
+ of empty parens here. */
+
+static char*
+gen_formal_list_for_type (fntype, style)
+ tree fntype;
+ formals_style style;
+{
+ char* formal_list = "";
+ tree formal_type;
+
+ if (style != ansi)
+ return "()";
+
+ formal_type = TYPE_ARG_TYPES (fntype);
+ while (formal_type && TREE_VALUE (formal_type) != void_type_node)
+ {
+ char* this_type;
+
+ if (*formal_list)
+ formal_list = concat (formal_list, ", ");
+
+ this_type = gen_type ("", TREE_VALUE (formal_type), ansi);
+ formal_list =
+ (strlen (this_type))
+ ? concat (formal_list, affix_data_type (this_type))
+ : concat (formal_list, data_type);
+
+ formal_type = TREE_CHAIN (formal_type);
+ }
+
+ /* If we got to here, then we are trying to generate an ANSI style formal
+ parameters list.
+
+ New style prototyped ANSI formal parameter lists should in theory always
+ contain some stuff between the opening and closing parens, even if it is
+ only "void".
+
+ The brutal truth though is that there is lots of old K&R code out there
+ which contains declarations of "pointer-to-function" parameters and
+ these almost never have fully specified formal parameter lists associated
+ with them. That is, the pointer-to-function parameters are declared
+ with just empty parameter lists.
+
+ In cases such as these, protoize should really insert *something* into
+ the vacant parameter lists, but what? It has no basis on which to insert
+ anything in particular.
+
+ Here, we make life easy for protoize by trying to distinguish between
+ K&R empty parameter lists and new-style prototyped parameter lists
+ that actually contain "void". In the latter case we (obviously) want
+ to output the "void" verbatim, and that what we do. In the former case,
+ we do our best to give protoize something nice to insert.
+
+ This "something nice" should be something that is still legal (when
+ re-compiled) but something that can clearly indicate to the user that
+ more typing information (for the parameter list) should be added (by
+ hand) at some convenient moment.
+
+ The string chosen here is a comment with question marks in it. */
+
+ if (!*formal_list)
+ {
+ if (TYPE_ARG_TYPES (fntype))
+ /* assert (TREE_VALUE (TYPE_ARG_TYPES (fntype)) == void_type_node); */
+ formal_list = "void";
+ else
+ formal_list = "/* ??? */";
+ }
+ else
+ {
+ /* If there were at least some parameters, and if the formals-types-list
+ petered out to a NULL (i.e. without being terminated by a
+ void_type_node) then we need to tack on an ellipsis. */
+ if (!formal_type)
+ formal_list = concat (formal_list, ", ...");
+ }
+
+ return concat3 (" (", formal_list, ")");
+}
+
+/* For the generation of an ANSI prototype for a function definition, we have
+ to look at the formal parameter list of the function's own "type" to
+ determine if the function's formal parameter list should end with an
+ ellipsis. Given a tree node, the following function will return non-zero
+ if the "function type" parameter list should end with an ellipsis. */
+
+static int
+deserves_ellipsis (fntype)
+ tree fntype;
+{
+ tree formal_type;
+
+ formal_type = TYPE_ARG_TYPES (fntype);
+ while (formal_type && TREE_VALUE (formal_type) != void_type_node)
+ formal_type = TREE_CHAIN (formal_type);
+
+ /* If there were at least some parameters, and if the formals-types-list
+ petered out to a NULL (i.e. without being terminated by a void_type_node)
+ then we need to tack on an ellipsis. */
+
+ return (!formal_type && TYPE_ARG_TYPES (fntype));
+}
+
+/* Generate a parameter list for a function definition (in some given style).
+
+ Note that this routine has to be separate (and different) from the code that
+ generates the prototype parameter lists for function declarations, because
+ in the case of a function declaration, all we have to go on is a tree node
+ representing the function's own "function type". This can tell us the types
+ of all of the formal parameters for the function, but it cannot tell us the
+ actual *names* of each of the formal parameters. We need to output those
+ parameter names for each function definition.
+
+ This routine gets a pointer to a tree node which represents the actual
+ declaration of the given function, and this DECL node has a list of formal
+ parameter (variable) declarations attached to it. These formal parameter
+ (variable) declaration nodes give us the actual names of the formal
+ parameters for the given function definition.
+
+ This routine returns a string which is the source form for the entire
+ function formal parameter list. */
+
+static char*
+gen_formal_list_for_func_def (fndecl, style)
+ tree fndecl;
+ formals_style style;
+{
+ char* formal_list = "";
+ tree formal_decl;
+
+ formal_decl = DECL_ARGUMENTS (fndecl);
+ while (formal_decl)
+ {
+ char *this_formal;
+
+ if (*formal_list && ((style == ansi) || (style == k_and_r_names)))
+ formal_list = concat (formal_list, ", ");
+ this_formal = gen_decl (formal_decl, 0, style);
+ if (style == k_and_r_decls)
+ formal_list = concat3 (formal_list, this_formal, "; ");
+ else
+ formal_list = concat (formal_list, this_formal);
+ formal_decl = TREE_CHAIN (formal_decl);
+ }
+ if (style == ansi)
+ {
+ if (!DECL_ARGUMENTS (fndecl))
+ formal_list = concat (formal_list, "void");
+ if (deserves_ellipsis (TREE_TYPE (fndecl)))
+ formal_list = concat (formal_list, ", ...");
+ }
+ if ((style == ansi) || (style == k_and_r_names))
+ formal_list = concat3 (" (", formal_list, ")");
+ return formal_list;
+}
+
+/* Generate a string which is the source code form for a given type (t). This
+ routine is ugly and complex because the C syntax for declarations is ugly
+ and complex. This routine is straightforward so long as *no* pointer types,
+ array types, or function types are involved.
+
+ In the simple cases, this routine will return the (string) value which was
+ passed in as the "ret_val" argument. Usually, this starts out either as an
+ empty string, or as the name of the declared item (i.e. the formal function
+ parameter variable).
+
+ This routine will also return with the global variable "data_type" set to
+ some string value which is the "basic" data-type of the given complete type.
+ This "data_type" string can be concatenated onto the front of the returned
+ string after this routine returns to its caller.
+
+ In complicated cases involving pointer types, array types, or function
+ types, the C declaration syntax requires an "inside out" approach, i.e. if
+ you have a type which is a "pointer-to-function" type, you need to handle
+ the "pointer" part first, but it also has to be "innermost" (relative to
+ the declaration stuff for the "function" type). Thus, is this case, you
+ must prepend a "(*" and append a ")" to the name of the item (i.e. formal
+ variable). Then you must append and prepend the other info for the
+ "function type" part of the overall type.
+
+ To handle the "innermost precedence" rules of complicated C declarators, we
+ do the following (in this routine). The input parameter called "ret_val"
+ is treated as a "seed". Each time gen_type is called (perhaps recursively)
+ some additional strings may be appended or prepended (or both) to the "seed"
+ string. If yet another (lower) level of the GCC tree exists for the given
+ type (as in the case of a pointer type, an array type, or a function type)
+ then the (wrapped) seed is passed to a (recursive) invocation of gen_type()
+ this recursive invocation may again "wrap" the (new) seed with yet more
+ declarator stuff, by appending, prepending (or both). By the time the
+ recursion bottoms out, the "seed value" at that point will have a value
+ which is (almost) the complete source version of the declarator (except
+ for the data_type info). Thus, this deepest "seed" value is simply passed
+ back up through all of the recursive calls until it is given (as the return
+ value) to the initial caller of the gen_type() routine. All that remains
+ to do at this point is for the initial caller to prepend the "data_type"
+ string onto the returned "seed". */
+
+static char*
+gen_type (ret_val, t, style)
+ char* ret_val;
+ tree t;
+ formals_style style;
+{
+ tree chain_p;
+
+ if (TYPE_NAME (t) && DECL_NAME (TYPE_NAME (t)))
+ data_type = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t)));
+ else
+ {
+ switch (TREE_CODE (t))
+ {
+ case POINTER_TYPE:
+ if (TYPE_READONLY (t))
+ ret_val = concat ("const ", ret_val);
+ if (TYPE_VOLATILE (t))
+ ret_val = concat ("volatile ", ret_val);
+
+ ret_val = concat ("*", ret_val);
+
+ if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
+ ret_val = concat3 ("(", ret_val, ")");
+
+ ret_val = gen_type (ret_val, TREE_TYPE (t), style);
+
+ return ret_val;
+
+ case ARRAY_TYPE:
+ if (TYPE_SIZE (t) == 0 || TREE_CODE (TYPE_SIZE (t)) != INTEGER_CST)
+ ret_val = gen_type (concat (ret_val, "[]"), TREE_TYPE (t), style);
+ else if (int_size_in_bytes (t) == 0)
+ ret_val = gen_type (concat (ret_val, "[0]"), TREE_TYPE (t), style);
+ else
+ {
+ int size = (int_size_in_bytes (t) / int_size_in_bytes (TREE_TYPE (t)));
+ char buff[10];
+ sprintf (buff, "[%d]", size);
+ ret_val = gen_type (concat (ret_val, buff),
+ TREE_TYPE (t), style);
+ }
+ break;
+
+ case FUNCTION_TYPE:
+ ret_val = gen_type (concat (ret_val, gen_formal_list_for_type (t, style)), TREE_TYPE (t), style);
+ break;
+
+ case IDENTIFIER_NODE:
+ data_type = IDENTIFIER_POINTER (t);
+ break;
+
+ /* The following three cases are complicated by the fact that a
+ user may do something really stupid, like creating a brand new
+ "anonymous" type specification in a formal argument list (or as
+ part of a function return type specification). For example:
+
+ int f (enum { red, green, blue } color);
+
+ In such cases, we have no name that we can put into the prototype
+ to represent the (anonymous) type. Thus, we have to generate the
+ whole darn type specification. Yuck! */
+
+ case RECORD_TYPE:
+ if (TYPE_NAME (t))
+ data_type = IDENTIFIER_POINTER (TYPE_NAME (t));
+ else
+ {
+ data_type = "";
+ chain_p = TYPE_FIELDS (t);
+ while (chain_p)
+ {
+ data_type = concat (data_type, gen_decl (chain_p, 0, ansi));
+ chain_p = TREE_CHAIN (chain_p);
+ data_type = concat (data_type, "; ");
+ }
+ data_type = concat3 ("{ ", data_type, "}");
+ }
+ data_type = concat ("struct ", data_type);
+ break;
+
+ case UNION_TYPE:
+ if (TYPE_NAME (t))
+ data_type = IDENTIFIER_POINTER (TYPE_NAME (t));
+ else
+ {
+ data_type = "";
+ chain_p = TYPE_FIELDS (t);
+ while (chain_p)
+ {
+ data_type = concat (data_type, gen_decl (chain_p, 0, ansi));
+ chain_p = TREE_CHAIN (chain_p);
+ data_type = concat (data_type, "; ");
+ }
+ data_type = concat3 ("{ ", data_type, "}");
+ }
+ data_type = concat ("union ", data_type);
+ break;
+
+ case ENUMERAL_TYPE:
+ if (TYPE_NAME (t))
+ data_type = IDENTIFIER_POINTER (TYPE_NAME (t));
+ else
+ {
+ data_type = "";
+ chain_p = TYPE_VALUES (t);
+ while (chain_p)
+ {
+ data_type = concat (data_type,
+ IDENTIFIER_POINTER (TREE_PURPOSE (chain_p)));
+ chain_p = TREE_CHAIN (chain_p);
+ if (chain_p)
+ data_type = concat (data_type, ", ");
+ }
+ data_type = concat3 ("{ ", data_type, " }");
+ }
+ data_type = concat ("enum ", data_type);
+ break;
+
+ case TYPE_DECL:
+ data_type = IDENTIFIER_POINTER (DECL_NAME (t));
+ break;
+
+ case INTEGER_TYPE:
+ data_type = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t)));
+ /* Normally, `unsigned' is part of the deal. Not so if it comes
+ with `const' or `volatile'. */
+ if (TREE_UNSIGNED (t) && (TYPE_READONLY (t) || TYPE_VOLATILE (t)))
+ data_type = concat ("unsigned ", data_type);
+ break;
+
+ case REAL_TYPE:
+ data_type = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t)));
+ break;
+
+ case VOID_TYPE:
+ data_type = "void";
+ break;
+
+ default:
+ abort ();
+ }
+ }
+ if (TYPE_READONLY (t))
+ ret_val = concat ("const ", ret_val);
+ if (TYPE_VOLATILE (t))
+ ret_val = concat ("volatile ", ret_val);
+ return ret_val;
+}
+
+/* Generate a string (source) representation of an entire entity declaration
+ (using some particular style for function types).
+
+ The given entity may be either a variable or a function.
+
+ If the "is_func_definition" parameter is non-zero, assume that the thing
+ we are generating a declaration for is a FUNCTION_DECL node which is
+ associated with a function definition. In this case, we can assume that
+ an attached list of DECL nodes for function formal arguments is present. */
+
+static char*
+gen_decl (decl, is_func_definition, style)
+ tree decl;
+ int is_func_definition;
+ formals_style style;
+{
+ char* ret_val;
+ char* outer_modifier = "";
+
+ if (DECL_NAME (decl))
+ ret_val = IDENTIFIER_POINTER (DECL_NAME (decl));
+ else
+ ret_val = "";
+
+ /* If we are just generating a list of names of formal parameters, we can
+ simply return the formal parameter name (with no typing information
+ attached to it) now. */
+
+ if (style == k_and_r_names)
+ return ret_val;
+
+ /* Note that for the declaration of some entity (either a function or a
+ data object, like for instance a parameter) if the entity itself was
+ declared as either const or volatile, then const and volatile properties
+ are associated with just the declaration of the entity, and *not* with
+ the `type' of the entity. Thus, for such declared entities, we have to
+ generate the qualifiers here. */
+
+ if (TREE_THIS_VOLATILE (decl))
+ ret_val = concat ("volatile ", ret_val);
+ if (TREE_READONLY (decl))
+ ret_val = concat ("const ", ret_val);
+
+ data_type = "";
+
+ /* For FUNCTION_DECL nodes, there are two possible cases here. First, if
+ this FUNCTION_DECL node was generated from a function "definition", then
+ we will have a list of DECL_NODE's, one for each of the function's formal
+ parameters. In this case, we can print out not only the types of each
+ formal, but also each formal's name. In the second case, this
+ FUNCTION_DECL node came from an actual function declaration (and *not*
+ a definition). In this case, we do nothing here because the formal
+ argument type-list will be output later, when the "type" of the function
+ is added to the string we are building. Note that the ANSI-style formal
+ parameter list is considered to be a (suffix) part of the "type" of the
+ function. */
+
+ if (TREE_CODE (decl) == FUNCTION_DECL && is_func_definition)
+ {
+ ret_val = concat (ret_val, gen_formal_list_for_func_def (decl, ansi));
+
+ /* Since we have already added in the formals list stuff, here we don't
+ add the whole "type" of the function we are considering (which
+ would include its parameter-list info), rather, we only add in
+ the "type" of the "type" of the function, which is really just
+ the return-type of the function (and does not include the parameter
+ list info). */
+
+ ret_val = gen_type (ret_val, TREE_TYPE (TREE_TYPE (decl)), style);
+ }
+ else
+ ret_val = gen_type (ret_val, TREE_TYPE (decl), style);
+
+ ret_val = affix_data_type (ret_val);
+
+ if (DECL_REGISTER (decl))
+ ret_val = concat ("register ", ret_val);
+ if (TREE_PUBLIC (decl))
+ ret_val = concat ("extern ", ret_val);
+ if (TREE_CODE (decl) == FUNCTION_DECL && !TREE_PUBLIC (decl))
+ ret_val = concat ("static ", ret_val);
+
+ return ret_val;
+}
+
+extern FILE* aux_info_file;
+
+/* Generate and write a new line of info to the aux-info (.X) file. This
+ routine is called once for each function declaration, and once for each
+ function definition (even the implicit ones). */
+
+void
+gen_aux_info_record (fndecl, is_definition, is_implicit, is_prototyped)
+ tree fndecl;
+ int is_definition;
+ int is_implicit;
+ int is_prototyped;
+{
+ if (flag_gen_aux_info)
+ {
+ static int compiled_from_record = 0;
+
+ /* Each output .X file must have a header line. Write one now if we
+ have not yet done so. */
+
+ if (! compiled_from_record++)
+ {
+ /* The first line tells which directory file names are relative to.
+ Currently, -aux-info works only for files in the working
+ directory, so just use a `.' as a placeholder for now. */
+ fprintf (aux_info_file, "/* compiled from: . */\n");
+ }
+
+ /* Write the actual line of auxiliary info. */
+
+ fprintf (aux_info_file, "/* %s:%d:%c%c */ %s;",
+ DECL_SOURCE_FILE (fndecl),
+ DECL_SOURCE_LINE (fndecl),
+ (is_implicit) ? 'I' : (is_prototyped) ? 'N' : 'O',
+ (is_definition) ? 'F' : 'C',
+ gen_decl (fndecl, is_definition, ansi));
+
+ /* If this is an explicit function declaration, we need to also write
+ out an old-style (i.e. K&R) function header, just in case the user
+ wants to run unprotoize. */
+
+ if (is_definition)
+ {
+ fprintf (aux_info_file, " /*%s %s*/",
+ gen_formal_list_for_func_def (fndecl, k_and_r_names),
+ gen_formal_list_for_func_def (fndecl, k_and_r_decls));
+ }
+
+ fprintf (aux_info_file, "\n");
+ }
+}
diff --git a/gnu/usr.bin/cc/cc1/c-convert.c b/gnu/usr.bin/cc/cc1/c-convert.c
new file mode 100644
index 000000000000..cfa590cfa6c2
--- /dev/null
+++ b/gnu/usr.bin/cc/cc1/c-convert.c
@@ -0,0 +1,95 @@
+/* Language-level data type conversion for GNU C.
+ Copyright (C) 1987, 1988, 1991 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+
+/* This file contains the functions for converting C expressions
+ to different data types. The only entry point is `convert'.
+ Every language front end must have a `convert' function
+ but what kind of conversions it does will depend on the language. */
+
+#include "config.h"
+#include "tree.h"
+#include "flags.h"
+#include "convert.h"
+
+/* Change of width--truncation and extension of integers or reals--
+ is represented with NOP_EXPR. Proper functioning of many things
+ assumes that no other conversions can be NOP_EXPRs.
+
+ Conversion between integer and pointer is represented with CONVERT_EXPR.
+ Converting integer to real uses FLOAT_EXPR
+ and real to integer uses FIX_TRUNC_EXPR.
+
+ Here is a list of all the functions that assume that widening and
+ narrowing is always done with a NOP_EXPR:
+ In convert.c, convert_to_integer.
+ In c-typeck.c, build_binary_op (boolean ops), and truthvalue_conversion.
+ In expr.c: expand_expr, for operands of a MULT_EXPR.
+ In fold-const.c: fold.
+ In tree.c: get_narrower and get_unwidened. */
+
+/* Subroutines of `convert'. */
+
+
+
+/* Create an expression whose value is that of EXPR,
+ converted to type TYPE. The TREE_TYPE of the value
+ is always TYPE. This function implements all reasonable
+ conversions; callers should filter out those that are
+ not permitted by the language being compiled. */
+
+tree
+convert (type, expr)
+ tree type, expr;
+{
+ register tree e = expr;
+ register enum tree_code code = TREE_CODE (type);
+
+ if (type == TREE_TYPE (expr)
+ || TREE_CODE (expr) == ERROR_MARK)
+ return expr;
+ if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (expr)))
+ return fold (build1 (NOP_EXPR, type, expr));
+ if (TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK)
+ return error_mark_node;
+ if (TREE_CODE (TREE_TYPE (expr)) == VOID_TYPE)
+ {
+ error ("void value not ignored as it ought to be");
+ return error_mark_node;
+ }
+ if (code == VOID_TYPE)
+ return build1 (CONVERT_EXPR, type, e);
+#if 0
+ /* This is incorrect. A truncation can't be stripped this way.
+ Extensions will be stripped by the use of get_unwidened. */
+ if (TREE_CODE (expr) == NOP_EXPR)
+ return convert (type, TREE_OPERAND (expr, 0));
+#endif
+ if (code == INTEGER_TYPE || code == ENUMERAL_TYPE)
+ return fold (convert_to_integer (type, e));
+ if (code == POINTER_TYPE)
+ return fold (convert_to_pointer (type, e));
+ if (code == REAL_TYPE)
+ return fold (convert_to_real (type, e));
+ if (code == COMPLEX_TYPE)
+ return fold (convert_to_complex (type, e));
+
+ error ("conversion to non-scalar type requested");
+ return error_mark_node;
+}
diff --git a/gnu/usr.bin/cc/cc1/c-decl.c b/gnu/usr.bin/cc/cc1/c-decl.c
new file mode 100644
index 000000000000..08f003e1f0e5
--- /dev/null
+++ b/gnu/usr.bin/cc/cc1/c-decl.c
@@ -0,0 +1,6494 @@
+/* Process declarations and variables for C compiler.
+ Copyright (C) 1988, 1992 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+
+/* Process declarations and symbol lookup for C front end.
+ Also constructs types; the standard scalar types at initialization,
+ and structure, union, array and enum types when they are declared. */
+
+/* ??? not all decl nodes are given the most useful possible
+ line numbers. For example, the CONST_DECLs for enum values. */
+
+#include "config.h"
+#include "tree.h"
+#include "flags.h"
+#include "c-tree.h"
+#include "c-lex.h"
+#include <stdio.h>
+
+/* In grokdeclarator, distinguish syntactic contexts of declarators. */
+enum decl_context
+{ NORMAL, /* Ordinary declaration */
+ FUNCDEF, /* Function definition */
+ PARM, /* Declaration of parm before function body */
+ FIELD, /* Declaration inside struct or union */
+ BITFIELD, /* Likewise but with specified width */
+ TYPENAME}; /* Typename (inside cast or sizeof) */
+
+#ifndef CHAR_TYPE_SIZE
+#define CHAR_TYPE_SIZE BITS_PER_UNIT
+#endif
+
+#ifndef SHORT_TYPE_SIZE
+#define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
+#endif
+
+#ifndef INT_TYPE_SIZE
+#define INT_TYPE_SIZE BITS_PER_WORD
+#endif
+
+#ifndef LONG_TYPE_SIZE
+#define LONG_TYPE_SIZE BITS_PER_WORD
+#endif
+
+#ifndef LONG_LONG_TYPE_SIZE
+#define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
+#endif
+
+#ifndef WCHAR_UNSIGNED
+#define WCHAR_UNSIGNED 0
+#endif
+
+#ifndef FLOAT_TYPE_SIZE
+#define FLOAT_TYPE_SIZE BITS_PER_WORD
+#endif
+
+#ifndef DOUBLE_TYPE_SIZE
+#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
+#endif
+
+#ifndef LONG_DOUBLE_TYPE_SIZE
+#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
+#endif
+
+/* We let tm.h override the types used here, to handle trivial differences
+ such as the choice of unsigned int or long unsigned int for size_t.
+ When machines start needing nontrivial differences in the size type,
+ it would be best to do something here to figure out automatically
+ from other information what type to use. */
+
+#ifndef SIZE_TYPE
+#define SIZE_TYPE "long unsigned int"
+#endif
+
+#ifndef PTRDIFF_TYPE
+#define PTRDIFF_TYPE "long int"
+#endif
+
+#ifndef WCHAR_TYPE
+#define WCHAR_TYPE "int"
+#endif
+
+/* a node which has tree code ERROR_MARK, and whose type is itself.
+ All erroneous expressions are replaced with this node. All functions
+ that accept nodes as arguments should avoid generating error messages
+ if this node is one of the arguments, since it is undesirable to get
+ multiple error messages from one error in the input. */
+
+tree error_mark_node;
+
+/* INTEGER_TYPE and REAL_TYPE nodes for the standard data types */
+
+tree short_integer_type_node;
+tree integer_type_node;
+tree long_integer_type_node;
+tree long_long_integer_type_node;
+
+tree short_unsigned_type_node;
+tree unsigned_type_node;
+tree long_unsigned_type_node;
+tree long_long_unsigned_type_node;
+
+tree ptrdiff_type_node;
+
+tree unsigned_char_type_node;
+tree signed_char_type_node;
+tree char_type_node;
+tree wchar_type_node;
+tree signed_wchar_type_node;
+tree unsigned_wchar_type_node;
+
+tree float_type_node;
+tree double_type_node;
+tree long_double_type_node;
+
+tree complex_integer_type_node;
+tree complex_float_type_node;
+tree complex_double_type_node;
+tree complex_long_double_type_node;
+
+tree intQI_type_node;
+tree intHI_type_node;
+tree intSI_type_node;
+tree intDI_type_node;
+
+tree unsigned_intQI_type_node;
+tree unsigned_intHI_type_node;
+tree unsigned_intSI_type_node;
+tree unsigned_intDI_type_node;
+
+/* a VOID_TYPE node. */
+
+tree void_type_node;
+
+/* Nodes for types `void *' and `const void *'. */
+
+tree ptr_type_node, const_ptr_type_node;
+
+/* Nodes for types `char *' and `const char *'. */
+
+tree string_type_node, const_string_type_node;
+
+/* Type `char[SOMENUMBER]'.
+ Used when an array of char is needed and the size is irrelevant. */
+
+tree char_array_type_node;
+
+/* Type `int[SOMENUMBER]' or something like it.
+ Used when an array of int needed and the size is irrelevant. */
+
+tree int_array_type_node;
+
+/* Type `wchar_t[SOMENUMBER]' or something like it.
+ Used when a wide string literal is created. */
+
+tree wchar_array_type_node;
+
+/* type `int ()' -- used for implicit declaration of functions. */
+
+tree default_function_type;
+
+/* function types `double (double)' and `double (double, double)', etc. */
+
+tree double_ftype_double, double_ftype_double_double;
+tree int_ftype_int, long_ftype_long;
+
+/* Function type `void (void *, void *, int)' and similar ones */
+
+tree void_ftype_ptr_ptr_int, int_ftype_ptr_ptr_int, void_ftype_ptr_int_int;
+
+/* Function type `char *(char *, char *)' and similar ones */
+tree string_ftype_ptr_ptr, int_ftype_string_string;
+
+/* Function type `int (const void *, const void *, size_t)' */
+tree int_ftype_cptr_cptr_sizet;
+
+/* Two expressions that are constants with value zero.
+ The first is of type `int', the second of type `void *'. */
+
+tree integer_zero_node;
+tree null_pointer_node;
+
+/* A node for the integer constant 1. */
+
+tree integer_one_node;
+
+/* Nonzero if we have seen an invalid cross reference
+ to a struct, union, or enum, but not yet printed the message. */
+
+tree pending_invalid_xref;
+/* File and line to appear in the eventual error message. */
+char *pending_invalid_xref_file;
+int pending_invalid_xref_line;
+
+/* While defining an enum type, this is 1 plus the last enumerator
+ constant value. */
+
+static tree enum_next_value;
+
+/* Nonzero means that there was overflow computing enum_next_value. */
+
+static int enum_overflow;
+
+/* Parsing a function declarator leaves a list of parameter names
+ or a chain or parameter decls here. */
+
+static tree last_function_parms;
+
+/* Parsing a function declarator leaves here a chain of structure
+ and enum types declared in the parmlist. */
+
+static tree last_function_parm_tags;
+
+/* After parsing the declarator that starts a function definition,
+ `start_function' puts here the list of parameter names or chain of decls.
+ `store_parm_decls' finds it here. */
+
+static tree current_function_parms;
+
+/* Similar, for last_function_parm_tags. */
+static tree current_function_parm_tags;
+
+/* Similar, for the file and line that the prototype came from if this is
+ an old-style definition. */
+static char *current_function_prototype_file;
+static int current_function_prototype_line;
+
+/* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function
+ that have names. Here so we can clear out their names' definitions
+ at the end of the function. */
+
+static tree named_labels;
+
+/* A list of LABEL_DECLs from outer contexts that are currently shadowed. */
+
+static tree shadowed_labels;
+
+/* Nonzero when store_parm_decls is called indicates a varargs function.
+ Value not meaningful after store_parm_decls. */
+
+static int c_function_varargs;
+
+/* The FUNCTION_DECL for the function currently being compiled,
+ or 0 if between functions. */
+tree current_function_decl;
+
+/* Set to 0 at beginning of a function definition, set to 1 if
+ a return statement that specifies a return value is seen. */
+
+int current_function_returns_value;
+
+/* Set to 0 at beginning of a function definition, set to 1 if
+ a return statement with no argument is seen. */
+
+int current_function_returns_null;
+
+/* Set to nonzero by `grokdeclarator' for a function
+ whose return type is defaulted, if warnings for this are desired. */
+
+static int warn_about_return_type;
+
+/* Nonzero when starting a function declared `extern inline'. */
+
+static int current_extern_inline;
+
+/* For each binding contour we allocate a binding_level structure
+ * which records the names defined in that contour.
+ * Contours include:
+ * 0) the global one
+ * 1) one for each function definition,
+ * where internal declarations of the parameters appear.
+ * 2) one for each compound statement,
+ * to record its declarations.
+ *
+ * The current meaning of a name can be found by searching the levels from
+ * the current one out to the global one.
+ */
+
+/* Note that the information in the `names' component of the global contour
+ is duplicated in the IDENTIFIER_GLOBAL_VALUEs of all identifiers. */
+
+struct binding_level
+ {
+ /* A chain of _DECL nodes for all variables, constants, functions,
+ and typedef types. These are in the reverse of the order supplied.
+ */
+ tree names;
+
+ /* A list of structure, union and enum definitions,
+ * for looking up tag names.
+ * It is a chain of TREE_LIST nodes, each of whose TREE_PURPOSE is a name,
+ * or NULL_TREE; and whose TREE_VALUE is a RECORD_TYPE, UNION_TYPE,
+ * or ENUMERAL_TYPE node.
+ */
+ tree tags;
+
+ /* For each level, a list of shadowed outer-level local definitions
+ to be restored when this level is popped.
+ Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and
+ whose TREE_VALUE is its old definition (a kind of ..._DECL node). */
+ tree shadowed;
+
+ /* For each level (except not the global one),
+ a chain of BLOCK nodes for all the levels
+ that were entered and exited one level down. */
+ tree blocks;
+
+ /* The BLOCK node for this level, if one has been preallocated.
+ If 0, the BLOCK is allocated (if needed) when the level is popped. */
+ tree this_block;
+
+ /* The binding level which this one is contained in (inherits from). */
+ struct binding_level *level_chain;
+
+ /* Nonzero for the level that holds the parameters of a function. */
+ char parm_flag;
+
+ /* Nonzero if this level "doesn't exist" for tags. */
+ char tag_transparent;
+
+ /* Nonzero if sublevels of this level "don't exist" for tags.
+ This is set in the parm level of a function definition
+ while reading the function body, so that the outermost block
+ of the function body will be tag-transparent. */
+ char subblocks_tag_transparent;
+
+ /* Nonzero means make a BLOCK for this level regardless of all else. */
+ char keep;
+
+ /* Nonzero means make a BLOCK if this level has any subblocks. */
+ char keep_if_subblocks;
+
+ /* Number of decls in `names' that have incomplete
+ structure or union types. */
+ int n_incomplete;
+
+ /* A list of decls giving the (reversed) specified order of parms,
+ not including any forward-decls in the parmlist.
+ This is so we can put the parms in proper order for assign_parms. */
+ tree parm_order;
+ };
+
+#define NULL_BINDING_LEVEL (struct binding_level *) NULL
+
+/* The binding level currently in effect. */
+
+static struct binding_level *current_binding_level;
+
+/* A chain of binding_level structures awaiting reuse. */
+
+static struct binding_level *free_binding_level;
+
+/* The outermost binding level, for names of file scope.
+ This is created when the compiler is started and exists
+ through the entire run. */
+
+static struct binding_level *global_binding_level;
+
+/* Binding level structures are initialized by copying this one. */
+
+static struct binding_level clear_binding_level
+ = {NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0};
+
+/* Nonzero means unconditionally make a BLOCK for the next level pushed. */
+
+static int keep_next_level_flag;
+
+/* Nonzero means make a BLOCK for the next level pushed
+ if it has subblocks. */
+
+static int keep_next_if_subblocks;
+
+/* The chain of outer levels of label scopes.
+ This uses the same data structure used for binding levels,
+ but it works differently: each link in the chain records
+ saved values of named_labels and shadowed_labels for
+ a label binding level outside the current one. */
+
+static struct binding_level *label_level_chain;
+
+/* Forward declarations. */
+
+static tree grokparms (), grokdeclarator ();
+tree pushdecl ();
+tree builtin_function ();
+void shadow_tag_warned ();
+
+static tree lookup_tag ();
+static tree lookup_tag_reverse ();
+tree lookup_name_current_level ();
+static char *redeclaration_error_message ();
+static void layout_array_type ();
+
+/* C-specific option variables. */
+
+/* Nonzero means allow type mismatches in conditional expressions;
+ just make their values `void'. */
+
+int flag_cond_mismatch;
+
+/* Nonzero means give `double' the same size as `float'. */
+
+int flag_short_double;
+
+/* Nonzero means don't recognize the keyword `asm'. */
+
+int flag_no_asm;
+
+/* Nonzero means don't recognize any builtin functions. */
+
+int flag_no_builtin;
+
+/* Nonzero means don't recognize the non-ANSI builtin functions.
+ -ansi sets this. */
+
+int flag_no_nonansi_builtin;
+
+/* Nonzero means do some things the same way PCC does. */
+
+int flag_traditional;
+
+/* Nonzero means to treat bitfields as signed unless they say `unsigned'. */
+
+int flag_signed_bitfields = 1;
+int explicit_flag_signed_bitfields = 0;
+
+/* Nonzero means handle `#ident' directives. 0 means ignore them. */
+
+int flag_no_ident = 0;
+
+/* Nonzero means warn about implicit declarations. */
+
+int warn_implicit;
+
+/* Nonzero means give string constants the type `const char *'
+ to get extra warnings from them. These warnings will be too numerous
+ to be useful, except in thoroughly ANSIfied programs. */
+
+int warn_write_strings;
+
+/* Nonzero means warn about pointer casts that can drop a type qualifier
+ from the pointer target type. */
+
+int warn_cast_qual;
+
+/* Warn about traditional constructs whose meanings changed in ANSI C. */
+
+int warn_traditional;
+
+/* Nonzero means warn about sizeof(function) or addition/subtraction
+ of function pointers. */
+
+int warn_pointer_arith;
+
+/* Nonzero means warn for non-prototype function decls
+ or non-prototyped defs without previous prototype. */
+
+int warn_strict_prototypes;
+
+/* Nonzero means warn for any global function def
+ without separate previous prototype decl. */
+
+int warn_missing_prototypes;
+
+/* Nonzero means warn about multiple (redundant) decls for the same single
+ variable or function. */
+
+int warn_redundant_decls = 0;
+
+/* Nonzero means warn about extern declarations of objects not at
+ file-scope level and about *all* declarations of functions (whether
+ extern or static) not at file-scope level. Note that we exclude
+ implicit function declarations. To get warnings about those, use
+ -Wimplicit. */
+
+int warn_nested_externs = 0;
+
+/* Warn about *printf or *scanf format/argument anomalies. */
+
+int warn_format;
+
+/* Warn about a subscript that has type char. */
+
+int warn_char_subscripts = 0;
+
+/* Warn if a type conversion is done that might have confusing results. */
+
+int warn_conversion;
+
+/* Warn if adding () is suggested. */
+
+int warn_parentheses;
+
+/* Warn if initializer is not completely bracketed. */
+
+int warn_missing_braces;
+
+/* Nonzero means `$' can be in an identifier.
+ See cccp.c for reasons why this breaks some obscure ANSI C programs. */
+
+#ifndef DOLLARS_IN_IDENTIFIERS
+#define DOLLARS_IN_IDENTIFIERS 1
+#endif
+int dollars_in_ident = DOLLARS_IN_IDENTIFIERS > 1;
+
+/* Decode the string P as a language-specific option for C.
+ Return 1 if it is recognized (and handle it);
+ return 0 if not recognized. */
+
+int
+c_decode_option (p)
+ char *p;
+{
+ if (!strcmp (p, "-ftraditional") || !strcmp (p, "-traditional"))
+ {
+ flag_traditional = 1;
+ flag_writable_strings = 1;
+#if DOLLARS_IN_IDENTIFIERS > 0
+ dollars_in_ident = 1;
+#endif
+ }
+ else if (!strcmp (p, "-fnotraditional") || !strcmp (p, "-fno-traditional"))
+ {
+ flag_traditional = 0;
+ flag_writable_strings = 0;
+ dollars_in_ident = DOLLARS_IN_IDENTIFIERS > 1;
+ }
+ else if (!strcmp (p, "-fsigned-char"))
+ flag_signed_char = 1;
+ else if (!strcmp (p, "-funsigned-char"))
+ flag_signed_char = 0;
+ else if (!strcmp (p, "-fno-signed-char"))
+ flag_signed_char = 0;
+ else if (!strcmp (p, "-fno-unsigned-char"))
+ flag_signed_char = 1;
+ else if (!strcmp (p, "-fsigned-bitfields")
+ || !strcmp (p, "-fno-unsigned-bitfields"))
+ {
+ flag_signed_bitfields = 1;
+ explicit_flag_signed_bitfields = 1;
+ }
+ else if (!strcmp (p, "-funsigned-bitfields")
+ || !strcmp (p, "-fno-signed-bitfields"))
+ {
+ flag_signed_bitfields = 0;
+ explicit_flag_signed_bitfields = 1;
+ }
+ else if (!strcmp (p, "-fshort-enums"))
+ flag_short_enums = 1;
+ else if (!strcmp (p, "-fno-short-enums"))
+ flag_short_enums = 0;
+ else if (!strcmp (p, "-fcond-mismatch"))
+ flag_cond_mismatch = 1;
+ else if (!strcmp (p, "-fno-cond-mismatch"))
+ flag_cond_mismatch = 0;
+ else if (!strcmp (p, "-fshort-double"))
+ flag_short_double = 1;
+ else if (!strcmp (p, "-fno-short-double"))
+ flag_short_double = 0;
+ else if (!strcmp (p, "-fasm"))
+ flag_no_asm = 0;
+ else if (!strcmp (p, "-fno-asm"))
+ flag_no_asm = 1;
+ else if (!strcmp (p, "-fbuiltin"))
+ flag_no_builtin = 0;
+ else if (!strcmp (p, "-fno-builtin"))
+ flag_no_builtin = 1;
+ else if (!strcmp (p, "-fno-ident"))
+ flag_no_ident = 1;
+ else if (!strcmp (p, "-fident"))
+ flag_no_ident = 0;
+ else if (!strcmp (p, "-ansi"))
+ flag_no_asm = 1, flag_no_nonansi_builtin = 1, dollars_in_ident = 0;
+ else if (!strcmp (p, "-Wimplicit"))
+ warn_implicit = 1;
+ else if (!strcmp (p, "-Wno-implicit"))
+ warn_implicit = 0;
+ else if (!strcmp (p, "-Wwrite-strings"))
+ warn_write_strings = 1;
+ else if (!strcmp (p, "-Wno-write-strings"))
+ warn_write_strings = 0;
+ else if (!strcmp (p, "-Wcast-qual"))
+ warn_cast_qual = 1;
+ else if (!strcmp (p, "-Wno-cast-qual"))
+ warn_cast_qual = 0;
+ else if (!strcmp (p, "-Wpointer-arith"))
+ warn_pointer_arith = 1;
+ else if (!strcmp (p, "-Wno-pointer-arith"))
+ warn_pointer_arith = 0;
+ else if (!strcmp (p, "-Wstrict-prototypes"))
+ warn_strict_prototypes = 1;
+ else if (!strcmp (p, "-Wno-strict-prototypes"))
+ warn_strict_prototypes = 0;
+ else if (!strcmp (p, "-Wmissing-prototypes"))
+ warn_missing_prototypes = 1;
+ else if (!strcmp (p, "-Wno-missing-prototypes"))
+ warn_missing_prototypes = 0;
+ else if (!strcmp (p, "-Wredundant-decls"))
+ warn_redundant_decls = 1;
+ else if (!strcmp (p, "-Wno-redundant-decls"))
+ warn_redundant_decls = 0;
+ else if (!strcmp (p, "-Wnested-externs"))
+ warn_nested_externs = 1;
+ else if (!strcmp (p, "-Wno-nested-externs"))
+ warn_nested_externs = 0;
+ else if (!strcmp (p, "-Wtraditional"))
+ warn_traditional = 1;
+ else if (!strcmp (p, "-Wno-traditional"))
+ warn_traditional = 0;
+ else if (!strcmp (p, "-Wformat"))
+ warn_format = 1;
+ else if (!strcmp (p, "-Wno-format"))
+ warn_format = 0;
+ else if (!strcmp (p, "-Wchar-subscripts"))
+ warn_char_subscripts = 1;
+ else if (!strcmp (p, "-Wno-char-subscripts"))
+ warn_char_subscripts = 0;
+ else if (!strcmp (p, "-Wconversion"))
+ warn_conversion = 1;
+ else if (!strcmp (p, "-Wno-conversion"))
+ warn_conversion = 0;
+ else if (!strcmp (p, "-Wparentheses"))
+ warn_parentheses = 1;
+ else if (!strcmp (p, "-Wno-parentheses"))
+ warn_parentheses = 0;
+ else if (!strcmp (p, "-Wreturn-type"))
+ warn_return_type = 1;
+ else if (!strcmp (p, "-Wno-return-type"))
+ warn_return_type = 0;
+ else if (!strcmp (p, "-Wcomment"))
+ ; /* cpp handles this one. */
+ else if (!strcmp (p, "-Wno-comment"))
+ ; /* cpp handles this one. */
+ else if (!strcmp (p, "-Wcomments"))
+ ; /* cpp handles this one. */
+ else if (!strcmp (p, "-Wno-comments"))
+ ; /* cpp handles this one. */
+ else if (!strcmp (p, "-Wtrigraphs"))
+ ; /* cpp handles this one. */
+ else if (!strcmp (p, "-Wno-trigraphs"))
+ ; /* cpp handles this one. */
+ else if (!strcmp (p, "-Wimport"))
+ ; /* cpp handles this one. */
+ else if (!strcmp (p, "-Wno-import"))
+ ; /* cpp handles this one. */
+ else if (!strcmp (p, "-Wmissing-braces"))
+ warn_missing_braces = 1;
+ else if (!strcmp (p, "-Wno-missing-braces"))
+ warn_missing_braces = 0;
+ else if (!strcmp (p, "-Wall"))
+ {
+ extra_warnings = 1;
+ /* We save the value of warn_uninitialized, since if they put
+ -Wuninitialized on the command line, we need to generate a
+ warning about not using it without also specifying -O. */
+ if (warn_uninitialized != 1)
+ warn_uninitialized = 2;
+ warn_implicit = 1;
+ warn_return_type = 1;
+ warn_unused = 1;
+ warn_switch = 1;
+ warn_format = 1;
+ warn_char_subscripts = 1;
+ warn_parentheses = 1;
+ warn_missing_braces = 1;
+ }
+ else
+ return 0;
+
+ return 1;
+}
+
+/* Hooks for print_node. */
+
+void
+print_lang_decl ()
+{
+}
+
+void
+print_lang_type ()
+{
+}
+
+void
+print_lang_identifier (file, node, indent)
+ FILE *file;
+ tree node;
+ int indent;
+{
+ print_node (file, "global", IDENTIFIER_GLOBAL_VALUE (node), indent + 4);
+ print_node (file, "local", IDENTIFIER_LOCAL_VALUE (node), indent + 4);
+ print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4);
+ print_node (file, "implicit", IDENTIFIER_IMPLICIT_DECL (node), indent + 4);
+ print_node (file, "error locus", IDENTIFIER_ERROR_LOCUS (node), indent + 4);
+ print_node (file, "limbo value", IDENTIFIER_LIMBO_VALUE (node), indent + 4);
+}
+
+/* Hook called at end of compilation to assume 1 elt
+ for a top-level array decl that wasn't complete before. */
+
+void
+finish_incomplete_decl (decl)
+ tree decl;
+{
+ if (TREE_CODE (decl) == VAR_DECL && TREE_TYPE (decl) != error_mark_node)
+ {
+ tree type = TREE_TYPE (decl);
+ if (TREE_CODE (type) == ARRAY_TYPE
+ && TYPE_DOMAIN (type) == 0
+ && TREE_CODE (decl) != TYPE_DECL)
+ {
+ complete_array_type (type, NULL_TREE, 1);
+
+ layout_decl (decl, 0);
+ }
+ }
+}
+
+/* Create a new `struct binding_level'. */
+
+static
+struct binding_level *
+make_binding_level ()
+{
+ /* NOSTRICT */
+ return (struct binding_level *) xmalloc (sizeof (struct binding_level));
+}
+
+/* Nonzero if we are currently in the global binding level. */
+
+int
+global_bindings_p ()
+{
+ return current_binding_level == global_binding_level;
+}
+
+void
+keep_next_level ()
+{
+ keep_next_level_flag = 1;
+}
+
+/* Nonzero if the current level needs to have a BLOCK made. */
+
+int
+kept_level_p ()
+{
+ return ((current_binding_level->keep_if_subblocks
+ && current_binding_level->blocks != 0)
+ || current_binding_level->keep
+ || current_binding_level->names != 0
+ || (current_binding_level->tags != 0
+ && !current_binding_level->tag_transparent));
+}
+
+/* Identify this binding level as a level of parameters.
+ DEFINITION_FLAG is 1 for a definition, 0 for a declaration.
+ But it turns out there is no way to pass the right value for
+ DEFINITION_FLAG, so we ignore it. */
+
+void
+declare_parm_level (definition_flag)
+ int definition_flag;
+{
+ current_binding_level->parm_flag = 1;
+}
+
+/* Nonzero if currently making parm declarations. */
+
+int
+in_parm_level_p ()
+{
+ return current_binding_level->parm_flag;
+}
+
+/* Enter a new binding level.
+ If TAG_TRANSPARENT is nonzero, do so only for the name space of variables,
+ not for that of tags. */
+
+void
+pushlevel (tag_transparent)
+ int tag_transparent;
+{
+ register struct binding_level *newlevel = NULL_BINDING_LEVEL;
+
+ /* If this is the top level of a function,
+ just make sure that NAMED_LABELS is 0. */
+
+ if (current_binding_level == global_binding_level)
+ {
+ named_labels = 0;
+ }
+
+ /* Reuse or create a struct for this binding level. */
+
+ if (free_binding_level)
+ {
+ newlevel = free_binding_level;
+ free_binding_level = free_binding_level->level_chain;
+ }
+ else
+ {
+ newlevel = make_binding_level ();
+ }
+
+ /* Add this level to the front of the chain (stack) of levels that
+ are active. */
+
+ *newlevel = clear_binding_level;
+ newlevel->tag_transparent
+ = (tag_transparent
+ || (current_binding_level
+ ? current_binding_level->subblocks_tag_transparent
+ : 0));
+ newlevel->level_chain = current_binding_level;
+ current_binding_level = newlevel;
+ newlevel->keep = keep_next_level_flag;
+ keep_next_level_flag = 0;
+ newlevel->keep_if_subblocks = keep_next_if_subblocks;
+ keep_next_if_subblocks = 0;
+}
+
+/* Exit a binding level.
+ Pop the level off, and restore the state of the identifier-decl mappings
+ that were in effect when this level was entered.
+
+ If KEEP is nonzero, this level had explicit declarations, so
+ and create a "block" (a BLOCK node) for the level
+ to record its declarations and subblocks for symbol table output.
+
+ If FUNCTIONBODY is nonzero, this level is the body of a function,
+ so create a block as if KEEP were set and also clear out all
+ label names.
+
+ If REVERSE is nonzero, reverse the order of decls before putting
+ them into the BLOCK. */
+
+tree
+poplevel (keep, reverse, functionbody)
+ int keep;
+ int reverse;
+ int functionbody;
+{
+ register tree link;
+ /* The chain of decls was accumulated in reverse order.
+ Put it into forward order, just for cleanliness. */
+ tree decls;
+ tree tags = current_binding_level->tags;
+ tree subblocks = current_binding_level->blocks;
+ tree block = 0;
+ tree decl;
+ int block_previously_created;
+
+ keep |= current_binding_level->keep;
+
+ /* This warning is turned off because it causes warnings for
+ declarations like `extern struct foo *x'. */
+#if 0
+ /* Warn about incomplete structure types in this level. */
+ for (link = tags; link; link = TREE_CHAIN (link))
+ if (TYPE_SIZE (TREE_VALUE (link)) == 0)
+ {
+ tree type = TREE_VALUE (link);
+ char *errmsg;
+ switch (TREE_CODE (type))
+ {
+ case RECORD_TYPE:
+ errmsg = "`struct %s' incomplete in scope ending here";
+ break;
+ case UNION_TYPE:
+ errmsg = "`union %s' incomplete in scope ending here";
+ break;
+ case ENUMERAL_TYPE:
+ errmsg = "`enum %s' incomplete in scope ending here";
+ break;
+ }
+ if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
+ error (errmsg, IDENTIFIER_POINTER (TYPE_NAME (type)));
+ else
+ /* If this type has a typedef-name, the TYPE_NAME is a TYPE_DECL. */
+ error (errmsg, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
+ }
+#endif /* 0 */
+
+ /* Get the decls in the order they were written.
+ Usually current_binding_level->names is in reverse order.
+ But parameter decls were previously put in forward order. */
+
+ if (reverse)
+ current_binding_level->names
+ = decls = nreverse (current_binding_level->names);
+ else
+ decls = current_binding_level->names;
+
+ /* Output any nested inline functions within this block
+ if they weren't already output. */
+
+ for (decl = decls; decl; decl = TREE_CHAIN (decl))
+ if (TREE_CODE (decl) == FUNCTION_DECL
+ && ! TREE_ASM_WRITTEN (decl)
+ && DECL_INITIAL (decl) != 0
+ && TREE_ADDRESSABLE (decl))
+ {
+ /* If this decl was copied from a file-scope decl
+ on account of a block-scope extern decl,
+ propagate TREE_ADDRESSABLE to the file-scope decl. */
+ if (DECL_ABSTRACT_ORIGIN (decl) != 0)
+ TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (decl)) = 1;
+ else
+ output_inline_function (decl);
+ }
+
+ /* If there were any declarations or structure tags in that level,
+ or if this level is a function body,
+ create a BLOCK to record them for the life of this function. */
+
+ block = 0;
+ block_previously_created = (current_binding_level->this_block != 0);
+ if (block_previously_created)
+ block = current_binding_level->this_block;
+ else if (keep || functionbody
+ || (current_binding_level->keep_if_subblocks && subblocks != 0))
+ block = make_node (BLOCK);
+ if (block != 0)
+ {
+ BLOCK_VARS (block) = decls;
+ BLOCK_TYPE_TAGS (block) = tags;
+ BLOCK_SUBBLOCKS (block) = subblocks;
+ remember_end_note (block);
+ }
+
+ /* In each subblock, record that this is its superior. */
+
+ for (link = subblocks; link; link = TREE_CHAIN (link))
+ BLOCK_SUPERCONTEXT (link) = block;
+
+ /* Clear out the meanings of the local variables of this level. */
+
+ for (link = decls; link; link = TREE_CHAIN (link))
+ {
+ if (DECL_NAME (link) != 0)
+ {
+ /* If the ident. was used or addressed via a local extern decl,
+ don't forget that fact. */
+ if (DECL_EXTERNAL (link))
+ {
+ if (TREE_USED (link))
+ TREE_USED (DECL_NAME (link)) = 1;
+ if (TREE_ADDRESSABLE (link))
+ TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (link)) = 1;
+ }
+ IDENTIFIER_LOCAL_VALUE (DECL_NAME (link)) = 0;
+ }
+ }
+
+ /* Restore all name-meanings of the outer levels
+ that were shadowed by this level. */
+
+ for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link))
+ IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
+
+ /* If the level being exited is the top level of a function,
+ check over all the labels, and clear out the current
+ (function local) meanings of their names. */
+
+ if (functionbody)
+ {
+ /* If this is the top level block of a function,
+ the vars are the function's parameters.
+ Don't leave them in the BLOCK because they are
+ found in the FUNCTION_DECL instead. */
+
+ BLOCK_VARS (block) = 0;
+
+ /* Clear out the definitions of all label names,
+ since their scopes end here,
+ and add them to BLOCK_VARS. */
+
+ for (link = named_labels; link; link = TREE_CHAIN (link))
+ {
+ register tree label = TREE_VALUE (link);
+
+ if (DECL_INITIAL (label) == 0)
+ {
+ error_with_decl (label, "label `%s' used but not defined");
+ /* Avoid crashing later. */
+ define_label (input_filename, lineno,
+ DECL_NAME (label));
+ }
+ else if (warn_unused && !TREE_USED (label))
+ warning_with_decl (label, "label `%s' defined but not used");
+ IDENTIFIER_LABEL_VALUE (DECL_NAME (label)) = 0;
+
+ /* Put the labels into the "variables" of the
+ top-level block, so debugger can see them. */
+ TREE_CHAIN (label) = BLOCK_VARS (block);
+ BLOCK_VARS (block) = label;
+ }
+ }
+
+ /* Pop the current level, and free the structure for reuse. */
+
+ {
+ register struct binding_level *level = current_binding_level;
+ current_binding_level = current_binding_level->level_chain;
+
+ level->level_chain = free_binding_level;
+ free_binding_level = level;
+ }
+
+ /* Dispose of the block that we just made inside some higher level. */
+ if (functionbody)
+ DECL_INITIAL (current_function_decl) = block;
+ else if (block)
+ {
+ if (!block_previously_created)
+ current_binding_level->blocks
+ = chainon (current_binding_level->blocks, block);
+ }
+ /* If we did not make a block for the level just exited,
+ any blocks made for inner levels
+ (since they cannot be recorded as subblocks in that level)
+ must be carried forward so they will later become subblocks
+ of something else. */
+ else if (subblocks)
+ current_binding_level->blocks
+ = chainon (current_binding_level->blocks, subblocks);
+
+ /* Set the TYPE_CONTEXTs for all of the tagged types belonging to this
+ binding contour so that they point to the appropriate construct, i.e.
+ either to the current FUNCTION_DECL node, or else to the BLOCK node
+ we just constructed.
+
+ Note that for tagged types whose scope is just the formal parameter
+ list for some function type specification, we can't properly set
+ their TYPE_CONTEXTs here, because we don't have a pointer to the
+ appropriate FUNCTION_TYPE node readily available to us. For those
+ cases, the TYPE_CONTEXTs of the relevant tagged type nodes get set
+ in `grokdeclarator' as soon as we have created the FUNCTION_TYPE
+ node which will represent the "scope" for these "parameter list local"
+ tagged types.
+ */
+
+ if (functionbody)
+ for (link = tags; link; link = TREE_CHAIN (link))
+ TYPE_CONTEXT (TREE_VALUE (link)) = current_function_decl;
+ else if (block)
+ for (link = tags; link; link = TREE_CHAIN (link))
+ TYPE_CONTEXT (TREE_VALUE (link)) = block;
+
+ if (block)
+ TREE_USED (block) = 1;
+ return block;
+}
+
+/* Delete the node BLOCK from the current binding level.
+ This is used for the block inside a stmt expr ({...})
+ so that the block can be reinserted where appropriate. */
+
+void
+delete_block (block)
+ tree block;
+{
+ tree t;
+ if (current_binding_level->blocks == block)
+ current_binding_level->blocks = TREE_CHAIN (block);
+ for (t = current_binding_level->blocks; t;)
+ {
+ if (TREE_CHAIN (t) == block)
+ TREE_CHAIN (t) = TREE_CHAIN (block);
+ else
+ t = TREE_CHAIN (t);
+ }
+ TREE_CHAIN (block) = NULL;
+ /* Clear TREE_USED which is always set by poplevel.
+ The flag is set again if insert_block is called. */
+ TREE_USED (block) = 0;
+}
+
+/* Insert BLOCK at the end of the list of subblocks of the
+ current binding level. This is used when a BIND_EXPR is expanded,
+ to handle the BLOCK node inside teh BIND_EXPR. */
+
+void
+insert_block (block)
+ tree block;
+{
+ TREE_USED (block) = 1;
+ current_binding_level->blocks
+ = chainon (current_binding_level->blocks, block);
+}
+
+/* Set the BLOCK node for the innermost scope
+ (the one we are currently in). */
+
+void
+set_block (block)
+ register tree block;
+{
+ current_binding_level->this_block = block;
+}
+
+void
+push_label_level ()
+{
+ register struct binding_level *newlevel;
+
+ /* Reuse or create a struct for this binding level. */
+
+ if (free_binding_level)
+ {
+ newlevel = free_binding_level;
+ free_binding_level = free_binding_level->level_chain;
+ }
+ else
+ {
+ newlevel = make_binding_level ();
+ }
+
+ /* Add this level to the front of the chain (stack) of label levels. */
+
+ newlevel->level_chain = label_level_chain;
+ label_level_chain = newlevel;
+
+ newlevel->names = named_labels;
+ newlevel->shadowed = shadowed_labels;
+ named_labels = 0;
+ shadowed_labels = 0;
+}
+
+void
+pop_label_level ()
+{
+ register struct binding_level *level = label_level_chain;
+ tree link, prev;
+
+ /* Clear out the definitions of the declared labels in this level.
+ Leave in the list any ordinary, non-declared labels. */
+ for (link = named_labels, prev = 0; link;)
+ {
+ if (C_DECLARED_LABEL_FLAG (TREE_VALUE (link)))
+ {
+ if (DECL_SOURCE_LINE (TREE_VALUE (link)) == 0)
+ {
+ error_with_decl (TREE_VALUE (link),
+ "label `%s' used but not defined");
+ /* Avoid crashing later. */
+ define_label (input_filename, lineno,
+ DECL_NAME (TREE_VALUE (link)));
+ }
+ else if (warn_unused && !TREE_USED (TREE_VALUE (link)))
+ warning_with_decl (TREE_VALUE (link),
+ "label `%s' defined but not used");
+ IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link))) = 0;
+
+ /* Delete this element from the list. */
+ link = TREE_CHAIN (link);
+ if (prev)
+ TREE_CHAIN (prev) = link;
+ else
+ named_labels = link;
+ }
+ else
+ {
+ prev = link;
+ link = TREE_CHAIN (link);
+ }
+ }
+
+ /* Bring back all the labels that were shadowed. */
+ for (link = shadowed_labels; link; link = TREE_CHAIN (link))
+ if (DECL_NAME (TREE_VALUE (link)) != 0)
+ IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link)))
+ = TREE_VALUE (link);
+
+ named_labels = chainon (named_labels, level->names);
+ shadowed_labels = level->shadowed;
+
+ /* Pop the current level, and free the structure for reuse. */
+ label_level_chain = label_level_chain->level_chain;
+ level->level_chain = free_binding_level;
+ free_binding_level = level;
+}
+
+/* Push a definition or a declaration of struct, union or enum tag "name".
+ "type" should be the type node.
+ We assume that the tag "name" is not already defined.
+
+ Note that the definition may really be just a forward reference.
+ In that case, the TYPE_SIZE will be zero. */
+
+void
+pushtag (name, type)
+ tree name, type;
+{
+ register struct binding_level *b;
+
+ /* Find the proper binding level for this type tag. */
+
+ for (b = current_binding_level; b->tag_transparent; b = b->level_chain)
+ continue;
+
+ if (name)
+ {
+ /* Record the identifier as the type's name if it has none. */
+
+ if (TYPE_NAME (type) == 0)
+ TYPE_NAME (type) = name;
+ }
+
+ if (b == global_binding_level)
+ b->tags = perm_tree_cons (name, type, b->tags);
+ else
+ b->tags = saveable_tree_cons (name, type, b->tags);
+
+ /* Create a fake NULL-named TYPE_DECL node whose TREE_TYPE will be the
+ tagged type we just added to the current binding level. This fake
+ NULL-named TYPE_DECL node helps dwarfout.c to know when it needs
+ to output a representation of a tagged type, and it also gives
+ us a convenient place to record the "scope start" address for the
+ tagged type. */
+
+ TYPE_STUB_DECL (type) = pushdecl (build_decl (TYPE_DECL, NULL_TREE, type));
+}
+
+/* Handle when a new declaration NEWDECL
+ has the same name as an old one OLDDECL
+ in the same binding contour.
+ Prints an error message if appropriate.
+
+ If safely possible, alter OLDDECL to look like NEWDECL, and return 1.
+ Otherwise, return 0. */
+
+static int
+duplicate_decls (newdecl, olddecl)
+ register tree newdecl, olddecl;
+{
+ int types_match = comptypes (TREE_TYPE (newdecl), TREE_TYPE (olddecl));
+ int new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL
+ && DECL_INITIAL (newdecl) != 0);
+ tree oldtype = TREE_TYPE (olddecl);
+ tree newtype = TREE_TYPE (newdecl);
+
+ if (TREE_CODE (newtype) == ERROR_MARK
+ || TREE_CODE (oldtype) == ERROR_MARK)
+ types_match = 0;
+
+ /* New decl is completely inconsistent with the old one =>
+ tell caller to replace the old one.
+ This is always an error except in the case of shadowing a builtin. */
+ if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
+ {
+ if (TREE_CODE (olddecl) == FUNCTION_DECL
+ && DECL_BUILT_IN (olddecl))
+ {
+ /* If you declare a built-in function name as static, the
+ built-in definition is overridden,
+ but optionally warn this was a bad choice of name. */
+ if (!TREE_PUBLIC (newdecl))
+ {
+ if (warn_shadow)
+ warning_with_decl (newdecl, "shadowing built-in function `%s'");
+ }
+ /* Likewise, if the built-in is not ansi, then programs can
+ override it even globally without an error. */
+ else if (DECL_BUILT_IN_NONANSI (olddecl))
+ warning_with_decl (newdecl,
+ "built-in function `%s' declared as non-function");
+ else
+ error_with_decl (newdecl,
+ "built-in function `%s' declared as non-function");
+ }
+ else if (TREE_CODE (olddecl) == FUNCTION_DECL
+ && DECL_BUILT_IN_NONANSI (olddecl))
+ {
+ /* If overriding decl is static,
+ optionally warn this was a bad choice of name. */
+ if (!TREE_PUBLIC (newdecl))
+ {
+ if (warn_shadow)
+ warning_with_decl (newdecl, "shadowing library function `%s'");
+ }
+ /* Otherwise, always warn. */
+ else
+ warning_with_decl (newdecl,
+ "library function `%s' declared as non-function");
+ }
+ else
+ {
+ error_with_decl (newdecl, "`%s' redeclared as different kind of symbol");
+ error_with_decl (olddecl, "previous declaration of `%s'");
+ }
+
+ return 0;
+ }
+
+ /* For real parm decl following a forward decl,
+ return 1 so old decl will be reused. */
+ if (types_match && TREE_CODE (newdecl) == PARM_DECL
+ && TREE_ASM_WRITTEN (olddecl) && ! TREE_ASM_WRITTEN (newdecl))
+ return 1;
+
+ /* The new declaration is the same kind of object as the old one.
+ The declarations may partially match. Print warnings if they don't
+ match enough. Ultimately, copy most of the information from the new
+ decl to the old one, and keep using the old one. */
+
+ if (flag_traditional && TREE_CODE (newdecl) == FUNCTION_DECL
+ && IDENTIFIER_IMPLICIT_DECL (DECL_NAME (newdecl)) == olddecl
+ && DECL_INITIAL (olddecl) == 0)
+ /* If -traditional, avoid error for redeclaring fcn
+ after implicit decl. */
+ ;
+ else if (TREE_CODE (olddecl) == FUNCTION_DECL
+ && DECL_BUILT_IN (olddecl))
+ {
+ /* A function declaration for a built-in function. */
+ if (!TREE_PUBLIC (newdecl))
+ {
+ /* If you declare a built-in function name as static, the
+ built-in definition is overridden,
+ but optionally warn this was a bad choice of name. */
+ if (warn_shadow)
+ warning_with_decl (newdecl, "shadowing built-in function `%s'");
+ /* Discard the old built-in function. */
+ return 0;
+ }
+ else if (!types_match)
+ {
+ /* Accept the return type of the new declaration if same modes. */
+ tree oldreturntype = TREE_TYPE (TREE_TYPE (olddecl));
+ tree newreturntype = TREE_TYPE (TREE_TYPE (newdecl));
+ if (TYPE_MODE (oldreturntype) == TYPE_MODE (newreturntype))
+ {
+ /* Function types may be shared, so we can't just modify
+ the return type of olddecl's function type. */
+ tree newtype
+ = build_function_type (newreturntype,
+ TYPE_ARG_TYPES (TREE_TYPE (olddecl)));
+
+ types_match = comptypes (TREE_TYPE (newdecl), newtype);
+ if (types_match)
+ TREE_TYPE (olddecl) = newtype;
+ }
+ /* Accept harmless mismatch in first argument type also.
+ This is for ffs. */
+ if (TYPE_ARG_TYPES (TREE_TYPE (newdecl)) != 0
+ && TYPE_ARG_TYPES (TREE_TYPE (olddecl)) != 0
+ && TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (newdecl))) != 0
+ && TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (olddecl))) != 0
+ && (TYPE_MODE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (newdecl))))
+ ==
+ TYPE_MODE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (olddecl))))))
+ {
+ /* Function types may be shared, so we can't just modify
+ the return type of olddecl's function type. */
+ tree newtype
+ = build_function_type (TREE_TYPE (TREE_TYPE (olddecl)),
+ tree_cons (NULL_TREE,
+ TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (newdecl))),
+ TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (olddecl)))));
+
+ types_match = comptypes (TREE_TYPE (newdecl), newtype);
+ if (types_match)
+ TREE_TYPE (olddecl) = newtype;
+ }
+ }
+ if (!types_match)
+ {
+ /* If types don't match for a built-in, throw away the built-in. */
+ warning_with_decl (newdecl, "conflicting types for built-in function `%s'");
+ return 0;
+ }
+ }
+ else if (TREE_CODE (olddecl) == FUNCTION_DECL
+ && DECL_SOURCE_LINE (olddecl) == 0)
+ {
+ /* A function declaration for a predeclared function
+ that isn't actually built in. */
+ if (!TREE_PUBLIC (newdecl))
+ {
+ /* If you declare it as static, the
+ default definition is overridden. */
+ return 0;
+ }
+ else if (!types_match)
+ {
+ /* If the types don't match, preserve volatility indication.
+ Later on, we will discard everything else about the
+ default declaration. */
+ TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
+ }
+ }
+ /* Permit char *foo () to match void *foo (...) if not pedantic,
+ if one of them came from a system header file. */
+ else if (!types_match
+ && TREE_CODE (olddecl) == FUNCTION_DECL
+ && TREE_CODE (newdecl) == FUNCTION_DECL
+ && TREE_CODE (TREE_TYPE (oldtype)) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (newtype)) == POINTER_TYPE
+ && (DECL_IN_SYSTEM_HEADER (olddecl)
+ || DECL_IN_SYSTEM_HEADER (newdecl))
+ && ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (newtype))) == void_type_node
+ && TYPE_ARG_TYPES (oldtype) == 0
+ && self_promoting_args_p (TYPE_ARG_TYPES (newtype))
+ && TREE_TYPE (TREE_TYPE (oldtype)) == char_type_node)
+ ||
+ (TREE_TYPE (TREE_TYPE (newtype)) == char_type_node
+ && TYPE_ARG_TYPES (newtype) == 0
+ && self_promoting_args_p (TYPE_ARG_TYPES (oldtype))
+ && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (oldtype))) == void_type_node)))
+ {
+ if (pedantic)
+ pedwarn_with_decl (newdecl, "conflicting types for `%s'");
+ /* Make sure we keep void * as ret type, not char *. */
+ if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (oldtype))) == void_type_node)
+ TREE_TYPE (newdecl) = newtype = oldtype;
+ }
+ else if (!types_match
+ /* Permit char *foo (int, ...); followed by char *foo ();
+ if not pedantic. */
+ && ! (TREE_CODE (olddecl) == FUNCTION_DECL
+ && ! pedantic
+ /* Return types must still match. */
+ && comptypes (TREE_TYPE (oldtype),
+ TREE_TYPE (newtype))
+ && TYPE_ARG_TYPES (newtype) == 0))
+ {
+ error_with_decl (newdecl, "conflicting types for `%s'");
+ /* Check for function type mismatch
+ involving an empty arglist vs a nonempty one. */
+ if (TREE_CODE (olddecl) == FUNCTION_DECL
+ && comptypes (TREE_TYPE (oldtype),
+ TREE_TYPE (newtype))
+ && ((TYPE_ARG_TYPES (oldtype) == 0
+ && DECL_INITIAL (olddecl) == 0)
+ ||
+ (TYPE_ARG_TYPES (newtype) == 0
+ && DECL_INITIAL (newdecl) == 0)))
+ {
+ /* Classify the problem further. */
+ register tree t = TYPE_ARG_TYPES (oldtype);
+ if (t == 0)
+ t = TYPE_ARG_TYPES (newtype);
+ for (; t; t = TREE_CHAIN (t))
+ {
+ register tree type = TREE_VALUE (t);
+
+ if (TREE_CHAIN (t) == 0
+ && TYPE_MAIN_VARIANT (type) != void_type_node)
+ {
+ error ("A parameter list with an ellipsis can't match");
+ error ("an empty parameter name list declaration.");
+ break;
+ }
+
+ if (TYPE_MAIN_VARIANT (type) == float_type_node
+ || C_PROMOTING_INTEGER_TYPE_P (type))
+ {
+ error ("An argument type that has a default promotion");
+ error ("can't match an empty parameter name list declaration.");
+ break;
+ }
+ }
+ }
+ error_with_decl (olddecl, "previous declaration of `%s'");
+ }
+ else
+ {
+ char *errmsg = redeclaration_error_message (newdecl, olddecl);
+ if (errmsg)
+ {
+ error_with_decl (newdecl, errmsg);
+ error_with_decl (olddecl,
+ ((DECL_INITIAL (olddecl)
+ && current_binding_level == global_binding_level)
+ ? "`%s' previously defined here"
+ : "`%s' previously declared here"));
+ }
+ else if (TREE_CODE (olddecl) == FUNCTION_DECL
+ && DECL_INITIAL (olddecl) != 0
+ && TYPE_ARG_TYPES (oldtype) == 0
+ && TYPE_ARG_TYPES (newtype) != 0)
+ {
+ register tree type, parm;
+ register int nargs;
+ /* Prototype decl follows defn w/o prototype. */
+
+ for (parm = TYPE_ACTUAL_ARG_TYPES (oldtype),
+ type = TYPE_ARG_TYPES (newtype),
+ nargs = 1;
+ (TYPE_MAIN_VARIANT (TREE_VALUE (parm)) != void_type_node
+ || TYPE_MAIN_VARIANT (TREE_VALUE (type)) != void_type_node);
+ parm = TREE_CHAIN (parm), type = TREE_CHAIN (type), nargs++)
+ {
+ if (TYPE_MAIN_VARIANT (TREE_VALUE (parm)) == void_type_node
+ || TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node)
+ {
+ errmsg = "prototype for `%s' follows and number of arguments";
+ break;
+ }
+ /* Type for passing arg must be consistent
+ with that declared for the arg. */
+ if (! comptypes (TREE_VALUE (parm), TREE_VALUE (type))
+ /* If -traditional, allow `unsigned int' instead of `int'
+ in the prototype. */
+ && (! (flag_traditional
+ && TYPE_MAIN_VARIANT (TREE_VALUE (parm)) == integer_type_node
+ && TYPE_MAIN_VARIANT (TREE_VALUE (type)) == unsigned_type_node)))
+ {
+ errmsg = "prototype for `%s' follows and argument %d";
+ break;
+ }
+ }
+ if (errmsg)
+ {
+ error_with_decl (newdecl, errmsg, nargs);
+ error_with_decl (olddecl,
+ "doesn't match non-prototype definition here");
+ }
+ else
+ {
+ warning_with_decl (newdecl, "prototype for `%s' follows");
+ warning_with_decl (olddecl, "non-prototype definition here");
+ }
+ }
+ /* Warn about mismatches in various flags. */
+ else
+ {
+ /* Warn if function is now inline
+ but was previously declared not inline and has been called. */
+ if (TREE_CODE (olddecl) == FUNCTION_DECL
+ && ! DECL_INLINE (olddecl) && DECL_INLINE (newdecl)
+ && TREE_USED (olddecl))
+ warning_with_decl (newdecl,
+ "`%s' declared inline after being called");
+ if (TREE_CODE (olddecl) == FUNCTION_DECL
+ && ! DECL_INLINE (olddecl) && DECL_INLINE (newdecl)
+ && DECL_INITIAL (olddecl) != 0)
+ warning_with_decl (newdecl,
+ "`%s' declared inline after its definition");
+ /* It is nice to warn when a function is declared
+ global first and then static. */
+ if (TREE_CODE (olddecl) == FUNCTION_DECL
+ && TREE_PUBLIC (olddecl)
+ && !TREE_PUBLIC (newdecl))
+ warning_with_decl (newdecl, "static declaration for `%s' follows non-static");
+
+ /* These bits are logically part of the type, for variables.
+ But not for functions
+ (where qualifiers are not valid ANSI anyway). */
+ if (pedantic && TREE_CODE (olddecl) != FUNCTION_DECL
+ && (TREE_READONLY (newdecl) != TREE_READONLY (olddecl)
+ || TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl)))
+ pedwarn_with_decl (newdecl, "type qualifiers for `%s' conflict with previous decl");
+ }
+ }
+
+ /* Optionally warn about more than one declaration for the same name. */
+ if (warn_redundant_decls && DECL_SOURCE_LINE (olddecl) != 0
+ /* Dont warn about a function declaration
+ followed by a definition. */
+ && !(TREE_CODE (newdecl) == FUNCTION_DECL && DECL_INITIAL (newdecl) != 0
+ && DECL_INITIAL (olddecl) == 0))
+ {
+ warning_with_decl (newdecl, "redundant redeclaration of `%s' in same scope");
+ warning_with_decl (olddecl, "previous declaration of `%s'");
+ }
+
+ /* Copy all the DECL_... slots specified in the new decl
+ except for any that we copy here from the old type.
+
+ Past this point, we don't change OLDTYPE and NEWTYPE
+ even if we change the types of NEWDECL and OLDDECL. */
+
+ if (types_match)
+ {
+ /* Merge the data types specified in the two decls. */
+ if (TREE_CODE (newdecl) != FUNCTION_DECL || !DECL_BUILT_IN (olddecl))
+ TREE_TYPE (newdecl)
+ = TREE_TYPE (olddecl)
+ = common_type (newtype, oldtype);
+
+ /* Lay the type out, unless already done. */
+ if (oldtype != TREE_TYPE (newdecl))
+ {
+ if (TREE_TYPE (newdecl) != error_mark_node)
+ layout_type (TREE_TYPE (newdecl));
+ if (TREE_CODE (newdecl) != FUNCTION_DECL
+ && TREE_CODE (newdecl) != TYPE_DECL
+ && TREE_CODE (newdecl) != CONST_DECL)
+ layout_decl (newdecl, 0);
+ }
+ else
+ {
+ /* Since the type is OLDDECL's, make OLDDECL's size go with. */
+ DECL_SIZE (newdecl) = DECL_SIZE (olddecl);
+ if (TREE_CODE (olddecl) != FUNCTION_DECL)
+ if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
+ DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl);
+ }
+
+ /* Keep the old rtl since we can safely use it. */
+ DECL_RTL (newdecl) = DECL_RTL (olddecl);
+
+ /* Merge the type qualifiers. */
+ if (DECL_BUILT_IN_NONANSI (olddecl) && TREE_THIS_VOLATILE (olddecl)
+ && !TREE_THIS_VOLATILE (newdecl))
+ TREE_THIS_VOLATILE (olddecl) = 0;
+ if (TREE_READONLY (newdecl))
+ TREE_READONLY (olddecl) = 1;
+ if (TREE_THIS_VOLATILE (newdecl))
+ {
+ TREE_THIS_VOLATILE (olddecl) = 1;
+ if (TREE_CODE (newdecl) == VAR_DECL)
+ make_var_volatile (newdecl);
+ }
+
+ /* Keep source location of definition rather than declaration. */
+ if (DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0)
+ {
+ DECL_SOURCE_LINE (newdecl) = DECL_SOURCE_LINE (olddecl);
+ DECL_SOURCE_FILE (newdecl) = DECL_SOURCE_FILE (olddecl);
+ }
+
+ /* Merge the unused-warning information. */
+ if (DECL_IN_SYSTEM_HEADER (olddecl))
+ DECL_IN_SYSTEM_HEADER (newdecl) = 1;
+ else if (DECL_IN_SYSTEM_HEADER (newdecl))
+ DECL_IN_SYSTEM_HEADER (olddecl) = 1;
+
+ /* Merge the initialization information. */
+ if (DECL_INITIAL (newdecl) == 0)
+ DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
+ }
+ /* If cannot merge, then use the new type and qualifiers,
+ and don't preserve the old rtl. */
+ else
+ {
+ TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
+ TREE_READONLY (olddecl) = TREE_READONLY (newdecl);
+ TREE_THIS_VOLATILE (olddecl) = TREE_THIS_VOLATILE (newdecl);
+ TREE_SIDE_EFFECTS (olddecl) = TREE_SIDE_EFFECTS (newdecl);
+ }
+
+ /* Merge the storage class information. */
+ /* For functions, static overrides non-static. */
+ if (TREE_CODE (newdecl) == FUNCTION_DECL)
+ {
+ TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl);
+ /* This is since we don't automatically
+ copy the attributes of NEWDECL into OLDDECL. */
+ TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
+ /* If this clears `static', clear it in the identifier too. */
+ if (! TREE_PUBLIC (olddecl))
+ TREE_PUBLIC (DECL_NAME (olddecl)) = 0;
+ }
+ if (DECL_EXTERNAL (newdecl))
+ {
+ TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
+ DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
+ /* An extern decl does not override previous storage class. */
+ TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
+ }
+ else
+ {
+ TREE_STATIC (olddecl) = TREE_STATIC (newdecl);
+ TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
+ }
+
+ /* If either decl says `inline', this fn is inline,
+ unless its definition was passed already. */
+ if (DECL_INLINE (newdecl) && DECL_INITIAL (olddecl) == 0)
+ DECL_INLINE (olddecl) = 1;
+ DECL_INLINE (newdecl) = DECL_INLINE (olddecl);
+
+ /* Get rid of any built-in function if new arg types don't match it
+ or if we have a function definition. */
+ if (TREE_CODE (newdecl) == FUNCTION_DECL
+ && DECL_BUILT_IN (olddecl)
+ && (!types_match || new_is_definition))
+ {
+ TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
+ DECL_BUILT_IN (olddecl) = 0;
+ }
+
+ /* If redeclaring a builtin function, and not a definition,
+ it stays built in.
+ Also preserve various other info from the definition. */
+ if (TREE_CODE (newdecl) == FUNCTION_DECL && !new_is_definition)
+ {
+ if (DECL_BUILT_IN (olddecl))
+ {
+ DECL_BUILT_IN (newdecl) = 1;
+ DECL_SET_FUNCTION_CODE (newdecl, DECL_FUNCTION_CODE (olddecl));
+ }
+ else
+ DECL_FRAME_SIZE (newdecl) = DECL_FRAME_SIZE (olddecl);
+
+ DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
+ DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
+ DECL_SAVED_INSNS (newdecl) = DECL_SAVED_INSNS (olddecl);
+ DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
+ }
+
+ /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
+ But preserve OLDdECL's DECL_UID. */
+ {
+ register unsigned olddecl_uid = DECL_UID (olddecl);
+
+ bcopy ((char *) newdecl + sizeof (struct tree_common),
+ (char *) olddecl + sizeof (struct tree_common),
+ sizeof (struct tree_decl) - sizeof (struct tree_common));
+ DECL_UID (olddecl) = olddecl_uid;
+ }
+
+ return 1;
+}
+
+/* Record a decl-node X as belonging to the current lexical scope.
+ Check for errors (such as an incompatible declaration for the same
+ name already seen in the same scope).
+
+ Returns either X or an old decl for the same name.
+ If an old decl is returned, it may have been smashed
+ to agree with what X says. */
+
+tree
+pushdecl (x)
+ tree x;
+{
+ register tree t;
+ register tree name = DECL_NAME (x);
+ register struct binding_level *b = current_binding_level;
+
+ DECL_CONTEXT (x) = current_function_decl;
+ /* A local extern declaration for a function doesn't constitute nesting.
+ A local auto declaration does, since it's a forward decl
+ for a nested function coming later. */
+ if (TREE_CODE (x) == FUNCTION_DECL && DECL_INITIAL (x) == 0
+ && DECL_EXTERNAL (x))
+ DECL_CONTEXT (x) = 0;
+
+ if (warn_nested_externs && DECL_EXTERNAL (x) && b != global_binding_level
+ && x != IDENTIFIER_IMPLICIT_DECL (name))
+ warning ("nested extern declaration of `%s'", IDENTIFIER_POINTER (name));
+
+ if (name)
+ {
+ char *file;
+ int line;
+
+ t = lookup_name_current_level (name);
+ if (t != 0 && t == error_mark_node)
+ /* error_mark_node is 0 for a while during initialization! */
+ {
+ t = 0;
+ error_with_decl (x, "`%s' used prior to declaration");
+ }
+
+ if (t != 0)
+ {
+ file = DECL_SOURCE_FILE (t);
+ line = DECL_SOURCE_LINE (t);
+ }
+
+ if (t != 0 && duplicate_decls (x, t))
+ {
+ if (TREE_CODE (t) == PARM_DECL)
+ {
+ /* Don't allow more than one "real" duplicate
+ of a forward parm decl. */
+ TREE_ASM_WRITTEN (t) = TREE_ASM_WRITTEN (x);
+ return t;
+ }
+ /* If this decl is `static' and an implicit decl was seen previously,
+ warn. But don't complain if -traditional,
+ since traditional compilers don't complain. */
+ if (!flag_traditional && TREE_PUBLIC (name)
+ && ! TREE_PUBLIC (x) && ! DECL_EXTERNAL (x)
+ /* We used to warn also for explicit extern followed by static,
+ but sometimes you need to do it that way. */
+ && IDENTIFIER_IMPLICIT_DECL (name) != 0)
+ {
+ pedwarn ("`%s' was declared implicitly `extern' and later `static'",
+ IDENTIFIER_POINTER (name));
+ pedwarn_with_file_and_line (file, line,
+ "previous declaration of `%s'",
+ IDENTIFIER_POINTER (name));
+ }
+
+ return t;
+ }
+
+ /* If we are processing a typedef statement, generate a whole new
+ ..._TYPE node (which will be just an variant of the existing
+ ..._TYPE node with identical properties) and then install the
+ TYPE_DECL node generated to represent the typedef name as the
+ TYPE_NAME of this brand new (duplicate) ..._TYPE node.
+
+ The whole point here is to end up with a situation where each
+ and every ..._TYPE node the compiler creates will be uniquely
+ associated with AT MOST one node representing a typedef name.
+ This way, even though the compiler substitutes corresponding
+ ..._TYPE nodes for TYPE_DECL (i.e. "typedef name") nodes very
+ early on, later parts of the compiler can always do the reverse
+ translation and get back the corresponding typedef name. For
+ example, given:
+
+ typedef struct S MY_TYPE;
+ MY_TYPE object;
+
+ Later parts of the compiler might only know that `object' was of
+ type `struct S' if if were not for code just below. With this
+ code however, later parts of the compiler see something like:
+
+ struct S' == struct S
+ typedef struct S' MY_TYPE;
+ struct S' object;
+
+ And they can then deduce (from the node for type struct S') that
+ the original object declaration was:
+
+ MY_TYPE object;
+
+ Being able to do this is important for proper support of protoize,
+ and also for generating precise symbolic debugging information
+ which takes full account of the programmer's (typedef) vocabulary.
+
+ Obviously, we don't want to generate a duplicate ..._TYPE node if
+ the TYPE_DECL node that we are now processing really represents a
+ standard built-in type.
+
+ Since all standard types are effectively declared at line zero
+ in the source file, we can easily check to see if we are working
+ on a standard type by checking the current value of lineno. */
+
+ if (TREE_CODE (x) == TYPE_DECL)
+ {
+ if (DECL_SOURCE_LINE (x) == 0)
+ {
+ if (TYPE_NAME (TREE_TYPE (x)) == 0)
+ TYPE_NAME (TREE_TYPE (x)) = x;
+ }
+ else if (TREE_TYPE (x) != error_mark_node)
+ {
+ tree tt = TREE_TYPE (x);
+
+ tt = build_type_copy (tt);
+ TYPE_NAME (tt) = x;
+ TREE_TYPE (x) = tt;
+ }
+ }
+
+ /* Multiple external decls of the same identifier ought to match.
+ Check against both global declarations and out of scope (limbo) block
+ level declarations.
+
+ We get warnings about inline functions where they are defined.
+ Avoid duplicate warnings where they are used. */
+ if (TREE_PUBLIC (x) && ! DECL_INLINE (x))
+ {
+ tree decl;
+
+ if (IDENTIFIER_GLOBAL_VALUE (name) != 0
+ && (DECL_EXTERNAL (IDENTIFIER_GLOBAL_VALUE (name))
+ || TREE_PUBLIC (IDENTIFIER_GLOBAL_VALUE (name))))
+ decl = IDENTIFIER_GLOBAL_VALUE (name);
+ else if (IDENTIFIER_LIMBO_VALUE (name) != 0)
+ /* Decls in limbo are always extern, so no need to check that. */
+ decl = IDENTIFIER_LIMBO_VALUE (name);
+ else
+ decl = 0;
+
+ if (decl && ! comptypes (TREE_TYPE (x), TREE_TYPE (decl))
+ /* If old decl is built-in, we already warned if we should. */
+ && !DECL_BUILT_IN (decl))
+ {
+ pedwarn_with_decl (x,
+ "type mismatch with previous external decl");
+ pedwarn_with_decl (decl, "previous external decl of `%s'");
+ }
+ }
+
+ /* If a function has had an implicit declaration, and then is defined,
+ make sure they are compatible. */
+
+ if (IDENTIFIER_IMPLICIT_DECL (name) != 0
+ && IDENTIFIER_GLOBAL_VALUE (name) == 0
+ && TREE_CODE (x) == FUNCTION_DECL
+ && ! comptypes (TREE_TYPE (x),
+ TREE_TYPE (IDENTIFIER_IMPLICIT_DECL (name))))
+ {
+ warning_with_decl (x, "type mismatch with previous implicit declaration");
+ warning_with_decl (IDENTIFIER_IMPLICIT_DECL (name),
+ "previous implicit declaration of `%s'");
+ }
+
+ /* In PCC-compatibility mode, extern decls of vars with no current decl
+ take effect at top level no matter where they are. */
+ if (flag_traditional && DECL_EXTERNAL (x)
+ && lookup_name (name) == 0)
+ {
+ tree type = TREE_TYPE (x);
+
+ /* But don't do this if the type contains temporary nodes. */
+ while (type)
+ {
+ if (type == error_mark_node)
+ break;
+ if (! TREE_PERMANENT (type))
+ {
+ warning_with_decl (x, "type of external `%s' is not global");
+ /* By exiting the loop early, we leave TYPE nonzero,
+ and thus prevent globalization of the decl. */
+ break;
+ }
+ else if (TREE_CODE (type) == FUNCTION_TYPE
+ && TYPE_ARG_TYPES (type) != 0)
+ /* The types might not be truly local,
+ but the list of arg types certainly is temporary.
+ Since prototypes are nontraditional,
+ ok not to do the traditional thing. */
+ break;
+ type = TREE_TYPE (type);
+ }
+
+ if (type == 0)
+ b = global_binding_level;
+ }
+
+ /* This name is new in its binding level.
+ Install the new declaration and return it. */
+ if (b == global_binding_level)
+ {
+ /* Install a global value. */
+
+ /* If the first global decl has external linkage,
+ warn if we later see static one. */
+ if (IDENTIFIER_GLOBAL_VALUE (name) == 0 && TREE_PUBLIC (x))
+ TREE_PUBLIC (name) = 1;
+
+ IDENTIFIER_GLOBAL_VALUE (name) = x;
+
+ /* We no longer care about any previous block level declarations. */
+ IDENTIFIER_LIMBO_VALUE (name) = 0;
+
+ /* Don't forget if the function was used via an implicit decl. */
+ if (IDENTIFIER_IMPLICIT_DECL (name)
+ && TREE_USED (IDENTIFIER_IMPLICIT_DECL (name)))
+ TREE_USED (x) = 1, TREE_USED (name) = 1;
+
+ /* Don't forget if its address was taken in that way. */
+ if (IDENTIFIER_IMPLICIT_DECL (name)
+ && TREE_ADDRESSABLE (IDENTIFIER_IMPLICIT_DECL (name)))
+ TREE_ADDRESSABLE (x) = 1;
+
+ /* Warn about mismatches against previous implicit decl. */
+ if (IDENTIFIER_IMPLICIT_DECL (name) != 0
+ /* If this real decl matches the implicit, don't complain. */
+ && ! (TREE_CODE (x) == FUNCTION_DECL
+ && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (x)))
+ == integer_type_node)))
+ pedwarn ("`%s' was previously implicitly declared to return `int'",
+ IDENTIFIER_POINTER (name));
+
+ /* If this decl is `static' and an `extern' was seen previously,
+ that is erroneous. */
+ if (TREE_PUBLIC (name)
+ && ! TREE_PUBLIC (x) && ! DECL_EXTERNAL (x))
+ {
+ /* Okay to redeclare an ANSI built-in as static. */
+ if (t != 0 && DECL_BUILT_IN (t))
+ ;
+ /* Okay to declare a non-ANSI built-in as anything. */
+ else if (t != 0 && DECL_BUILT_IN_NONANSI (t))
+ ;
+ else if (IDENTIFIER_IMPLICIT_DECL (name))
+ pedwarn ("`%s' was declared implicitly `extern' and later `static'",
+ IDENTIFIER_POINTER (name));
+ else
+ pedwarn ("`%s' was declared `extern' and later `static'",
+ IDENTIFIER_POINTER (name));
+ }
+ }
+ else
+ {
+ /* Here to install a non-global value. */
+ tree oldlocal = IDENTIFIER_LOCAL_VALUE (name);
+ tree oldglobal = IDENTIFIER_GLOBAL_VALUE (name);
+ IDENTIFIER_LOCAL_VALUE (name) = x;
+
+ /* If this is an extern function declaration, see if we
+ have a global definition or declaration for the function. */
+ if (oldlocal == 0
+ && DECL_EXTERNAL (x) && !DECL_INLINE (x)
+ && oldglobal != 0
+ && TREE_CODE (x) == FUNCTION_DECL
+ && TREE_CODE (oldglobal) == FUNCTION_DECL)
+ {
+ /* We have one. Their types must agree. */
+ if (! comptypes (TREE_TYPE (x),
+ TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (name))))
+ pedwarn_with_decl (x, "extern declaration of `%s' doesn't match global one");
+ else
+ {
+ /* Inner extern decl is inline if global one is.
+ Copy enough to really inline it. */
+ if (DECL_INLINE (oldglobal))
+ {
+ DECL_INLINE (x) = DECL_INLINE (oldglobal);
+ DECL_INITIAL (x) = (current_function_decl == oldglobal
+ ? 0 : DECL_INITIAL (oldglobal));
+ DECL_SAVED_INSNS (x) = DECL_SAVED_INSNS (oldglobal);
+ DECL_FRAME_SIZE (x) = DECL_FRAME_SIZE (oldglobal);
+ DECL_ARGUMENTS (x) = DECL_ARGUMENTS (oldglobal);
+ DECL_RESULT (x) = DECL_RESULT (oldglobal);
+ TREE_ASM_WRITTEN (x) = TREE_ASM_WRITTEN (oldglobal);
+ DECL_ABSTRACT_ORIGIN (x) = oldglobal;
+ }
+ /* Inner extern decl is built-in if global one is. */
+ if (DECL_BUILT_IN (oldglobal))
+ {
+ DECL_BUILT_IN (x) = DECL_BUILT_IN (oldglobal);
+ DECL_SET_FUNCTION_CODE (x, DECL_FUNCTION_CODE (oldglobal));
+ }
+ /* Keep the arg types from a file-scope fcn defn. */
+ if (TYPE_ARG_TYPES (TREE_TYPE (oldglobal)) != 0
+ && DECL_INITIAL (oldglobal)
+ && TYPE_ARG_TYPES (TREE_TYPE (x)) == 0)
+ TREE_TYPE (x) = TREE_TYPE (oldglobal);
+ }
+ }
+
+#if 0 /* This case is probably sometimes the right thing to do. */
+ /* If we have a local external declaration,
+ then any file-scope declaration should not
+ have been static. */
+ if (oldlocal == 0 && oldglobal != 0
+ && !TREE_PUBLIC (oldglobal)
+ && DECL_EXTERNAL (x) && TREE_PUBLIC (x))
+ warning ("`%s' locally external but globally static",
+ IDENTIFIER_POINTER (name));
+#endif
+
+ /* If we have a local external declaration,
+ and no file-scope declaration has yet been seen,
+ then if we later have a file-scope decl it must not be static. */
+ if (oldlocal == 0
+ && oldglobal == 0
+ && DECL_EXTERNAL (x)
+ && TREE_PUBLIC (x))
+ {
+ TREE_PUBLIC (name) = 1;
+
+ /* Save this decl, so that we can do type checking against
+ other decls after it falls out of scope.
+
+ Only save it once. This prevents temporary decls created in
+ expand_inline_function from being used here, since this
+ will have been set when the inline function was parsed.
+ It also helps give slightly better warnings. */
+ if (IDENTIFIER_LIMBO_VALUE (name) == 0)
+ IDENTIFIER_LIMBO_VALUE (name) = x;
+ }
+
+ /* Warn if shadowing an argument at the top level of the body. */
+ if (oldlocal != 0 && !DECL_EXTERNAL (x)
+ /* This warning doesn't apply to the parms of a nested fcn. */
+ && ! current_binding_level->parm_flag
+ /* Check that this is one level down from the parms. */
+ && current_binding_level->level_chain->parm_flag
+ /* Check that the decl being shadowed
+ comes from the parm level, one level up. */
+ && chain_member (oldlocal, current_binding_level->level_chain->names))
+ {
+ if (TREE_CODE (oldlocal) == PARM_DECL)
+ pedwarn ("declaration of `%s' shadows a parameter",
+ IDENTIFIER_POINTER (name));
+ else
+ pedwarn ("declaration of `%s' shadows a symbol from the parameter list",
+ IDENTIFIER_POINTER (name));
+ }
+
+ /* Maybe warn if shadowing something else. */
+ else if (warn_shadow && !DECL_EXTERNAL (x)
+ /* No shadow warnings for internally generated vars. */
+ && DECL_SOURCE_LINE (x) != 0
+ /* No shadow warnings for vars made for inlining. */
+ && ! DECL_FROM_INLINE (x))
+ {
+ char *warnstring = 0;
+
+ if (TREE_CODE (x) == PARM_DECL
+ && current_binding_level->level_chain->parm_flag)
+ /* Don't warn about the parm names in function declarator
+ within a function declarator.
+ It would be nice to avoid warning in any function
+ declarator in a declaration, as opposed to a definition,
+ but there is no way to tell it's not a definition. */
+ ;
+ else if (oldlocal != 0 && TREE_CODE (oldlocal) == PARM_DECL)
+ warnstring = "declaration of `%s' shadows a parameter";
+ else if (oldlocal != 0)
+ warnstring = "declaration of `%s' shadows previous local";
+ else if (IDENTIFIER_GLOBAL_VALUE (name) != 0
+ && IDENTIFIER_GLOBAL_VALUE (name) != error_mark_node)
+ warnstring = "declaration of `%s' shadows global declaration";
+
+ if (warnstring)
+ warning (warnstring, IDENTIFIER_POINTER (name));
+ }
+
+ /* If storing a local value, there may already be one (inherited).
+ If so, record it for restoration when this binding level ends. */
+ if (oldlocal != 0)
+ b->shadowed = tree_cons (name, oldlocal, b->shadowed);
+ }
+
+ /* Keep count of variables in this level with incomplete type. */
+ if (TYPE_SIZE (TREE_TYPE (x)) == 0)
+ ++b->n_incomplete;
+ }
+
+ /* Put decls on list in reverse order.
+ We will reverse them later if necessary. */
+ TREE_CHAIN (x) = b->names;
+ b->names = x;
+
+ return x;
+}
+
+/* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL, if appropriate. */
+
+tree
+pushdecl_top_level (x)
+ tree x;
+{
+ register tree t;
+ register struct binding_level *b = current_binding_level;
+
+ current_binding_level = global_binding_level;
+ t = pushdecl (x);
+ current_binding_level = b;
+ return t;
+}
+
+/* Generate an implicit declaration for identifier FUNCTIONID
+ as a function of type int (). Print a warning if appropriate. */
+
+tree
+implicitly_declare (functionid)
+ tree functionid;
+{
+ register tree decl;
+ int traditional_warning = 0;
+ /* Only one "implicit declaration" warning per identifier. */
+ int implicit_warning;
+
+ /* Save the decl permanently so we can warn if definition follows. */
+ push_obstacks_nochange ();
+ end_temporary_allocation ();
+
+ /* We used to reuse an old implicit decl here,
+ but this loses with inline functions because it can clobber
+ the saved decl chains. */
+/* if (IDENTIFIER_IMPLICIT_DECL (functionid) != 0)
+ decl = IDENTIFIER_IMPLICIT_DECL (functionid);
+ else */
+ decl = build_decl (FUNCTION_DECL, functionid, default_function_type);
+
+ /* Warn of implicit decl following explicit local extern decl.
+ This is probably a program designed for traditional C. */
+ if (TREE_PUBLIC (functionid) && IDENTIFIER_GLOBAL_VALUE (functionid) == 0)
+ traditional_warning = 1;
+
+ /* Warn once of an implicit declaration. */
+ implicit_warning = (IDENTIFIER_IMPLICIT_DECL (functionid) == 0);
+
+ DECL_EXTERNAL (decl) = 1;
+ TREE_PUBLIC (decl) = 1;
+
+ /* Record that we have an implicit decl and this is it. */
+ IDENTIFIER_IMPLICIT_DECL (functionid) = decl;
+
+ /* ANSI standard says implicit declarations are in the innermost block.
+ So we record the decl in the standard fashion.
+ If flag_traditional is set, pushdecl does it top-level. */
+ pushdecl (decl);
+
+ /* This is a no-op in c-lang.c or something real in objc-actions.c. */
+ maybe_objc_check_decl (decl);
+
+ rest_of_decl_compilation (decl, NULL_PTR, 0, 0);
+
+ if (warn_implicit && implicit_warning)
+ warning ("implicit declaration of function `%s'",
+ IDENTIFIER_POINTER (functionid));
+ else if (warn_traditional && traditional_warning)
+ warning ("function `%s' was previously declared within a block",
+ IDENTIFIER_POINTER (functionid));
+
+ /* Write a record describing this implicit function declaration to the
+ prototypes file (if requested). */
+
+ gen_aux_info_record (decl, 0, 1, 0);
+
+ pop_obstacks ();
+
+ return decl;
+}
+
+/* Return zero if the declaration NEWDECL is valid
+ when the declaration OLDDECL (assumed to be for the same name)
+ has already been seen.
+ Otherwise return an error message format string with a %s
+ where the identifier should go. */
+
+static char *
+redeclaration_error_message (newdecl, olddecl)
+ tree newdecl, olddecl;
+{
+ if (TREE_CODE (newdecl) == TYPE_DECL)
+ {
+ if (flag_traditional && TREE_TYPE (newdecl) == TREE_TYPE (olddecl))
+ return 0;
+ return "redefinition of `%s'";
+ }
+ else if (TREE_CODE (newdecl) == FUNCTION_DECL)
+ {
+ /* Declarations of functions can insist on internal linkage
+ but they can't be inconsistent with internal linkage,
+ so there can be no error on that account.
+ However defining the same name twice is no good. */
+ if (DECL_INITIAL (olddecl) != 0 && DECL_INITIAL (newdecl) != 0
+ /* However, defining once as extern inline and a second
+ time in another way is ok. */
+ && !(DECL_INLINE (olddecl) && DECL_EXTERNAL (olddecl)
+ && !(DECL_INLINE (newdecl) && DECL_EXTERNAL (newdecl))))
+ return "redefinition of `%s'";
+ return 0;
+ }
+ else if (current_binding_level == global_binding_level)
+ {
+ /* Objects declared at top level: */
+ /* If at least one is a reference, it's ok. */
+ if (DECL_EXTERNAL (newdecl) || DECL_EXTERNAL (olddecl))
+ return 0;
+ /* Reject two definitions. */
+ if (DECL_INITIAL (olddecl) != 0 && DECL_INITIAL (newdecl) != 0)
+ return "redefinition of `%s'";
+ /* Now we have two tentative defs, or one tentative and one real def. */
+ /* Insist that the linkage match. */
+ if (TREE_PUBLIC (olddecl) != TREE_PUBLIC (newdecl))
+ return "conflicting declarations of `%s'";
+ return 0;
+ }
+ else if (current_binding_level->parm_flag
+ && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))
+ return 0;
+ else
+ {
+ /* Objects declared with block scope: */
+ /* Reject two definitions, and reject a definition
+ together with an external reference. */
+ if (!(DECL_EXTERNAL (newdecl) && DECL_EXTERNAL (olddecl)))
+ return "redeclaration of `%s'";
+ return 0;
+ }
+}
+
+/* Get the LABEL_DECL corresponding to identifier ID as a label.
+ Create one if none exists so far for the current function.
+ This function is called for both label definitions and label references. */
+
+tree
+lookup_label (id)
+ tree id;
+{
+ register tree decl = IDENTIFIER_LABEL_VALUE (id);
+
+ if (current_function_decl == 0)
+ {
+ error ("label %s referenced outside of any function",
+ IDENTIFIER_POINTER (id));
+ return 0;
+ }
+
+ /* Use a label already defined or ref'd with this name. */
+ if (decl != 0)
+ {
+ /* But not if it is inherited and wasn't declared to be inheritable. */
+ if (DECL_CONTEXT (decl) != current_function_decl
+ && ! C_DECLARED_LABEL_FLAG (decl))
+ return shadow_label (id);
+ return decl;
+ }
+
+ decl = build_decl (LABEL_DECL, id, void_type_node);
+
+ /* Make sure every label has an rtx. */
+ label_rtx (decl);
+
+ /* A label not explicitly declared must be local to where it's ref'd. */
+ DECL_CONTEXT (decl) = current_function_decl;
+
+ DECL_MODE (decl) = VOIDmode;
+
+ /* Say where one reference is to the label,
+ for the sake of the error if it is not defined. */
+ DECL_SOURCE_LINE (decl) = lineno;
+ DECL_SOURCE_FILE (decl) = input_filename;
+
+ IDENTIFIER_LABEL_VALUE (id) = decl;
+
+ named_labels = tree_cons (NULL_TREE, decl, named_labels);
+
+ return decl;
+}
+
+/* Make a label named NAME in the current function,
+ shadowing silently any that may be inherited from containing functions
+ or containing scopes.
+
+ Note that valid use, if the label being shadowed
+ comes from another scope in the same function,
+ requires calling declare_nonlocal_label right away. */
+
+tree
+shadow_label (name)
+ tree name;
+{
+ register tree decl = IDENTIFIER_LABEL_VALUE (name);
+
+ if (decl != 0)
+ {
+ shadowed_labels = tree_cons (NULL_TREE, decl, shadowed_labels);
+ IDENTIFIER_LABEL_VALUE (name) = decl = 0;
+ }
+
+ return lookup_label (name);
+}
+
+/* Define a label, specifying the location in the source file.
+ Return the LABEL_DECL node for the label, if the definition is valid.
+ Otherwise return 0. */
+
+tree
+define_label (filename, line, name)
+ char *filename;
+ int line;
+ tree name;
+{
+ tree decl = lookup_label (name);
+
+ /* If label with this name is known from an outer context, shadow it. */
+ if (decl != 0 && DECL_CONTEXT (decl) != current_function_decl)
+ {
+ shadowed_labels = tree_cons (NULL_TREE, decl, shadowed_labels);
+ IDENTIFIER_LABEL_VALUE (name) = 0;
+ decl = lookup_label (name);
+ }
+
+ if (DECL_INITIAL (decl) != 0)
+ {
+ error ("duplicate label `%s'", IDENTIFIER_POINTER (name));
+ return 0;
+ }
+ else
+ {
+ /* Mark label as having been defined. */
+ DECL_INITIAL (decl) = error_mark_node;
+ /* Say where in the source. */
+ DECL_SOURCE_FILE (decl) = filename;
+ DECL_SOURCE_LINE (decl) = line;
+ return decl;
+ }
+}
+
+/* Return the list of declarations of the current level.
+ Note that this list is in reverse order unless/until
+ you nreverse it; and when you do nreverse it, you must
+ store the result back using `storedecls' or you will lose. */
+
+tree
+getdecls ()
+{
+ return current_binding_level->names;
+}
+
+/* Return the list of type-tags (for structs, etc) of the current level. */
+
+tree
+gettags ()
+{
+ return current_binding_level->tags;
+}
+
+/* Store the list of declarations of the current level.
+ This is done for the parameter declarations of a function being defined,
+ after they are modified in the light of any missing parameters. */
+
+static void
+storedecls (decls)
+ tree decls;
+{
+ current_binding_level->names = decls;
+}
+
+/* Similarly, store the list of tags of the current level. */
+
+static void
+storetags (tags)
+ tree tags;
+{
+ current_binding_level->tags = tags;
+}
+
+/* Given NAME, an IDENTIFIER_NODE,
+ return the structure (or union or enum) definition for that name.
+ Searches binding levels from BINDING_LEVEL up to the global level.
+ If THISLEVEL_ONLY is nonzero, searches only the specified context
+ (but skips any tag-transparent contexts to find one that is
+ meaningful for tags).
+ CODE says which kind of type the caller wants;
+ it is RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE.
+ If the wrong kind of type is found, an error is reported. */
+
+static tree
+lookup_tag (code, name, binding_level, thislevel_only)
+ enum tree_code code;
+ struct binding_level *binding_level;
+ tree name;
+ int thislevel_only;
+{
+ register struct binding_level *level;
+
+ for (level = binding_level; level; level = level->level_chain)
+ {
+ register tree tail;
+ for (tail = level->tags; tail; tail = TREE_CHAIN (tail))
+ {
+ if (TREE_PURPOSE (tail) == name)
+ {
+ if (TREE_CODE (TREE_VALUE (tail)) != code)
+ {
+ /* Definition isn't the kind we were looking for. */
+ pending_invalid_xref = name;
+ pending_invalid_xref_file = input_filename;
+ pending_invalid_xref_line = lineno;
+ }
+ return TREE_VALUE (tail);
+ }
+ }
+ if (thislevel_only && ! level->tag_transparent)
+ return NULL_TREE;
+ }
+ return NULL_TREE;
+}
+
+/* Print an error message now
+ for a recent invalid struct, union or enum cross reference.
+ We don't print them immediately because they are not invalid
+ when used in the `struct foo;' construct for shadowing. */
+
+void
+pending_xref_error ()
+{
+ if (pending_invalid_xref != 0)
+ error_with_file_and_line (pending_invalid_xref_file,
+ pending_invalid_xref_line,
+ "`%s' defined as wrong kind of tag",
+ IDENTIFIER_POINTER (pending_invalid_xref));
+ pending_invalid_xref = 0;
+}
+
+/* Given a type, find the tag that was defined for it and return the tag name.
+ Otherwise return 0. */
+
+static tree
+lookup_tag_reverse (type)
+ tree type;
+{
+ register struct binding_level *level;
+
+ for (level = current_binding_level; level; level = level->level_chain)
+ {
+ register tree tail;
+ for (tail = level->tags; tail; tail = TREE_CHAIN (tail))
+ {
+ if (TREE_VALUE (tail) == type)
+ return TREE_PURPOSE (tail);
+ }
+ }
+ return NULL_TREE;
+}
+
+/* Look up NAME in the current binding level and its superiors
+ in the namespace of variables, functions and typedefs.
+ Return a ..._DECL node of some kind representing its definition,
+ or return 0 if it is undefined. */
+
+tree
+lookup_name (name)
+ tree name;
+{
+ register tree val;
+ if (current_binding_level != global_binding_level
+ && IDENTIFIER_LOCAL_VALUE (name))
+ val = IDENTIFIER_LOCAL_VALUE (name);
+ else
+ val = IDENTIFIER_GLOBAL_VALUE (name);
+ return val;
+}
+
+/* Similar to `lookup_name' but look only at current binding level. */
+
+tree
+lookup_name_current_level (name)
+ tree name;
+{
+ register tree t;
+
+ if (current_binding_level == global_binding_level)
+ return IDENTIFIER_GLOBAL_VALUE (name);
+
+ if (IDENTIFIER_LOCAL_VALUE (name) == 0)
+ return 0;
+
+ for (t = current_binding_level->names; t; t = TREE_CHAIN (t))
+ if (DECL_NAME (t) == name)
+ break;
+
+ return t;
+}
+
+/* Create the predefined scalar types of C,
+ and some nodes representing standard constants (0, 1, (void *)0).
+ Initialize the global binding level.
+ Make definitions for built-in primitive functions. */
+
+void
+init_decl_processing ()
+{
+ register tree endlink;
+ /* Either char* or void*. */
+ tree traditional_ptr_type_node;
+ /* Data types of memcpy and strlen. */
+ tree memcpy_ftype, strlen_ftype;
+ tree void_ftype_any;
+ int wchar_type_size;
+ tree temp;
+ tree array_domain_type;
+
+ current_function_decl = NULL;
+ named_labels = NULL;
+ current_binding_level = NULL_BINDING_LEVEL;
+ free_binding_level = NULL_BINDING_LEVEL;
+ pushlevel (0); /* make the binding_level structure for global names */
+ global_binding_level = current_binding_level;
+
+ /* Define `int' and `char' first so that dbx will output them first. */
+
+ integer_type_node = make_signed_type (INT_TYPE_SIZE);
+ pushdecl (build_decl (TYPE_DECL, ridpointers[(int) RID_INT],
+ integer_type_node));
+
+ /* Define `char', which is like either `signed char' or `unsigned char'
+ but not the same as either. */
+
+ char_type_node
+ = (flag_signed_char
+ ? make_signed_type (CHAR_TYPE_SIZE)
+ : make_unsigned_type (CHAR_TYPE_SIZE));
+ pushdecl (build_decl (TYPE_DECL, get_identifier ("char"),
+ char_type_node));
+
+ long_integer_type_node = make_signed_type (LONG_TYPE_SIZE);
+ pushdecl (build_decl (TYPE_DECL, get_identifier ("long int"),
+ long_integer_type_node));
+
+ unsigned_type_node = make_unsigned_type (INT_TYPE_SIZE);
+ pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned int"),
+ unsigned_type_node));
+
+ long_unsigned_type_node = make_unsigned_type (LONG_TYPE_SIZE);
+ pushdecl (build_decl (TYPE_DECL, get_identifier ("long unsigned int"),
+ long_unsigned_type_node));
+
+ /* `unsigned long' is the standard type for sizeof.
+ Traditionally, use a signed type.
+ Note that stddef.h uses `unsigned long',
+ and this must agree, even of long and int are the same size. */
+ if (flag_traditional)
+ sizetype = long_integer_type_node;
+ else
+ sizetype
+ = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (SIZE_TYPE)));
+
+ ptrdiff_type_node
+ = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (PTRDIFF_TYPE)));
+
+ TREE_TYPE (TYPE_SIZE (integer_type_node)) = sizetype;
+ TREE_TYPE (TYPE_SIZE (char_type_node)) = sizetype;
+ TREE_TYPE (TYPE_SIZE (unsigned_type_node)) = sizetype;
+ TREE_TYPE (TYPE_SIZE (long_unsigned_type_node)) = sizetype;
+ TREE_TYPE (TYPE_SIZE (long_integer_type_node)) = sizetype;
+
+ error_mark_node = make_node (ERROR_MARK);
+ TREE_TYPE (error_mark_node) = error_mark_node;
+
+ short_integer_type_node = make_signed_type (SHORT_TYPE_SIZE);
+ pushdecl (build_decl (TYPE_DECL, get_identifier ("short int"),
+ short_integer_type_node));
+
+ long_long_integer_type_node = make_signed_type (LONG_LONG_TYPE_SIZE);
+ pushdecl (build_decl (TYPE_DECL, get_identifier ("long long int"),
+ long_long_integer_type_node));
+
+ short_unsigned_type_node = make_unsigned_type (SHORT_TYPE_SIZE);
+ pushdecl (build_decl (TYPE_DECL, get_identifier ("short unsigned int"),
+ short_unsigned_type_node));
+
+ long_long_unsigned_type_node = make_unsigned_type (LONG_LONG_TYPE_SIZE);
+ pushdecl (build_decl (TYPE_DECL, get_identifier ("long long unsigned int"),
+ long_long_unsigned_type_node));
+
+ /* Define both `signed char' and `unsigned char'. */
+ signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE);
+ pushdecl (build_decl (TYPE_DECL, get_identifier ("signed char"),
+ signed_char_type_node));
+
+ unsigned_char_type_node = make_unsigned_type (CHAR_TYPE_SIZE);
+ pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned char"),
+ unsigned_char_type_node));
+
+ intQI_type_node = make_signed_type (GET_MODE_BITSIZE (QImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, intQI_type_node));
+
+ intHI_type_node = make_signed_type (GET_MODE_BITSIZE (HImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, intHI_type_node));
+
+ intSI_type_node = make_signed_type (GET_MODE_BITSIZE (SImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, intSI_type_node));
+
+ intDI_type_node = make_signed_type (GET_MODE_BITSIZE (DImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, intDI_type_node));
+
+ unsigned_intQI_type_node = make_unsigned_type (GET_MODE_BITSIZE (QImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, unsigned_intQI_type_node));
+
+ unsigned_intHI_type_node = make_unsigned_type (GET_MODE_BITSIZE (HImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, unsigned_intHI_type_node));
+
+ unsigned_intSI_type_node = make_unsigned_type (GET_MODE_BITSIZE (SImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, unsigned_intSI_type_node));
+
+ unsigned_intDI_type_node = make_unsigned_type (GET_MODE_BITSIZE (DImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, unsigned_intDI_type_node));
+
+ float_type_node = make_node (REAL_TYPE);
+ TYPE_PRECISION (float_type_node) = FLOAT_TYPE_SIZE;
+ pushdecl (build_decl (TYPE_DECL, ridpointers[(int) RID_FLOAT],
+ float_type_node));
+ layout_type (float_type_node);
+
+ double_type_node = make_node (REAL_TYPE);
+ if (flag_short_double)
+ TYPE_PRECISION (double_type_node) = FLOAT_TYPE_SIZE;
+ else
+ TYPE_PRECISION (double_type_node) = DOUBLE_TYPE_SIZE;
+ pushdecl (build_decl (TYPE_DECL, ridpointers[(int) RID_DOUBLE],
+ double_type_node));
+ layout_type (double_type_node);
+
+ long_double_type_node = make_node (REAL_TYPE);
+ TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
+ pushdecl (build_decl (TYPE_DECL, get_identifier ("long double"),
+ long_double_type_node));
+ layout_type (long_double_type_node);
+
+ complex_integer_type_node = make_node (COMPLEX_TYPE);
+ pushdecl (build_decl (TYPE_DECL, get_identifier ("complex int"),
+ complex_integer_type_node));
+ TREE_TYPE (complex_integer_type_node) = integer_type_node;
+ layout_type (complex_integer_type_node);
+
+ complex_float_type_node = make_node (COMPLEX_TYPE);
+ pushdecl (build_decl (TYPE_DECL, get_identifier ("complex float"),
+ complex_float_type_node));
+ TREE_TYPE (complex_float_type_node) = float_type_node;
+ layout_type (complex_float_type_node);
+
+ complex_double_type_node = make_node (COMPLEX_TYPE);
+ pushdecl (build_decl (TYPE_DECL, get_identifier ("complex double"),
+ complex_double_type_node));
+ TREE_TYPE (complex_double_type_node) = double_type_node;
+ layout_type (complex_double_type_node);
+
+ complex_long_double_type_node = make_node (COMPLEX_TYPE);
+ pushdecl (build_decl (TYPE_DECL, get_identifier ("complex long double"),
+ complex_long_double_type_node));
+ TREE_TYPE (complex_long_double_type_node) = long_double_type_node;
+ layout_type (complex_long_double_type_node);
+
+ wchar_type_node
+ = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (WCHAR_TYPE)));
+ wchar_type_size = TYPE_PRECISION (wchar_type_node);
+ signed_wchar_type_node = type_for_size (wchar_type_size, 0);
+ unsigned_wchar_type_node = type_for_size (wchar_type_size, 1);
+
+ integer_zero_node = build_int_2 (0, 0);
+ TREE_TYPE (integer_zero_node) = integer_type_node;
+ integer_one_node = build_int_2 (1, 0);
+ TREE_TYPE (integer_one_node) = integer_type_node;
+
+ size_zero_node = build_int_2 (0, 0);
+ TREE_TYPE (size_zero_node) = sizetype;
+ size_one_node = build_int_2 (1, 0);
+ TREE_TYPE (size_one_node) = sizetype;
+
+ void_type_node = make_node (VOID_TYPE);
+ pushdecl (build_decl (TYPE_DECL,
+ ridpointers[(int) RID_VOID], void_type_node));
+ layout_type (void_type_node); /* Uses integer_zero_node */
+ /* We are not going to have real types in C with less than byte alignment,
+ so we might as well not have any types that claim to have it. */
+ TYPE_ALIGN (void_type_node) = BITS_PER_UNIT;
+
+ null_pointer_node = build_int_2 (0, 0);
+ TREE_TYPE (null_pointer_node) = build_pointer_type (void_type_node);
+ layout_type (TREE_TYPE (null_pointer_node));
+
+ string_type_node = build_pointer_type (char_type_node);
+ const_string_type_node
+ = build_pointer_type (build_type_variant (char_type_node, 1, 0));
+
+ /* Make a type to be the domain of a few array types
+ whose domains don't really matter.
+ 200 is small enough that it always fits in size_t
+ and large enough that it can hold most function names for the
+ initializations of __FUNCTION__ and __PRETTY_FUNCTION__. */
+ array_domain_type = build_index_type (build_int_2 (200, 0));
+
+ /* make a type for arrays of characters.
+ With luck nothing will ever really depend on the length of this
+ array type. */
+ char_array_type_node
+ = build_array_type (char_type_node, array_domain_type);
+ /* Likewise for arrays of ints. */
+ int_array_type_node
+ = build_array_type (integer_type_node, array_domain_type);
+ /* This is for wide string constants. */
+ wchar_array_type_node
+ = build_array_type (wchar_type_node, array_domain_type);
+
+ default_function_type
+ = build_function_type (integer_type_node, NULL_TREE);
+
+ ptr_type_node = build_pointer_type (void_type_node);
+ const_ptr_type_node
+ = build_pointer_type (build_type_variant (void_type_node, 1, 0));
+
+ endlink = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
+
+ void_ftype_any
+ = build_function_type (void_type_node, NULL_TREE);
+
+ double_ftype_double
+ = build_function_type (double_type_node,
+ tree_cons (NULL_TREE, double_type_node, endlink));
+
+ double_ftype_double_double
+ = build_function_type (double_type_node,
+ tree_cons (NULL_TREE, double_type_node,
+ tree_cons (NULL_TREE,
+ double_type_node, endlink)));
+
+ int_ftype_int
+ = build_function_type (integer_type_node,
+ tree_cons (NULL_TREE, integer_type_node, endlink));
+
+ long_ftype_long
+ = build_function_type (long_integer_type_node,
+ tree_cons (NULL_TREE,
+ long_integer_type_node, endlink));
+
+ void_ftype_ptr_ptr_int
+ = build_function_type (void_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE,
+ integer_type_node,
+ endlink))));
+
+ int_ftype_cptr_cptr_sizet
+ = build_function_type (integer_type_node,
+ tree_cons (NULL_TREE, const_ptr_type_node,
+ tree_cons (NULL_TREE, const_ptr_type_node,
+ tree_cons (NULL_TREE,
+ sizetype,
+ endlink))));
+
+ void_ftype_ptr_int_int
+ = build_function_type (void_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE, integer_type_node,
+ tree_cons (NULL_TREE,
+ integer_type_node,
+ endlink))));
+
+ string_ftype_ptr_ptr /* strcpy prototype */
+ = build_function_type (string_type_node,
+ tree_cons (NULL_TREE, string_type_node,
+ tree_cons (NULL_TREE,
+ const_string_type_node,
+ endlink)));
+
+ int_ftype_string_string /* strcmp prototype */
+ = build_function_type (integer_type_node,
+ tree_cons (NULL_TREE, const_string_type_node,
+ tree_cons (NULL_TREE,
+ const_string_type_node,
+ endlink)));
+
+ strlen_ftype /* strlen prototype */
+ = build_function_type (flag_traditional ? integer_type_node : sizetype,
+ tree_cons (NULL_TREE, const_string_type_node,
+ endlink));
+
+ traditional_ptr_type_node
+ = (flag_traditional ? string_type_node : ptr_type_node);
+
+ memcpy_ftype /* memcpy prototype */
+ = build_function_type (traditional_ptr_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE, const_ptr_type_node,
+ tree_cons (NULL_TREE,
+ sizetype,
+ endlink))));
+
+ builtin_function ("__builtin_constant_p", int_ftype_int,
+ BUILT_IN_CONSTANT_P, NULL_PTR);
+
+ builtin_function ("__builtin_return_address",
+ build_function_type (ptr_type_node,
+ tree_cons (NULL_TREE,
+ unsigned_type_node,
+ endlink)),
+ BUILT_IN_RETURN_ADDRESS, NULL_PTR);
+
+ builtin_function ("__builtin_frame_address",
+ build_function_type (ptr_type_node,
+ tree_cons (NULL_TREE,
+ unsigned_type_node,
+ endlink)),
+ BUILT_IN_FRAME_ADDRESS, NULL_PTR);
+
+ builtin_function ("__builtin_alloca",
+ build_function_type (ptr_type_node,
+ tree_cons (NULL_TREE,
+ sizetype,
+ endlink)),
+ BUILT_IN_ALLOCA, "alloca");
+ builtin_function ("__builtin_ffs", int_ftype_int, BUILT_IN_FFS, NULL_PTR);
+ /* Define alloca, ffs as builtins.
+ Declare _exit just to mark it as volatile. */
+ if (! flag_no_builtin && !flag_no_nonansi_builtin)
+ {
+ temp = builtin_function ("alloca",
+ build_function_type (ptr_type_node,
+ tree_cons (NULL_TREE,
+ sizetype,
+ endlink)),
+ BUILT_IN_ALLOCA, NULL_PTR);
+ /* Suppress error if redefined as a non-function. */
+ DECL_BUILT_IN_NONANSI (temp) = 1;
+ temp = builtin_function ("ffs", int_ftype_int, BUILT_IN_FFS, NULL_PTR);
+ /* Suppress error if redefined as a non-function. */
+ DECL_BUILT_IN_NONANSI (temp) = 1;
+ temp = builtin_function ("_exit", void_ftype_any, NOT_BUILT_IN,
+ NULL_PTR);
+ TREE_THIS_VOLATILE (temp) = 1;
+ TREE_SIDE_EFFECTS (temp) = 1;
+ /* Suppress error if redefined as a non-function. */
+ DECL_BUILT_IN_NONANSI (temp) = 1;
+ }
+
+ builtin_function ("__builtin_abs", int_ftype_int, BUILT_IN_ABS, NULL_PTR);
+ builtin_function ("__builtin_fabs", double_ftype_double, BUILT_IN_FABS,
+ NULL_PTR);
+ builtin_function ("__builtin_labs", long_ftype_long, BUILT_IN_LABS,
+ NULL_PTR);
+ builtin_function ("__builtin_saveregs",
+ build_function_type (ptr_type_node, NULL_TREE),
+ BUILT_IN_SAVEREGS, NULL_PTR);
+/* EXPAND_BUILTIN_VARARGS is obsolete. */
+#if 0
+ builtin_function ("__builtin_varargs",
+ build_function_type (ptr_type_node,
+ tree_cons (NULL_TREE,
+ integer_type_node,
+ endlink)),
+ BUILT_IN_VARARGS, NULL_PTR);
+#endif
+ builtin_function ("__builtin_classify_type", default_function_type,
+ BUILT_IN_CLASSIFY_TYPE, NULL_PTR);
+ builtin_function ("__builtin_next_arg",
+ build_function_type (ptr_type_node, endlink),
+ BUILT_IN_NEXT_ARG, NULL_PTR);
+ builtin_function ("__builtin_args_info",
+ build_function_type (integer_type_node,
+ tree_cons (NULL_TREE,
+ integer_type_node,
+ endlink)),
+ BUILT_IN_ARGS_INFO, NULL_PTR);
+
+ /* Untyped call and return. */
+ builtin_function ("__builtin_apply_args",
+ build_function_type (ptr_type_node, NULL_TREE),
+ BUILT_IN_APPLY_ARGS, NULL_PTR);
+
+ temp = tree_cons (NULL_TREE,
+ build_pointer_type (build_function_type (void_type_node,
+ NULL_TREE)),
+ tree_cons (NULL_TREE,
+ ptr_type_node,
+ tree_cons (NULL_TREE,
+ sizetype,
+ endlink)));
+ builtin_function ("__builtin_apply",
+ build_function_type (ptr_type_node, temp),
+ BUILT_IN_APPLY, NULL_PTR);
+ builtin_function ("__builtin_return",
+ build_function_type (void_type_node,
+ tree_cons (NULL_TREE,
+ ptr_type_node,
+ endlink)),
+ BUILT_IN_RETURN, NULL_PTR);
+
+ /* Currently under experimentation. */
+ builtin_function ("__builtin_memcpy", memcpy_ftype,
+ BUILT_IN_MEMCPY, "memcpy");
+ builtin_function ("__builtin_memcmp", int_ftype_cptr_cptr_sizet,
+ BUILT_IN_MEMCMP, "memcmp");
+ builtin_function ("__builtin_strcmp", int_ftype_string_string,
+ BUILT_IN_STRCMP, "strcmp");
+ builtin_function ("__builtin_strcpy", string_ftype_ptr_ptr,
+ BUILT_IN_STRCPY, "strcpy");
+ builtin_function ("__builtin_strlen", strlen_ftype,
+ BUILT_IN_STRLEN, "strlen");
+ builtin_function ("__builtin_fsqrt", double_ftype_double,
+ BUILT_IN_FSQRT, "sqrt");
+ builtin_function ("__builtin_sin", double_ftype_double,
+ BUILT_IN_SIN, "sin");
+ builtin_function ("__builtin_cos", double_ftype_double,
+ BUILT_IN_COS, "cos");
+
+ /* In an ANSI C program, it is okay to supply built-in meanings
+ for these functions, since applications cannot validly use them
+ with any other meaning.
+ However, honor the -fno-builtin option. */
+ if (!flag_no_builtin)
+ {
+ builtin_function ("abs", int_ftype_int, BUILT_IN_ABS, NULL_PTR);
+ builtin_function ("fabs", double_ftype_double, BUILT_IN_FABS, NULL_PTR);
+ builtin_function ("labs", long_ftype_long, BUILT_IN_LABS, NULL_PTR);
+ builtin_function ("memcpy", memcpy_ftype, BUILT_IN_MEMCPY, NULL_PTR);
+ builtin_function ("memcmp", int_ftype_cptr_cptr_sizet, BUILT_IN_MEMCMP,
+ NULL_PTR);
+ builtin_function ("strcmp", int_ftype_string_string, BUILT_IN_STRCMP,
+ NULL_PTR);
+ builtin_function ("strcpy", string_ftype_ptr_ptr, BUILT_IN_STRCPY,
+ NULL_PTR);
+ builtin_function ("strlen", strlen_ftype, BUILT_IN_STRLEN, NULL_PTR);
+ builtin_function ("sqrt", double_ftype_double, BUILT_IN_FSQRT, NULL_PTR);
+ builtin_function ("sin", double_ftype_double, BUILT_IN_SIN, NULL_PTR);
+ builtin_function ("cos", double_ftype_double, BUILT_IN_COS, NULL_PTR);
+
+ /* Declare these functions volatile
+ to avoid spurious "control drops through" warnings. */
+ /* Don't specify the argument types, to avoid errors
+ from certain code which isn't valid in ANSI but which exists. */
+ temp = builtin_function ("abort", void_ftype_any, NOT_BUILT_IN,
+ NULL_PTR);
+ TREE_THIS_VOLATILE (temp) = 1;
+ TREE_SIDE_EFFECTS (temp) = 1;
+ temp = builtin_function ("exit", void_ftype_any, NOT_BUILT_IN, NULL_PTR);
+ TREE_THIS_VOLATILE (temp) = 1;
+ TREE_SIDE_EFFECTS (temp) = 1;
+ }
+
+#if 0
+ /* Support for these has not been written in either expand_builtin
+ or build_function_call. */
+ builtin_function ("__builtin_div", default_ftype, BUILT_IN_DIV, NULL_PTR);
+ builtin_function ("__builtin_ldiv", default_ftype, BUILT_IN_LDIV, NULL_PTR);
+ builtin_function ("__builtin_ffloor", double_ftype_double, BUILT_IN_FFLOOR,
+ NULL_PTR);
+ builtin_function ("__builtin_fceil", double_ftype_double, BUILT_IN_FCEIL,
+ NULL_PTR);
+ builtin_function ("__builtin_fmod", double_ftype_double_double,
+ BUILT_IN_FMOD, NULL_PTR);
+ builtin_function ("__builtin_frem", double_ftype_double_double,
+ BUILT_IN_FREM, NULL_PTR);
+ builtin_function ("__builtin_memset", ptr_ftype_ptr_int_int,
+ BUILT_IN_MEMSET, NULL_PTR);
+ builtin_function ("__builtin_getexp", double_ftype_double, BUILT_IN_GETEXP,
+ NULL_PTR);
+ builtin_function ("__builtin_getman", double_ftype_double, BUILT_IN_GETMAN,
+ NULL_PTR);
+#endif
+
+ /* Create the global bindings for __FUNCTION__ and __PRETTY_FUNCTION__. */
+ declare_function_name ();
+
+ start_identifier_warnings ();
+
+ init_format_info_table ();
+
+ init_iterators ();
+
+ incomplete_decl_finalize_hook = finish_incomplete_decl;
+}
+
+/* Return a definition for a builtin function named NAME and whose data type
+ is TYPE. TYPE should be a function type with argument types.
+ FUNCTION_CODE tells later passes how to compile calls to this function.
+ See tree.h for its possible values.
+
+ If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME,
+ the name to be called if we can't opencode the function. */
+
+tree
+builtin_function (name, type, function_code, library_name)
+ char *name;
+ tree type;
+ enum built_in_function function_code;
+ char *library_name;
+{
+ tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
+ DECL_EXTERNAL (decl) = 1;
+ TREE_PUBLIC (decl) = 1;
+ /* If -traditional, permit redefining a builtin function any way you like.
+ (Though really, if the program redefines these functions,
+ it probably won't work right unless compiled with -fno-builtin.) */
+ if (flag_traditional && name[0] != '_')
+ DECL_BUILT_IN_NONANSI (decl) = 1;
+ if (library_name)
+ DECL_ASSEMBLER_NAME (decl) = get_identifier (library_name);
+ make_decl_rtl (decl, NULL_PTR, 1);
+ pushdecl (decl);
+ if (function_code != NOT_BUILT_IN)
+ {
+ DECL_BUILT_IN (decl) = 1;
+ DECL_SET_FUNCTION_CODE (decl, function_code);
+ }
+ /* Warn if a function in the namespace for users
+ is used without an occasion to consider it declared. */
+ if (name[0] != '_' || name[1] != '_')
+ C_DECL_ANTICIPATED (decl) = 1;
+
+ return decl;
+}
+
+/* Called when a declaration is seen that contains no names to declare.
+ If its type is a reference to a structure, union or enum inherited
+ from a containing scope, shadow that tag name for the current scope
+ with a forward reference.
+ If its type defines a new named structure or union
+ or defines an enum, it is valid but we need not do anything here.
+ Otherwise, it is an error. */
+
+void
+shadow_tag (declspecs)
+ tree declspecs;
+{
+ shadow_tag_warned (declspecs, 0);
+}
+
+void
+shadow_tag_warned (declspecs, warned)
+ tree declspecs;
+ int warned;
+ /* 1 => we have done a pedwarn. 2 => we have done a warning, but
+ no pedwarn. */
+{
+ int found_tag = 0;
+ register tree link;
+
+ pending_invalid_xref = 0;
+
+ for (link = declspecs; link; link = TREE_CHAIN (link))
+ {
+ register tree value = TREE_VALUE (link);
+ register enum tree_code code = TREE_CODE (value);
+
+ if (code == RECORD_TYPE || code == UNION_TYPE || code == ENUMERAL_TYPE)
+ /* Used to test also that TYPE_SIZE (value) != 0.
+ That caused warning for `struct foo;' at top level in the file. */
+ {
+ register tree name = lookup_tag_reverse (value);
+ register tree t;
+
+ found_tag++;
+
+ if (name == 0)
+ {
+ if (warned != 1 && code != ENUMERAL_TYPE)
+ /* Empty unnamed enum OK */
+ {
+ pedwarn ("unnamed struct/union that defines no instances");
+ warned = 1;
+ }
+ }
+ else
+ {
+ t = lookup_tag (code, name, current_binding_level, 1);
+
+ if (t == 0)
+ {
+ t = make_node (code);
+ pushtag (name, t);
+ }
+ }
+ }
+ else
+ {
+ if (!warned)
+ {
+ warning ("useless keyword or type name in empty declaration");
+ warned = 2;
+ }
+ }
+ }
+
+ if (found_tag > 1)
+ error ("two types specified in one empty declaration");
+
+ if (warned != 1)
+ {
+ if (found_tag == 0)
+ pedwarn ("empty declaration");
+ }
+}
+
+/* Decode a "typename", such as "int **", returning a ..._TYPE node. */
+
+tree
+groktypename (typename)
+ tree typename;
+{
+ if (TREE_CODE (typename) != TREE_LIST)
+ return typename;
+ return grokdeclarator (TREE_VALUE (typename),
+ TREE_PURPOSE (typename),
+ TYPENAME, 0);
+}
+
+/* Return a PARM_DECL node for a given pair of specs and declarator. */
+
+tree
+groktypename_in_parm_context (typename)
+ tree typename;
+{
+ if (TREE_CODE (typename) != TREE_LIST)
+ return typename;
+ return grokdeclarator (TREE_VALUE (typename),
+ TREE_PURPOSE (typename),
+ PARM, 0);
+}
+
+/* Decode a declarator in an ordinary declaration or data definition.
+ This is called as soon as the type information and variable name
+ have been parsed, before parsing the initializer if any.
+ Here we create the ..._DECL node, fill in its type,
+ and put it on the list of decls for the current context.
+ The ..._DECL node is returned as the value.
+
+ Exception: for arrays where the length is not specified,
+ the type is left null, to be filled in by `finish_decl'.
+
+ Function definitions do not come here; they go to start_function
+ instead. However, external and forward declarations of functions
+ do go through here. Structure field declarations are done by
+ grokfield and not through here. */
+
+/* Set this to zero to debug not using the temporary obstack
+ to parse initializers. */
+int debug_temp_inits = 1;
+
+tree
+start_decl (declarator, declspecs, initialized)
+ tree declarator, declspecs;
+ int initialized;
+{
+ register tree decl = grokdeclarator (declarator, declspecs,
+ NORMAL, initialized);
+ register tree tem;
+ int init_written = initialized;
+
+ /* The corresponding pop_obstacks is in finish_decl. */
+ push_obstacks_nochange ();
+
+ if (initialized)
+ /* Is it valid for this decl to have an initializer at all?
+ If not, set INITIALIZED to zero, which will indirectly
+ tell `finish_decl' to ignore the initializer once it is parsed. */
+ switch (TREE_CODE (decl))
+ {
+ case TYPE_DECL:
+ /* typedef foo = bar means give foo the same type as bar.
+ We haven't parsed bar yet, so `finish_decl' will fix that up.
+ Any other case of an initialization in a TYPE_DECL is an error. */
+ if (pedantic || list_length (declspecs) > 1)
+ {
+ error ("typedef `%s' is initialized",
+ IDENTIFIER_POINTER (DECL_NAME (decl)));
+ initialized = 0;
+ }
+ break;
+
+ case FUNCTION_DECL:
+ error ("function `%s' is initialized like a variable",
+ IDENTIFIER_POINTER (DECL_NAME (decl)));
+ initialized = 0;
+ break;
+
+ case PARM_DECL:
+ /* DECL_INITIAL in a PARM_DECL is really DECL_ARG_TYPE. */
+ error ("parameter `%s' is initialized",
+ IDENTIFIER_POINTER (DECL_NAME (decl)));
+ initialized = 0;
+ break;
+
+ default:
+ /* Don't allow initializations for incomplete types
+ except for arrays which might be completed by the initialization. */
+ if (TYPE_SIZE (TREE_TYPE (decl)) != 0)
+ {
+ /* A complete type is ok if size is fixed. */
+
+ if (TREE_CODE (TYPE_SIZE (TREE_TYPE (decl))) != INTEGER_CST
+ || C_DECL_VARIABLE_SIZE (decl))
+ {
+ error ("variable-sized object may not be initialized");
+ initialized = 0;
+ }
+ }
+ else if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE)
+ {
+ error ("variable `%s' has initializer but incomplete type",
+ IDENTIFIER_POINTER (DECL_NAME (decl)));
+ initialized = 0;
+ }
+ else if (TYPE_SIZE (TREE_TYPE (TREE_TYPE (decl))) == 0)
+ {
+ error ("elements of array `%s' have incomplete type",
+ IDENTIFIER_POINTER (DECL_NAME (decl)));
+ initialized = 0;
+ }
+ }
+
+ if (initialized)
+ {
+#if 0 /* Seems redundant with grokdeclarator. */
+ if (current_binding_level != global_binding_level
+ && DECL_EXTERNAL (decl)
+ && TREE_CODE (decl) != FUNCTION_DECL)
+ warning ("declaration of `%s' has `extern' and is initialized",
+ IDENTIFIER_POINTER (DECL_NAME (decl)));
+#endif
+ DECL_EXTERNAL (decl) = 0;
+ if (current_binding_level == global_binding_level)
+ TREE_STATIC (decl) = 1;
+
+ /* Tell `pushdecl' this is an initialized decl
+ even though we don't yet have the initializer expression.
+ Also tell `finish_decl' it may store the real initializer. */
+ DECL_INITIAL (decl) = error_mark_node;
+ }
+
+ /* If this is a function declaration, write a record describing it to the
+ prototypes file (if requested). */
+
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ gen_aux_info_record (decl, 0, 0, TYPE_ARG_TYPES (TREE_TYPE (decl)) != 0);
+
+ /* Add this decl to the current binding level.
+ TEM may equal DECL or it may be a previous decl of the same name. */
+ tem = pushdecl (decl);
+
+ /* For a local variable, define the RTL now. */
+ if (current_binding_level != global_binding_level
+ /* But not if this is a duplicate decl
+ and we preserved the rtl from the previous one
+ (which may or may not happen). */
+ && DECL_RTL (tem) == 0)
+ {
+ if (TYPE_SIZE (TREE_TYPE (tem)) != 0)
+ expand_decl (tem);
+ else if (TREE_CODE (TREE_TYPE (tem)) == ARRAY_TYPE
+ && DECL_INITIAL (tem) != 0)
+ expand_decl (tem);
+ }
+
+ if (init_written)
+ {
+ /* When parsing and digesting the initializer,
+ use temporary storage. Do this even if we will ignore the value. */
+ if (current_binding_level == global_binding_level && debug_temp_inits)
+ temporary_allocation ();
+ }
+
+ return tem;
+}
+
+/* Finish processing of a declaration;
+ install its initial value.
+ If the length of an array type is not known before,
+ it must be determined now, from the initial value, or it is an error. */
+
+void
+finish_decl (decl, init, asmspec_tree)
+ tree decl, init;
+ tree asmspec_tree;
+{
+ register tree type = TREE_TYPE (decl);
+ int was_incomplete = (DECL_SIZE (decl) == 0);
+ int temporary = allocation_temporary_p ();
+ char *asmspec = 0;
+
+ if (asmspec_tree)
+ asmspec = TREE_STRING_POINTER (asmspec_tree);
+
+ /* If `start_decl' didn't like having an initialization, ignore it now. */
+
+ if (init != 0 && DECL_INITIAL (decl) == 0)
+ init = 0;
+ /* Don't crash if parm is initialized. */
+ if (TREE_CODE (decl) == PARM_DECL)
+ init = 0;
+
+ if (ITERATOR_P (decl))
+ {
+ if (init == 0)
+ error_with_decl (decl, "iterator has no initial value");
+ else
+ init = save_expr (init);
+ }
+
+ if (init)
+ {
+ if (TREE_CODE (decl) != TYPE_DECL)
+ store_init_value (decl, init);
+ else
+ {
+ /* typedef foo = bar; store the type of bar as the type of foo. */
+ TREE_TYPE (decl) = TREE_TYPE (init);
+ DECL_INITIAL (decl) = init = 0;
+ }
+ }
+
+ /* Pop back to the obstack that is current for this binding level.
+ This is because MAXINDEX, rtl, etc. to be made below
+ must go in the permanent obstack. But don't discard the
+ temporary data yet. */
+ pop_obstacks ();
+#if 0 /* pop_obstacks was near the end; this is what was here. */
+ if (current_binding_level == global_binding_level && temporary)
+ end_temporary_allocation ();
+#endif
+
+ /* Deduce size of array from initialization, if not already known */
+
+ if (TREE_CODE (type) == ARRAY_TYPE
+ && TYPE_DOMAIN (type) == 0
+ && TREE_CODE (decl) != TYPE_DECL)
+ {
+ int do_default
+ = (TREE_STATIC (decl)
+ /* Even if pedantic, an external linkage array
+ may have incomplete type at first. */
+ ? pedantic && !TREE_PUBLIC (decl)
+ : !DECL_EXTERNAL (decl));
+ int failure
+ = complete_array_type (type, DECL_INITIAL (decl), do_default);
+
+ /* Get the completed type made by complete_array_type. */
+ type = TREE_TYPE (decl);
+
+ if (failure == 1)
+ error_with_decl (decl, "initializer fails to determine size of `%s'");
+
+ if (failure == 2)
+ {
+ if (do_default)
+ error_with_decl (decl, "array size missing in `%s'");
+ /* If a `static' var's size isn't known,
+ make it extern as well as static, so it does not get
+ allocated.
+ If it is not `static', then do not mark extern;
+ finish_incomplete_decl will give it a default size
+ and it will get allocated. */
+ else if (!pedantic && TREE_STATIC (decl) && ! TREE_PUBLIC (decl))
+ DECL_EXTERNAL (decl) = 1;
+ }
+
+ if (pedantic && TYPE_DOMAIN (type) != 0
+ && tree_int_cst_lt (TYPE_MAX_VALUE (TYPE_DOMAIN (type)),
+ integer_zero_node))
+ error_with_decl (decl, "zero-size array `%s'");
+
+ layout_decl (decl, 0);
+ }
+
+ if (TREE_CODE (decl) == VAR_DECL)
+ {
+ if (DECL_SIZE (decl) == 0
+ && TYPE_SIZE (TREE_TYPE (decl)) != 0)
+ layout_decl (decl, 0);
+
+ if (DECL_SIZE (decl) == 0
+ && (TREE_STATIC (decl)
+ ?
+ /* A static variable with an incomplete type
+ is an error if it is initialized or `static'.
+ Otherwise, let it through, but if it is not `extern'
+ then it may cause an error message later. */
+ !TREE_PUBLIC (decl) || DECL_INITIAL (decl)
+ :
+ /* An automatic variable with an incomplete type
+ is an error. */
+ !DECL_EXTERNAL (decl)))
+ {
+ error_with_decl (decl, "storage size of `%s' isn't known");
+ TREE_TYPE (decl) = error_mark_node;
+ }
+
+ if ((DECL_EXTERNAL (decl) || TREE_STATIC (decl))
+ && DECL_SIZE (decl) != 0)
+ {
+ if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)
+ constant_expression_warning (DECL_SIZE (decl));
+ else
+ error_with_decl (decl, "storage size of `%s' isn't constant");
+ }
+ }
+
+ /* Output the assembler code and/or RTL code for variables and functions,
+ unless the type is an undefined structure or union.
+ If not, it will get done when the type is completed. */
+
+ if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)
+ {
+ if (flag_traditional && allocation_temporary_p ())
+ {
+ push_obstacks_nochange ();
+ end_temporary_allocation ();
+ /* This is a no-op in c-lang.c or something real in objc-actions.c. */
+ maybe_objc_check_decl (decl);
+ rest_of_decl_compilation (decl, asmspec,
+ current_binding_level == global_binding_level,
+ 0);
+ pop_obstacks ();
+ }
+ else
+ {
+ /* This is a no-op in c-lang.c or something real in objc-actions.c. */
+ maybe_objc_check_decl (decl);
+ rest_of_decl_compilation (decl, asmspec,
+ current_binding_level == global_binding_level,
+ 0);
+ }
+ if (current_binding_level != global_binding_level)
+ {
+ /* Recompute the RTL of a local array now
+ if it used to be an incomplete type. */
+ if (was_incomplete
+ && ! TREE_STATIC (decl) && ! DECL_EXTERNAL (decl))
+ {
+ /* If we used it already as memory, it must stay in memory. */
+ TREE_ADDRESSABLE (decl) = TREE_USED (decl);
+ /* If it's still incomplete now, no init will save it. */
+ if (DECL_SIZE (decl) == 0)
+ DECL_INITIAL (decl) = 0;
+ expand_decl (decl);
+ }
+ /* Compute and store the initial value. */
+ if (TREE_CODE (decl) != FUNCTION_DECL)
+ expand_decl_init (decl);
+ }
+ }
+
+ if (TREE_CODE (decl) == TYPE_DECL)
+ {
+ /* This is a no-op in c-lang.c or something real in objc-actions.c. */
+ maybe_objc_check_decl (decl);
+ rest_of_decl_compilation (decl, NULL_PTR,
+ current_binding_level == global_binding_level,
+ 0);
+ }
+
+ /* ??? After 2.3, test (init != 0) instead of TREE_CODE. */
+ if (!(TREE_CODE (decl) == FUNCTION_DECL && DECL_INLINE (decl))
+ && temporary && TREE_PERMANENT (decl)
+ /* DECL_INITIAL is not defined in PARM_DECLs, since it shares
+ space with DECL_ARG_TYPE. */
+ && TREE_CODE (decl) != PARM_DECL)
+ {
+ /* We need to remember that this array HAD an initialization,
+ but discard the actual temporary nodes,
+ since we can't have a permanent node keep pointing to them. */
+ /* We make an exception for inline functions, since it's
+ normal for a local extern redeclaration of an inline function
+ to have a copy of the top-level decl's DECL_INLINE. */
+ if (DECL_INITIAL (decl) != 0)
+ DECL_INITIAL (decl) = error_mark_node;
+ }
+
+#if 0
+ /* Resume permanent allocation, if not within a function. */
+ /* The corresponding push_obstacks_nochange is in start_decl,
+ and in push_parm_decl and in grokfield. */
+ pop_obstacks ();
+#endif
+
+ /* If we have gone back from temporary to permanent allocation,
+ actually free the temporary space that we no longer need. */
+ if (temporary && !allocation_temporary_p ())
+ permanent_allocation ();
+
+ /* At the end of a declaration, throw away any variable type sizes
+ of types defined inside that declaration. There is no use
+ computing them in the following function definition. */
+ if (current_binding_level == global_binding_level)
+ get_pending_sizes ();
+}
+
+/* If DECL has a cleanup, build and return that cleanup here.
+ This is a callback called by expand_expr. */
+
+tree
+maybe_build_cleanup (decl)
+ tree decl;
+{
+ /* There are no cleanups in C. */
+ return NULL_TREE;
+}
+
+/* Given a parsed parameter declaration,
+ decode it into a PARM_DECL and push that on the current binding level.
+ Also, for the sake of forward parm decls,
+ record the given order of parms in `parm_order'. */
+
+void
+push_parm_decl (parm)
+ tree parm;
+{
+ tree decl, olddecl;
+ int old_immediate_size_expand = immediate_size_expand;
+ /* Don't try computing parm sizes now -- wait till fn is called. */
+ immediate_size_expand = 0;
+
+ /* The corresponding pop_obstacks is in finish_decl. */
+ push_obstacks_nochange ();
+
+ decl = grokdeclarator (TREE_VALUE (parm), TREE_PURPOSE (parm), PARM, 0);
+
+#if 0
+ if (DECL_NAME (decl))
+ {
+ olddecl = lookup_name (DECL_NAME (decl));
+ if (pedantic && olddecl != 0 && TREE_CODE (olddecl) == TYPE_DECL)
+ pedwarn_with_decl (decl, "ANSI C forbids parameter `%s' shadowing typedef");
+ }
+#endif
+
+ decl = pushdecl (decl);
+
+ immediate_size_expand = old_immediate_size_expand;
+
+ current_binding_level->parm_order
+ = tree_cons (NULL_TREE, decl, current_binding_level->parm_order);
+
+ /* Add this decl to the current binding level. */
+ finish_decl (decl, NULL_TREE, NULL_TREE);
+}
+
+/* Clear the given order of parms in `parm_order'.
+ Used at start of parm list,
+ and also at semicolon terminating forward decls. */
+
+void
+clear_parm_order ()
+{
+ current_binding_level->parm_order = NULL_TREE;
+}
+
+/* Make TYPE a complete type based on INITIAL_VALUE.
+ Return 0 if successful, 1 if INITIAL_VALUE can't be deciphered,
+ 2 if there was no information (in which case assume 1 if DO_DEFAULT). */
+
+int
+complete_array_type (type, initial_value, do_default)
+ tree type;
+ tree initial_value;
+ int do_default;
+{
+ register tree maxindex = NULL_TREE;
+ int value = 0;
+
+ if (initial_value)
+ {
+ /* Note MAXINDEX is really the maximum index,
+ one less than the size. */
+ if (TREE_CODE (initial_value) == STRING_CST)
+ {
+ int eltsize
+ = int_size_in_bytes (TREE_TYPE (TREE_TYPE (initial_value)));
+ maxindex = build_int_2 (TREE_STRING_LENGTH (initial_value) / eltsize - 1, 0);
+ }
+ else if (TREE_CODE (initial_value) == CONSTRUCTOR)
+ {
+ register int nelts
+ = list_length (CONSTRUCTOR_ELTS (initial_value));
+ maxindex = build_int_2 (nelts - 1, - (nelts == 0));
+ }
+ else
+ {
+ /* Make an error message unless that happened already. */
+ if (initial_value != error_mark_node)
+ value = 1;
+
+ /* Prevent further error messages. */
+ maxindex = build_int_2 (0, 0);
+ }
+ }
+
+ if (!maxindex)
+ {
+ if (do_default)
+ maxindex = build_int_2 (0, 0);
+ value = 2;
+ }
+
+ if (maxindex)
+ {
+ TYPE_DOMAIN (type) = build_index_type (maxindex);
+ if (!TREE_TYPE (maxindex))
+ TREE_TYPE (maxindex) = TYPE_DOMAIN (type);
+#if 0 /* I took out this change
+ together with the change in build_array_type. --rms */
+ change_main_variant (type,
+ build_array_type (TREE_TYPE (type),
+ TYPE_DOMAIN (type)));
+#endif
+ }
+
+ /* Lay out the type now that we can get the real answer. */
+
+ layout_type (type);
+
+ return value;
+}
+
+/* Given declspecs and a declarator,
+ determine the name and type of the object declared
+ and construct a ..._DECL node for it.
+ (In one case we can return a ..._TYPE node instead.
+ For invalid input we sometimes return 0.)
+
+ DECLSPECS is a chain of tree_list nodes whose value fields
+ are the storage classes and type specifiers.
+
+ DECL_CONTEXT says which syntactic context this declaration is in:
+ NORMAL for most contexts. Make a VAR_DECL or FUNCTION_DECL or TYPE_DECL.
+ FUNCDEF for a function definition. Like NORMAL but a few different
+ error messages in each case. Return value may be zero meaning
+ this definition is too screwy to try to parse.
+ PARM for a parameter declaration (either within a function prototype
+ or before a function body). Make a PARM_DECL, or return void_type_node.
+ TYPENAME if for a typename (in a cast or sizeof).
+ Don't make a DECL node; just return the ..._TYPE node.
+ FIELD for a struct or union field; make a FIELD_DECL.
+ BITFIELD for a field with specified width.
+ INITIALIZED is 1 if the decl has an initializer.
+
+ In the TYPENAME case, DECLARATOR is really an absolute declarator.
+ It may also be so in the PARM case, for a prototype where the
+ argument type is specified but not the name.
+
+ This function is where the complicated C meanings of `static'
+ and `extern' are interpreted. */
+
+static tree
+grokdeclarator (declarator, declspecs, decl_context, initialized)
+ tree declspecs;
+ tree declarator;
+ enum decl_context decl_context;
+ int initialized;
+{
+ int specbits = 0;
+ tree spec;
+ tree type = NULL_TREE;
+ int longlong = 0;
+ int constp;
+ int volatilep;
+ int inlinep;
+ int explicit_int = 0;
+ int explicit_char = 0;
+ int defaulted_int = 0;
+ tree typedef_decl = 0;
+ char *name;
+ tree typedef_type = 0;
+ int funcdef_flag = 0;
+ enum tree_code innermost_code = ERROR_MARK;
+ int bitfield = 0;
+ int size_varies = 0;
+
+ if (decl_context == BITFIELD)
+ bitfield = 1, decl_context = FIELD;
+
+ if (decl_context == FUNCDEF)
+ funcdef_flag = 1, decl_context = NORMAL;
+
+ push_obstacks_nochange ();
+
+ if (flag_traditional && allocation_temporary_p ())
+ end_temporary_allocation ();
+
+ /* Look inside a declarator for the name being declared
+ and get it as a string, for an error message. */
+ {
+ register tree decl = declarator;
+ name = 0;
+
+ while (decl)
+ switch (TREE_CODE (decl))
+ {
+ case ARRAY_REF:
+ case INDIRECT_REF:
+ case CALL_EXPR:
+ innermost_code = TREE_CODE (decl);
+ decl = TREE_OPERAND (decl, 0);
+ break;
+
+ case IDENTIFIER_NODE:
+ name = IDENTIFIER_POINTER (decl);
+ decl = 0;
+ break;
+
+ default:
+ abort ();
+ }
+ if (name == 0)
+ name = "type name";
+ }
+
+ /* A function definition's declarator must have the form of
+ a function declarator. */
+
+ if (funcdef_flag && innermost_code != CALL_EXPR)
+ return 0;
+
+ /* Anything declared one level down from the top level
+ must be one of the parameters of a function
+ (because the body is at least two levels down). */
+
+ /* If this looks like a function definition, make it one,
+ even if it occurs where parms are expected.
+ Then store_parm_decls will reject it and not use it as a parm. */
+ if (decl_context == NORMAL && !funcdef_flag
+ && current_binding_level->level_chain == global_binding_level)
+ decl_context = PARM;
+
+ /* Look through the decl specs and record which ones appear.
+ Some typespecs are defined as built-in typenames.
+ Others, the ones that are modifiers of other types,
+ are represented by bits in SPECBITS: set the bits for
+ the modifiers that appear. Storage class keywords are also in SPECBITS.
+
+ If there is a typedef name or a type, store the type in TYPE.
+ This includes builtin typedefs such as `int'.
+
+ Set EXPLICIT_INT or EXPLICIT_CHAR if the type is `int' or `char'
+ and did not come from a user typedef.
+
+ Set LONGLONG if `long' is mentioned twice. */
+
+ for (spec = declspecs; spec; spec = TREE_CHAIN (spec))
+ {
+ register int i;
+ register tree id = TREE_VALUE (spec);
+
+ if (id == ridpointers[(int) RID_INT])
+ explicit_int = 1;
+ if (id == ridpointers[(int) RID_CHAR])
+ explicit_char = 1;
+
+ if (TREE_CODE (id) == IDENTIFIER_NODE)
+ for (i = (int) RID_FIRST_MODIFIER; i < (int) RID_MAX; i++)
+ {
+ if (ridpointers[i] == id)
+ {
+ if (i == (int) RID_LONG && specbits & (1<<i))
+ {
+ if (longlong)
+ error ("`long long long' is too long for GCC");
+ else
+ {
+ if (pedantic)
+ pedwarn ("ANSI C does not support `long long'");
+ longlong = 1;
+ }
+ }
+ else if (specbits & (1 << i))
+ pedwarn ("duplicate `%s'", IDENTIFIER_POINTER (id));
+ specbits |= 1 << i;
+ goto found;
+ }
+ }
+ if (type)
+ error ("two or more data types in declaration of `%s'", name);
+ /* Actual typedefs come to us as TYPE_DECL nodes. */
+ else if (TREE_CODE (id) == TYPE_DECL)
+ {
+ type = TREE_TYPE (id);
+ typedef_decl = id;
+ }
+ /* Built-in types come as identifiers. */
+ else if (TREE_CODE (id) == IDENTIFIER_NODE)
+ {
+ register tree t = lookup_name (id);
+ if (TREE_TYPE (t) == error_mark_node)
+ ;
+ else if (!t || TREE_CODE (t) != TYPE_DECL)
+ error ("`%s' fails to be a typedef or built in type",
+ IDENTIFIER_POINTER (id));
+ else
+ {
+ type = TREE_TYPE (t);
+ typedef_decl = t;
+ }
+ }
+ else if (TREE_CODE (id) != ERROR_MARK)
+ type = id;
+
+ found: {}
+ }
+
+ typedef_type = type;
+ if (type)
+ size_varies = C_TYPE_VARIABLE_SIZE (type);
+
+ /* No type at all: default to `int', and set DEFAULTED_INT
+ because it was not a user-defined typedef. */
+
+ if (type == 0)
+ {
+ if (funcdef_flag && warn_return_type
+ && ! (specbits & ((1 << (int) RID_LONG) | (1 << (int) RID_SHORT)
+ | (1 << (int) RID_SIGNED) | (1 << (int) RID_UNSIGNED))))
+ warn_about_return_type = 1;
+ defaulted_int = 1;
+ type = integer_type_node;
+ }
+
+ /* Now process the modifiers that were specified
+ and check for invalid combinations. */
+
+ /* Long double is a special combination. */
+
+ if ((specbits & 1 << (int) RID_LONG)
+ && TYPE_MAIN_VARIANT (type) == double_type_node)
+ {
+ specbits &= ~ (1 << (int) RID_LONG);
+ type = long_double_type_node;
+ }
+
+ /* Check all other uses of type modifiers. */
+
+ if (specbits & ((1 << (int) RID_LONG) | (1 << (int) RID_SHORT)
+ | (1 << (int) RID_UNSIGNED) | (1 << (int) RID_SIGNED)))
+ {
+ int ok = 0;
+
+ if (TREE_CODE (type) != INTEGER_TYPE)
+ error ("long, short, signed or unsigned invalid for `%s'", name);
+ else if ((specbits & 1 << (int) RID_LONG)
+ && (specbits & 1 << (int) RID_SHORT))
+ error ("long and short specified together for `%s'", name);
+ else if (((specbits & 1 << (int) RID_LONG)
+ || (specbits & 1 << (int) RID_SHORT))
+ && explicit_char)
+ error ("long or short specified with char for `%s'", name);
+ else if (((specbits & 1 << (int) RID_LONG)
+ || (specbits & 1 << (int) RID_SHORT))
+ && TREE_CODE (type) == REAL_TYPE)
+ error ("long or short specified with floating type for `%s'", name);
+ else if ((specbits & 1 << (int) RID_SIGNED)
+ && (specbits & 1 << (int) RID_UNSIGNED))
+ error ("signed and unsigned given together for `%s'", name);
+ else
+ {
+ ok = 1;
+ if (!explicit_int && !defaulted_int && !explicit_char && pedantic)
+ {
+ pedwarn ("long, short, signed or unsigned used invalidly for `%s'",
+ name);
+ if (flag_pedantic_errors)
+ ok = 0;
+ }
+ }
+
+ /* Discard the type modifiers if they are invalid. */
+ if (! ok)
+ {
+ specbits &= ~((1 << (int) RID_LONG) | (1 << (int) RID_SHORT)
+ | (1 << (int) RID_UNSIGNED) | (1 << (int) RID_SIGNED));
+ longlong = 0;
+ }
+ }
+
+ /* Decide whether an integer type is signed or not.
+ Optionally treat bitfields as signed by default. */
+ if (specbits & 1 << (int) RID_UNSIGNED
+ /* Traditionally, all bitfields are unsigned. */
+ || (bitfield && flag_traditional
+ && (! explicit_flag_signed_bitfields || !flag_signed_bitfields))
+ || (bitfield && ! flag_signed_bitfields
+ && (explicit_int || defaulted_int || explicit_char
+ /* A typedef for plain `int' without `signed'
+ can be controlled just like plain `int'. */
+ || ! (typedef_decl != 0
+ && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
+ && TREE_CODE (type) != ENUMERAL_TYPE
+ && !(specbits & 1 << (int) RID_SIGNED)))
+ {
+ if (longlong)
+ type = long_long_unsigned_type_node;
+ else if (specbits & 1 << (int) RID_LONG)
+ type = long_unsigned_type_node;
+ else if (specbits & 1 << (int) RID_SHORT)
+ type = short_unsigned_type_node;
+ else if (type == char_type_node)
+ type = unsigned_char_type_node;
+ else if (typedef_decl)
+ type = unsigned_type (type);
+ else
+ type = unsigned_type_node;
+ }
+ else if ((specbits & 1 << (int) RID_SIGNED)
+ && type == char_type_node)
+ type = signed_char_type_node;
+ else if (longlong)
+ type = long_long_integer_type_node;
+ else if (specbits & 1 << (int) RID_LONG)
+ type = long_integer_type_node;
+ else if (specbits & 1 << (int) RID_SHORT)
+ type = short_integer_type_node;
+ else if (specbits & 1 << (int) RID_COMPLEX)
+ {
+ if (defaulted_int)
+ type = complex_double_type_node;
+ else if (type == integer_type_node)
+ type = complex_integer_type_node;
+ else if (type == float_type_node)
+ type = complex_float_type_node;
+ else if (type == double_type_node)
+ type = complex_double_type_node;
+ else if (type == long_double_type_node)
+ type = complex_long_double_type_node;
+ else
+ error ("invalid complex type");
+ }
+
+ /* Set CONSTP if this declaration is `const', whether by
+ explicit specification or via a typedef.
+ Likewise for VOLATILEP. */
+
+ constp = !! (specbits & 1 << (int) RID_CONST) + TYPE_READONLY (type);
+ volatilep = !! (specbits & 1 << (int) RID_VOLATILE) + TYPE_VOLATILE (type);
+ inlinep = !! (specbits & (1 << (int) RID_INLINE));
+ if (constp > 1)
+ pedwarn ("duplicate `const'");
+ if (volatilep > 1)
+ pedwarn ("duplicate `volatile'");
+ if (! flag_gen_aux_info && (TYPE_READONLY (type) || TYPE_VOLATILE (type)))
+ type = TYPE_MAIN_VARIANT (type);
+
+ /* Warn if two storage classes are given. Default to `auto'. */
+
+ {
+ int nclasses = 0;
+
+ if (specbits & 1 << (int) RID_AUTO) nclasses++;
+ if (specbits & 1 << (int) RID_STATIC) nclasses++;
+ if (specbits & 1 << (int) RID_EXTERN) nclasses++;
+ if (specbits & 1 << (int) RID_REGISTER) nclasses++;
+ if (specbits & 1 << (int) RID_TYPEDEF) nclasses++;
+ if (specbits & 1 << (int) RID_ITERATOR) nclasses++;
+
+ /* Warn about storage classes that are invalid for certain
+ kinds of declarations (parameters, typenames, etc.). */
+
+ if (nclasses > 1)
+ error ("multiple storage classes in declaration of `%s'", name);
+ else if (funcdef_flag
+ && (specbits
+ & ((1 << (int) RID_REGISTER)
+ | (1 << (int) RID_AUTO)
+ | (1 << (int) RID_TYPEDEF))))
+ {
+ if (specbits & 1 << (int) RID_AUTO
+ && (pedantic || current_binding_level == global_binding_level))
+ pedwarn ("function definition declared `auto'");
+ if (specbits & 1 << (int) RID_REGISTER)
+ error ("function definition declared `register'");
+ if (specbits & 1 << (int) RID_TYPEDEF)
+ error ("function definition declared `typedef'");
+ specbits &= ~ ((1 << (int) RID_TYPEDEF) | (1 << (int) RID_REGISTER)
+ | (1 << (int) RID_AUTO));
+ }
+ else if (decl_context != NORMAL && nclasses > 0)
+ {
+ if (decl_context == PARM && specbits & 1 << (int) RID_REGISTER)
+ ;
+ else
+ {
+ error ((decl_context == FIELD
+ ? "storage class specified for structure field `%s'"
+ : (decl_context == PARM
+ ? "storage class specified for parameter `%s'"
+ : "storage class specified for typename")),
+ name);
+ specbits &= ~ ((1 << (int) RID_TYPEDEF) | (1 << (int) RID_REGISTER)
+ | (1 << (int) RID_AUTO) | (1 << (int) RID_STATIC)
+ | (1 << (int) RID_EXTERN));
+ }
+ }
+ else if (specbits & 1 << (int) RID_EXTERN && initialized && ! funcdef_flag)
+ {
+ /* `extern' with initialization is invalid if not at top level. */
+ if (current_binding_level == global_binding_level)
+ warning ("`%s' initialized and declared `extern'", name);
+ else
+ error ("`%s' has both `extern' and initializer", name);
+ }
+ else if (specbits & 1 << (int) RID_EXTERN && funcdef_flag
+ && current_binding_level != global_binding_level)
+ error ("nested function `%s' declared `extern'", name);
+ else if (current_binding_level == global_binding_level
+ && specbits & (1 << (int) RID_AUTO))
+ error ("top-level declaration of `%s' specifies `auto'", name);
+ else if ((specbits & 1 << (int) RID_ITERATOR)
+ && TREE_CODE (declarator) != IDENTIFIER_NODE)
+ {
+ error ("iterator `%s' has derived type", name);
+ type = error_mark_node;
+ }
+ else if ((specbits & 1 << (int) RID_ITERATOR)
+ && TREE_CODE (type) != INTEGER_TYPE)
+ {
+ error ("iterator `%s' has noninteger type", name);
+ type = error_mark_node;
+ }
+ }
+
+ /* Now figure out the structure of the declarator proper.
+ Descend through it, creating more complex types, until we reach
+ the declared identifier (or NULL_TREE, in an absolute declarator). */
+
+ while (declarator && TREE_CODE (declarator) != IDENTIFIER_NODE)
+ {
+ if (type == error_mark_node)
+ {
+ declarator = TREE_OPERAND (declarator, 0);
+ continue;
+ }
+
+ /* Each level of DECLARATOR is either an ARRAY_REF (for ...[..]),
+ an INDIRECT_REF (for *...),
+ a CALL_EXPR (for ...(...)),
+ an identifier (for the name being declared)
+ or a null pointer (for the place in an absolute declarator
+ where the name was omitted).
+ For the last two cases, we have just exited the loop.
+
+ At this point, TYPE is the type of elements of an array,
+ or for a function to return, or for a pointer to point to.
+ After this sequence of ifs, TYPE is the type of the
+ array or function or pointer, and DECLARATOR has had its
+ outermost layer removed. */
+
+ if (TREE_CODE (declarator) == ARRAY_REF)
+ {
+ register tree itype = NULL_TREE;
+ register tree size = TREE_OPERAND (declarator, 1);
+ /* An uninitialized decl with `extern' is a reference. */
+ int extern_ref = !initialized && (specbits & (1 << (int) RID_EXTERN));
+
+ declarator = TREE_OPERAND (declarator, 0);
+
+ /* Check for some types that there cannot be arrays of. */
+
+ if (TYPE_MAIN_VARIANT (type) == void_type_node)
+ {
+ error ("declaration of `%s' as array of voids", name);
+ type = error_mark_node;
+ }
+
+ if (TREE_CODE (type) == FUNCTION_TYPE)
+ {
+ error ("declaration of `%s' as array of functions", name);
+ type = error_mark_node;
+ }
+
+ if (size == error_mark_node)
+ type = error_mark_node;
+
+ if (type == error_mark_node)
+ continue;
+
+ /* If this is a block level extern, it must live past the end
+ of the function so that we can check it against other extern
+ declarations (IDENTIFIER_LIMBO_VALUE). */
+ if (extern_ref && allocation_temporary_p ())
+ end_temporary_allocation ();
+
+ /* If size was specified, set ITYPE to a range-type for that size.
+ Otherwise, ITYPE remains null. finish_decl may figure it out
+ from an initial value. */
+
+ if (size)
+ {
+ /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
+ STRIP_TYPE_NOPS (size);
+
+ if (TREE_CODE (TREE_TYPE (size)) != INTEGER_TYPE
+ && TREE_CODE (TREE_TYPE (size)) != ENUMERAL_TYPE)
+ {
+ error ("size of array `%s' has non-integer type", name);
+ size = integer_one_node;
+ }
+ if (pedantic && integer_zerop (size))
+ pedwarn ("ANSI C forbids zero-size array `%s'", name);
+ if (TREE_CODE (size) == INTEGER_CST)
+ {
+ constant_expression_warning (size);
+ if (INT_CST_LT (size, integer_zero_node))
+ {
+ error ("size of array `%s' is negative", name);
+ size = integer_one_node;
+ }
+ itype = build_index_type (size_binop (MINUS_EXPR, size,
+ size_one_node));
+ }
+ else
+ {
+ if (pedantic)
+ {
+ if (TREE_CONSTANT (size))
+ pedwarn ("ANSI C forbids array `%s' whose size can't be evaluated", name);
+ else
+ pedwarn ("ANSI C forbids variable-size array `%s'", name);
+ }
+ itype = build_binary_op (MINUS_EXPR, size, integer_one_node,
+ 1);
+ /* Make sure the array size remains visibly nonconstant
+ even if it is (eg) a const variable with known value. */
+ size_varies = 1;
+ itype = variable_size (itype);
+ itype = build_index_type (itype);
+ }
+ }
+
+#if 0 /* This had bad results for pointers to arrays, as in
+ union incomplete (*foo)[4]; */
+ /* Complain about arrays of incomplete types, except in typedefs. */
+
+ if (TYPE_SIZE (type) == 0
+ /* Avoid multiple warnings for nested array types. */
+ && TREE_CODE (type) != ARRAY_TYPE
+ && !(specbits & (1 << (int) RID_TYPEDEF))
+ && !C_TYPE_BEING_DEFINED (type))
+ warning ("array type has incomplete element type");
+#endif
+
+#if 0 /* We shouldn't have a function type here at all!
+ Functions aren't allowed as array elements. */
+ if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
+ && (constp || volatilep))
+ pedwarn ("ANSI C forbids const or volatile function types");
+#endif
+
+ /* Build the array type itself, then merge any constancy or
+ volatility into the target type. We must do it in this order
+ to ensure that the TYPE_MAIN_VARIANT field of the array type
+ is set correctly. */
+
+ type = build_array_type (type, itype);
+ if (constp || volatilep)
+ type = c_build_type_variant (type, constp, volatilep);
+
+#if 0 /* don't clear these; leave them set so that the array type
+ or the variable is itself const or volatile. */
+ constp = 0;
+ volatilep = 0;
+#endif
+
+ if (size_varies)
+ C_TYPE_VARIABLE_SIZE (type) = 1;
+ }
+ else if (TREE_CODE (declarator) == CALL_EXPR)
+ {
+ int extern_ref = (!(specbits & (1 << (int) RID_AUTO))
+ || current_binding_level == global_binding_level);
+ tree arg_types;
+
+ /* Declaring a function type.
+ Make sure we have a valid type for the function to return. */
+ if (type == error_mark_node)
+ continue;
+
+ size_varies = 0;
+
+ /* Warn about some types functions can't return. */
+
+ if (TREE_CODE (type) == FUNCTION_TYPE)
+ {
+ error ("`%s' declared as function returning a function", name);
+ type = integer_type_node;
+ }
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ error ("`%s' declared as function returning an array", name);
+ type = integer_type_node;
+ }
+
+#ifndef TRADITIONAL_RETURN_FLOAT
+ /* Traditionally, declaring return type float means double. */
+
+ if (flag_traditional && TYPE_MAIN_VARIANT (type) == float_type_node)
+ type = double_type_node;
+#endif /* TRADITIONAL_RETURN_FLOAT */
+
+ /* If this is a block level extern, it must live past the end
+ of the function so that we can check it against other extern
+ declarations (IDENTIFIER_LIMBO_VALUE). */
+ if (extern_ref && allocation_temporary_p ())
+ end_temporary_allocation ();
+
+ /* Construct the function type and go to the next
+ inner layer of declarator. */
+
+ arg_types = grokparms (TREE_OPERAND (declarator, 1),
+ funcdef_flag
+ /* Say it's a definition
+ only for the CALL_EXPR
+ closest to the identifier. */
+ && TREE_CODE (TREE_OPERAND (declarator, 0)) == IDENTIFIER_NODE);
+#if 0 /* This seems to be false. We turn off temporary allocation
+ above in this function if -traditional.
+ And this code caused inconsistent results with prototypes:
+ callers would ignore them, and pass arguments wrong. */
+
+ /* Omit the arg types if -traditional, since the arg types
+ and the list links might not be permanent. */
+ type = build_function_type (type,
+ flag_traditional
+ ? NULL_TREE : arg_types);
+#endif
+ type = build_function_type (type, arg_types);
+ declarator = TREE_OPERAND (declarator, 0);
+
+ /* Set the TYPE_CONTEXTs for each tagged type which is local to
+ the formal parameter list of this FUNCTION_TYPE to point to
+ the FUNCTION_TYPE node itself. */
+
+ {
+ register tree link;
+
+ for (link = current_function_parm_tags;
+ link;
+ link = TREE_CHAIN (link))
+ TYPE_CONTEXT (TREE_VALUE (link)) = type;
+ }
+ }
+ else if (TREE_CODE (declarator) == INDIRECT_REF)
+ {
+ /* Merge any constancy or volatility into the target type
+ for the pointer. */
+
+ if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
+ && (constp || volatilep))
+ pedwarn ("ANSI C forbids const or volatile function types");
+ if (constp || volatilep)
+ type = c_build_type_variant (type, constp, volatilep);
+ constp = 0;
+ volatilep = 0;
+ size_varies = 0;
+
+ type = build_pointer_type (type);
+
+ /* Process a list of type modifier keywords
+ (such as const or volatile) that were given inside the `*'. */
+
+ if (TREE_TYPE (declarator))
+ {
+ register tree typemodlist;
+ int erred = 0;
+ for (typemodlist = TREE_TYPE (declarator); typemodlist;
+ typemodlist = TREE_CHAIN (typemodlist))
+ {
+ if (TREE_VALUE (typemodlist) == ridpointers[(int) RID_CONST])
+ constp++;
+ else if (TREE_VALUE (typemodlist) == ridpointers[(int) RID_VOLATILE])
+ volatilep++;
+ else if (!erred)
+ {
+ erred = 1;
+ error ("invalid type modifier within pointer declarator");
+ }
+ }
+ if (constp > 1)
+ pedwarn ("duplicate `const'");
+ if (volatilep > 1)
+ pedwarn ("duplicate `volatile'");
+ }
+
+ declarator = TREE_OPERAND (declarator, 0);
+ }
+ else
+ abort ();
+
+ }
+
+ /* Now TYPE has the actual type. */
+
+ /* If this is declaring a typedef name, return a TYPE_DECL. */
+
+ if (specbits & (1 << (int) RID_TYPEDEF))
+ {
+ tree decl;
+ /* Note that the grammar rejects storage classes
+ in typenames, fields or parameters */
+ if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
+ && (constp || volatilep))
+ pedwarn ("ANSI C forbids const or volatile function types");
+ if (constp || volatilep)
+ type = c_build_type_variant (type, constp, volatilep);
+ pop_obstacks ();
+ decl = build_decl (TYPE_DECL, declarator, type);
+ if ((specbits & (1 << (int) RID_SIGNED))
+ || (typedef_decl && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
+ C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
+ return decl;
+ }
+
+ /* Detect the case of an array type of unspecified size
+ which came, as such, direct from a typedef name.
+ We must copy the type, so that each identifier gets
+ a distinct type, so that each identifier's size can be
+ controlled separately by its own initializer. */
+
+ if (type != 0 && typedef_type != 0
+ && TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (typedef_type)
+ && TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == 0)
+ {
+ type = build_array_type (TREE_TYPE (type), 0);
+ if (size_varies)
+ C_TYPE_VARIABLE_SIZE (type) = 1;
+ }
+
+ /* If this is a type name (such as, in a cast or sizeof),
+ compute the type and return it now. */
+
+ if (decl_context == TYPENAME)
+ {
+ /* Note that the grammar rejects storage classes
+ in typenames, fields or parameters */
+ if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
+ && (constp || volatilep))
+ pedwarn ("ANSI C forbids const or volatile function types");
+ if (constp || volatilep)
+ type = c_build_type_variant (type, constp, volatilep);
+ pop_obstacks ();
+ return type;
+ }
+
+ /* `void' at top level (not within pointer)
+ is allowed only in typedefs or type names.
+ We don't complain about parms either, but that is because
+ a better error message can be made later. */
+
+ if (TYPE_MAIN_VARIANT (type) == void_type_node && decl_context != PARM)
+ {
+ error ("variable or field `%s' declared void",
+ IDENTIFIER_POINTER (declarator));
+ type = integer_type_node;
+ }
+
+ /* Now create the decl, which may be a VAR_DECL, a PARM_DECL
+ or a FUNCTION_DECL, depending on DECL_CONTEXT and TYPE. */
+
+ {
+ register tree decl;
+
+ if (decl_context == PARM)
+ {
+ tree type_as_written = type;
+ tree main_type;
+
+ /* A parameter declared as an array of T is really a pointer to T.
+ One declared as a function is really a pointer to a function. */
+
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ /* Transfer const-ness of array into that of type pointed to. */
+ type = build_pointer_type
+ (c_build_type_variant (TREE_TYPE (type), constp, volatilep));
+ volatilep = constp = 0;
+ size_varies = 0;
+ }
+ else if (TREE_CODE (type) == FUNCTION_TYPE)
+ {
+ if (pedantic && (constp || volatilep))
+ pedwarn ("ANSI C forbids const or volatile function types");
+ type = build_pointer_type (c_build_type_variant (type, constp, volatilep));
+ volatilep = constp = 0;
+ }
+
+ decl = build_decl (PARM_DECL, declarator, type);
+ if (size_varies)
+ C_DECL_VARIABLE_SIZE (decl) = 1;
+
+ /* Compute the type actually passed in the parmlist,
+ for the case where there is no prototype.
+ (For example, shorts and chars are passed as ints.)
+ When there is a prototype, this is overridden later. */
+
+ DECL_ARG_TYPE (decl) = type;
+ main_type = (type == error_mark_node
+ ? error_mark_node
+ : TYPE_MAIN_VARIANT (type));
+ if (main_type == float_type_node)
+ DECL_ARG_TYPE (decl) = double_type_node;
+ /* Don't use TYPE_PRECISION to decide whether to promote,
+ because we should convert short if it's the same size as int,
+ but we should not convert long if it's the same size as int. */
+ else if (TREE_CODE (main_type) != ERROR_MARK
+ && C_PROMOTING_INTEGER_TYPE_P (main_type))
+ {
+ if (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)
+ && TREE_UNSIGNED (type))
+ DECL_ARG_TYPE (decl) = unsigned_type_node;
+ else
+ DECL_ARG_TYPE (decl) = integer_type_node;
+ }
+
+ DECL_ARG_TYPE_AS_WRITTEN (decl) = type_as_written;
+ }
+ else if (decl_context == FIELD)
+ {
+ /* Structure field. It may not be a function. */
+
+ if (TREE_CODE (type) == FUNCTION_TYPE)
+ {
+ error ("field `%s' declared as a function",
+ IDENTIFIER_POINTER (declarator));
+ type = build_pointer_type (type);
+ }
+ else if (TREE_CODE (type) != ERROR_MARK && TYPE_SIZE (type) == 0)
+ {
+ error ("field `%s' has incomplete type",
+ IDENTIFIER_POINTER (declarator));
+ type = error_mark_node;
+ }
+ /* Move type qualifiers down to element of an array. */
+ if (TREE_CODE (type) == ARRAY_TYPE && (constp || volatilep))
+ {
+ type = build_array_type (c_build_type_variant (TREE_TYPE (type),
+ constp, volatilep),
+ TYPE_DOMAIN (type));
+#if 0 /* Leave the field const or volatile as well. */
+ constp = volatilep = 0;
+#endif
+ }
+ decl = build_decl (FIELD_DECL, declarator, type);
+ if (size_varies)
+ C_DECL_VARIABLE_SIZE (decl) = 1;
+ }
+ else if (TREE_CODE (type) == FUNCTION_TYPE)
+ {
+ /* Every function declaration is "external"
+ except for those which are inside a function body
+ in which `auto' is used.
+ That is a case not specified by ANSI C,
+ and we use it for forward declarations for nested functions. */
+ int extern_ref = (!(specbits & (1 << (int) RID_AUTO))
+ || current_binding_level == global_binding_level);
+
+ if (specbits & (1 << (int) RID_AUTO)
+ && (pedantic || current_binding_level == global_binding_level))
+ pedwarn ("invalid storage class for function `%s'",
+ IDENTIFIER_POINTER (declarator));
+ if (specbits & (1 << (int) RID_REGISTER))
+ error ("invalid storage class for function `%s'",
+ IDENTIFIER_POINTER (declarator));
+ /* Function declaration not at top level.
+ Storage classes other than `extern' are not allowed
+ and `extern' makes no difference. */
+ if (current_binding_level != global_binding_level
+ && (specbits & ((1 << (int) RID_STATIC) | (1 << (int) RID_INLINE)))
+ && pedantic)
+ pedwarn ("invalid storage class for function `%s'",
+ IDENTIFIER_POINTER (declarator));
+
+ /* If this is a block level extern, it must live past the end
+ of the function so that we can check it against other
+ extern declarations (IDENTIFIER_LIMBO_VALUE). */
+ if (extern_ref && allocation_temporary_p ())
+ end_temporary_allocation ();
+
+ decl = build_decl (FUNCTION_DECL, declarator, type);
+
+ if (pedantic && (constp || volatilep)
+ && ! DECL_IN_SYSTEM_HEADER (decl))
+ pedwarn ("ANSI C forbids const or volatile functions");
+
+ if (extern_ref)
+ DECL_EXTERNAL (decl) = 1;
+ /* Record absence of global scope for `static' or `auto'. */
+ TREE_PUBLIC (decl)
+ = !(specbits & ((1 << (int) RID_STATIC) | (1 << (int) RID_AUTO)));
+ /* Record presence of `inline', if it is reasonable. */
+ if (inlinep)
+ {
+ tree last = tree_last (TYPE_ARG_TYPES (type));
+
+ if (! strcmp (IDENTIFIER_POINTER (declarator), "main"))
+ warning ("cannot inline function `main'");
+ else if (last && (TYPE_MAIN_VARIANT (TREE_VALUE (last))
+ != void_type_node))
+ warning ("inline declaration ignored for function with `...'");
+ else
+ /* Assume that otherwise the function can be inlined. */
+ DECL_INLINE (decl) = 1;
+
+ if (specbits & (1 << (int) RID_EXTERN))
+ current_extern_inline = 1;
+ }
+ }
+ else
+ {
+ /* It's a variable. */
+ /* An uninitialized decl with `extern' is a reference. */
+ int extern_ref = !initialized && (specbits & (1 << (int) RID_EXTERN));
+
+ /* Move type qualifiers down to element of an array. */
+ if (TREE_CODE (type) == ARRAY_TYPE && (constp || volatilep))
+ {
+ type = build_array_type (c_build_type_variant (TREE_TYPE (type),
+ constp, volatilep),
+ TYPE_DOMAIN (type));
+#if 0 /* Leave the variable const or volatile as well. */
+ constp = volatilep = 0;
+#endif
+ }
+
+ /* If this is a block level extern, it must live past the end
+ of the function so that we can check it against other
+ extern declarations (IDENTIFIER_LIMBO_VALUE). */
+ if (extern_ref && allocation_temporary_p ())
+ end_temporary_allocation ();
+
+ decl = build_decl (VAR_DECL, declarator, type);
+ if (size_varies)
+ C_DECL_VARIABLE_SIZE (decl) = 1;
+
+ if (inlinep)
+ pedwarn_with_decl (decl, "variable `%s' declared `inline'");
+
+ DECL_EXTERNAL (decl) = extern_ref;
+ /* At top level, the presence of a `static' or `register' storage
+ class specifier, or the absence of all storage class specifiers
+ makes this declaration a definition (perhaps tentative). Also,
+ the absence of both `static' and `register' makes it public. */
+ if (current_binding_level == global_binding_level)
+ {
+ TREE_PUBLIC (decl)
+ = !(specbits
+ & ((1 << (int) RID_STATIC) | (1 << (int) RID_REGISTER)));
+ TREE_STATIC (decl) = ! DECL_EXTERNAL (decl);
+ }
+ /* Not at top level, only `static' makes a static definition. */
+ else
+ {
+ TREE_STATIC (decl) = (specbits & (1 << (int) RID_STATIC)) != 0;
+ TREE_PUBLIC (decl) = DECL_EXTERNAL (decl);
+ }
+
+ if (specbits & 1 << (int) RID_ITERATOR)
+ ITERATOR_P (decl) = 1;
+ }
+
+ /* Record `register' declaration for warnings on &
+ and in case doing stupid register allocation. */
+
+ if (specbits & (1 << (int) RID_REGISTER))
+ DECL_REGISTER (decl) = 1;
+
+ /* Record constancy and volatility. */
+
+ if (constp)
+ TREE_READONLY (decl) = 1;
+ if (volatilep)
+ {
+ TREE_SIDE_EFFECTS (decl) = 1;
+ TREE_THIS_VOLATILE (decl) = 1;
+ }
+ /* If a type has volatile components, it should be stored in memory.
+ Otherwise, the fact that those components are volatile
+ will be ignored, and would even crash the compiler. */
+ if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (decl)))
+ mark_addressable (decl);
+
+ pop_obstacks ();
+
+ return decl;
+ }
+}
+
+/* Decode the parameter-list info for a function type or function definition.
+ The argument is the value returned by `get_parm_info' (or made in parse.y
+ if there is an identifier list instead of a parameter decl list).
+ These two functions are separate because when a function returns
+ or receives functions then each is called multiple times but the order
+ of calls is different. The last call to `grokparms' is always the one
+ that contains the formal parameter names of a function definition.
+
+ Store in `last_function_parms' a chain of the decls of parms.
+ Also store in `last_function_parm_tags' a chain of the struct, union,
+ and enum tags declared among the parms.
+
+ Return a list of arg types to use in the FUNCTION_TYPE for this function.
+
+ FUNCDEF_FLAG is nonzero for a function definition, 0 for
+ a mere declaration. A nonempty identifier-list gets an error message
+ when FUNCDEF_FLAG is zero. */
+
+static tree
+grokparms (parms_info, funcdef_flag)
+ tree parms_info;
+ int funcdef_flag;
+{
+ tree first_parm = TREE_CHAIN (parms_info);
+
+ last_function_parms = TREE_PURPOSE (parms_info);
+ last_function_parm_tags = TREE_VALUE (parms_info);
+
+ if (warn_strict_prototypes && first_parm == 0 && !funcdef_flag
+ && !in_system_header)
+ warning ("function declaration isn't a prototype");
+
+ if (first_parm != 0
+ && TREE_CODE (TREE_VALUE (first_parm)) == IDENTIFIER_NODE)
+ {
+ if (! funcdef_flag)
+ pedwarn ("parameter names (without types) in function declaration");
+
+ last_function_parms = first_parm;
+ return 0;
+ }
+ else
+ {
+ tree parm;
+ tree typelt;
+ /* We no longer test FUNCDEF_FLAG.
+ If the arg types are incomplete in a declaration,
+ they must include undefined tags.
+ These tags can never be defined in the scope of the declaration,
+ so the types can never be completed,
+ and no call can be compiled successfully. */
+#if 0
+ /* In a fcn definition, arg types must be complete. */
+ if (funcdef_flag)
+#endif
+ for (parm = last_function_parms, typelt = first_parm;
+ parm;
+ parm = TREE_CHAIN (parm))
+ /* Skip over any enumeration constants declared here. */
+ if (TREE_CODE (parm) == PARM_DECL)
+ {
+ /* Barf if the parameter itself has an incomplete type. */
+ tree type = TREE_VALUE (typelt);
+ if (TYPE_SIZE (type) == 0)
+ {
+ if (funcdef_flag && DECL_NAME (parm) != 0)
+ error ("parameter `%s' has incomplete type",
+ IDENTIFIER_POINTER (DECL_NAME (parm)));
+ else
+ warning ("parameter has incomplete type");
+ if (funcdef_flag)
+ {
+ TREE_VALUE (typelt) = error_mark_node;
+ TREE_TYPE (parm) = error_mark_node;
+ }
+ }
+#if 0 /* This has been replaced by parm_tags_warning
+ which uses a more accurate criterion for what to warn about. */
+ else
+ {
+ /* Now warn if is a pointer to an incomplete type. */
+ while (TREE_CODE (type) == POINTER_TYPE
+ || TREE_CODE (type) == REFERENCE_TYPE)
+ type = TREE_TYPE (type);
+ type = TYPE_MAIN_VARIANT (type);
+ if (TYPE_SIZE (type) == 0)
+ {
+ if (DECL_NAME (parm) != 0)
+ warning ("parameter `%s' points to incomplete type",
+ IDENTIFIER_POINTER (DECL_NAME (parm)));
+ else
+ warning ("parameter points to incomplete type");
+ }
+ }
+#endif
+ typelt = TREE_CHAIN (typelt);
+ }
+
+ /* Allocate the list of types the way we allocate a type. */
+ if (first_parm && ! TREE_PERMANENT (first_parm))
+ {
+ /* Construct a copy of the list of types
+ on the saveable obstack. */
+ tree result = NULL;
+ for (typelt = first_parm; typelt; typelt = TREE_CHAIN (typelt))
+ result = saveable_tree_cons (NULL_TREE, TREE_VALUE (typelt),
+ result);
+ return nreverse (result);
+ }
+ else
+ /* The list we have is permanent already. */
+ return first_parm;
+ }
+}
+
+
+/* Return a tree_list node with info on a parameter list just parsed.
+ The TREE_PURPOSE is a chain of decls of those parms.
+ The TREE_VALUE is a list of structure, union and enum tags defined.
+ The TREE_CHAIN is a list of argument types to go in the FUNCTION_TYPE.
+ This tree_list node is later fed to `grokparms'.
+
+ VOID_AT_END nonzero means append `void' to the end of the type-list.
+ Zero means the parmlist ended with an ellipsis so don't append `void'. */
+
+tree
+get_parm_info (void_at_end)
+ int void_at_end;
+{
+ register tree decl, t;
+ register tree types = 0;
+ int erred = 0;
+ tree tags = gettags ();
+ tree parms = getdecls ();
+ tree new_parms = 0;
+ tree order = current_binding_level->parm_order;
+
+ /* Just `void' (and no ellipsis) is special. There are really no parms. */
+ if (void_at_end && parms != 0
+ && TREE_CHAIN (parms) == 0
+ && TYPE_MAIN_VARIANT (TREE_TYPE (parms)) == void_type_node
+ && DECL_NAME (parms) == 0)
+ {
+ parms = NULL_TREE;
+ storedecls (NULL_TREE);
+ return saveable_tree_cons (NULL_TREE, NULL_TREE,
+ saveable_tree_cons (NULL_TREE, void_type_node, NULL_TREE));
+ }
+
+ /* Extract enumerator values and other non-parms declared with the parms.
+ Likewise any forward parm decls that didn't have real parm decls. */
+ for (decl = parms; decl; )
+ {
+ tree next = TREE_CHAIN (decl);
+
+ if (TREE_CODE (decl) != PARM_DECL)
+ {
+ TREE_CHAIN (decl) = new_parms;
+ new_parms = decl;
+ }
+ else if (TREE_ASM_WRITTEN (decl))
+ {
+ error_with_decl (decl, "parameter `%s' has just a forward declaration");
+ TREE_CHAIN (decl) = new_parms;
+ new_parms = decl;
+ }
+ decl = next;
+ }
+
+ /* Put the parm decls back in the order they were in in the parm list. */
+ for (t = order; t; t = TREE_CHAIN (t))
+ {
+ if (TREE_CHAIN (t))
+ TREE_CHAIN (TREE_VALUE (t)) = TREE_VALUE (TREE_CHAIN (t));
+ else
+ TREE_CHAIN (TREE_VALUE (t)) = 0;
+ }
+
+ new_parms = chainon (order ? nreverse (TREE_VALUE (order)) : 0,
+ new_parms);
+
+ /* Store the parmlist in the binding level since the old one
+ is no longer a valid list. (We have changed the chain pointers.) */
+ storedecls (new_parms);
+
+ for (decl = new_parms; decl; decl = TREE_CHAIN (decl))
+ /* There may also be declarations for enumerators if an enumeration
+ type is declared among the parms. Ignore them here. */
+ if (TREE_CODE (decl) == PARM_DECL)
+ {
+ /* Since there is a prototype,
+ args are passed in their declared types. */
+ tree type = TREE_TYPE (decl);
+ DECL_ARG_TYPE (decl) = type;
+#ifdef PROMOTE_PROTOTYPES
+ if (TREE_CODE (type) == INTEGER_TYPE
+ && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
+ DECL_ARG_TYPE (decl) = integer_type_node;
+#endif
+
+ types = saveable_tree_cons (NULL_TREE, TREE_TYPE (decl), types);
+ if (TYPE_MAIN_VARIANT (TREE_VALUE (types)) == void_type_node && ! erred
+ && DECL_NAME (decl) == 0)
+ {
+ error ("`void' in parameter list must be the entire list");
+ erred = 1;
+ }
+ }
+
+ if (void_at_end)
+ return saveable_tree_cons (new_parms, tags,
+ nreverse (saveable_tree_cons (NULL_TREE, void_type_node, types)));
+
+ return saveable_tree_cons (new_parms, tags, nreverse (types));
+}
+
+/* At end of parameter list, warn about any struct, union or enum tags
+ defined within. Do so because these types cannot ever become complete. */
+
+void
+parmlist_tags_warning ()
+{
+ tree elt;
+ static int already;
+
+ for (elt = current_binding_level->tags; elt; elt = TREE_CHAIN (elt))
+ {
+ enum tree_code code = TREE_CODE (TREE_VALUE (elt));
+ /* An anonymous union parm type is meaningful as a GNU extension.
+ So don't warn for that. */
+ if (code == UNION_TYPE && !pedantic)
+ continue;
+ if (TREE_PURPOSE (elt) != 0)
+ warning ("`%s %s' declared inside parameter list",
+ (code == RECORD_TYPE ? "struct"
+ : code == UNION_TYPE ? "union"
+ : "enum"),
+ IDENTIFIER_POINTER (TREE_PURPOSE (elt)));
+ else
+ warning ("anonymous %s declared inside parameter list",
+ (code == RECORD_TYPE ? "struct"
+ : code == UNION_TYPE ? "union"
+ : "enum"));
+
+ if (! already)
+ {
+ warning ("its scope is only this definition or declaration,");
+ warning ("which is probably not what you want.");
+ already = 1;
+ }
+ }
+}
+
+/* Get the struct, enum or union (CODE says which) with tag NAME.
+ Define the tag as a forward-reference if it is not defined. */
+
+tree
+xref_tag (code, name)
+ enum tree_code code;
+ tree name;
+{
+ int temporary = allocation_temporary_p ();
+
+ /* If a cross reference is requested, look up the type
+ already defined for this tag and return it. */
+
+ register tree ref = lookup_tag (code, name, current_binding_level, 0);
+ /* Even if this is the wrong type of tag, return what we found.
+ There will be an error message anyway, from pending_xref_error.
+ If we create an empty xref just for an invalid use of the type,
+ the main result is to create lots of superfluous error messages. */
+ if (ref)
+ return ref;
+
+ push_obstacks_nochange ();
+
+ if (current_binding_level == global_binding_level && temporary)
+ end_temporary_allocation ();
+
+ /* If no such tag is yet defined, create a forward-reference node
+ and record it as the "definition".
+ When a real declaration of this type is found,
+ the forward-reference will be altered into a real type. */
+
+ ref = make_node (code);
+ if (code == ENUMERAL_TYPE)
+ {
+ /* (In ANSI, Enums can be referred to only if already defined.) */
+ if (pedantic)
+ pedwarn ("ANSI C forbids forward references to `enum' types");
+ /* Give the type a default layout like unsigned int
+ to avoid crashing if it does not get defined. */
+ TYPE_MODE (ref) = TYPE_MODE (unsigned_type_node);
+ TYPE_ALIGN (ref) = TYPE_ALIGN (unsigned_type_node);
+ TREE_UNSIGNED (ref) = 1;
+ TYPE_PRECISION (ref) = TYPE_PRECISION (unsigned_type_node);
+ TYPE_MIN_VALUE (ref) = TYPE_MIN_VALUE (unsigned_type_node);
+ TYPE_MAX_VALUE (ref) = TYPE_MAX_VALUE (unsigned_type_node);
+ }
+
+ pushtag (name, ref);
+
+ pop_obstacks ();
+
+ return ref;
+}
+
+/* Make sure that the tag NAME is defined *in the current binding level*
+ at least as a forward reference.
+ CODE says which kind of tag NAME ought to be.
+
+ We also do a push_obstacks_nochange
+ whose matching pop is in finish_struct. */
+
+tree
+start_struct (code, name)
+ enum tree_code code;
+ tree name;
+{
+ /* If there is already a tag defined at this binding level
+ (as a forward reference), just return it. */
+
+ register tree ref = 0;
+
+ push_obstacks_nochange ();
+ if (current_binding_level == global_binding_level)
+ end_temporary_allocation ();
+
+ if (name != 0)
+ ref = lookup_tag (code, name, current_binding_level, 1);
+ if (ref && TREE_CODE (ref) == code)
+ {
+ C_TYPE_BEING_DEFINED (ref) = 1;
+ if (TYPE_FIELDS (ref))
+ error ((code == UNION_TYPE ? "redefinition of `union %s'"
+ : "redefinition of `struct %s'"),
+ IDENTIFIER_POINTER (name));
+
+ return ref;
+ }
+
+ /* Otherwise create a forward-reference just so the tag is in scope. */
+
+ ref = make_node (code);
+ pushtag (name, ref);
+ C_TYPE_BEING_DEFINED (ref) = 1;
+ return ref;
+}
+
+/* Process the specs, declarator (NULL if omitted) and width (NULL if omitted)
+ of a structure component, returning a FIELD_DECL node.
+ WIDTH is non-NULL for bit fields only, and is an INTEGER_CST node.
+
+ This is done during the parsing of the struct declaration.
+ The FIELD_DECL nodes are chained together and the lot of them
+ are ultimately passed to `build_struct' to make the RECORD_TYPE node. */
+
+tree
+grokfield (filename, line, declarator, declspecs, width)
+ char *filename;
+ int line;
+ tree declarator, declspecs, width;
+{
+ tree value;
+
+ /* The corresponding pop_obstacks is in finish_decl. */
+ push_obstacks_nochange ();
+
+ value = grokdeclarator (declarator, declspecs, width ? BITFIELD : FIELD, 0);
+
+ finish_decl (value, NULL_TREE, NULL_TREE);
+ DECL_INITIAL (value) = width;
+
+ maybe_objc_check_decl (value);
+ return value;
+}
+
+/* Function to help qsort sort FIELD_DECLs by name order. */
+
+static int
+field_decl_cmp (x, y)
+ tree *x, *y;
+{
+ return (long)DECL_NAME (*x) - (long)DECL_NAME (*y);
+}
+
+/* Fill in the fields of a RECORD_TYPE or UNION_TYPE node, T.
+ FIELDLIST is a chain of FIELD_DECL nodes for the fields.
+
+ We also do a pop_obstacks to match the push in start_struct. */
+
+tree
+finish_struct (t, fieldlist)
+ register tree t, fieldlist;
+{
+ register tree x;
+ int old_momentary;
+ int toplevel = global_binding_level == current_binding_level;
+
+ /* If this type was previously laid out as a forward reference,
+ make sure we lay it out again. */
+
+ TYPE_SIZE (t) = 0;
+
+ /* Nameless union parm types are useful as GCC extension. */
+ if (! (TREE_CODE (t) == UNION_TYPE && TYPE_NAME (t) == 0) && !pedantic)
+ /* Otherwise, warn about any struct or union def. in parmlist. */
+ if (in_parm_level_p ())
+ {
+ if (pedantic)
+ pedwarn ((TREE_CODE (t) == UNION_TYPE ? "union defined inside parms"
+ : "structure defined inside parms"));
+ else if (! flag_traditional)
+ warning ((TREE_CODE (t) == UNION_TYPE ? "union defined inside parms"
+ : "structure defined inside parms"));
+ }
+
+ old_momentary = suspend_momentary ();
+
+ if (fieldlist == 0 && pedantic)
+ pedwarn ((TREE_CODE (t) == UNION_TYPE ? "union has no members"
+ : "structure has no members"));
+
+ /* Install struct as DECL_CONTEXT of each field decl.
+ Also process specified field sizes.
+ Set DECL_FIELD_SIZE to the specified size, or 0 if none specified.
+ The specified size is found in the DECL_INITIAL.
+ Store 0 there, except for ": 0" fields (so we can find them
+ and delete them, below). */
+
+ for (x = fieldlist; x; x = TREE_CHAIN (x))
+ {
+ DECL_CONTEXT (x) = t;
+ DECL_FIELD_SIZE (x) = 0;
+
+ /* If any field is const, the structure type is pseudo-const. */
+ if (TREE_READONLY (x))
+ C_TYPE_FIELDS_READONLY (t) = 1;
+ else
+ {
+ /* A field that is pseudo-const makes the structure likewise. */
+ tree t1 = TREE_TYPE (x);
+ while (TREE_CODE (t1) == ARRAY_TYPE)
+ t1 = TREE_TYPE (t1);
+ if ((TREE_CODE (t1) == RECORD_TYPE || TREE_CODE (t1) == UNION_TYPE)
+ && C_TYPE_FIELDS_READONLY (t1))
+ C_TYPE_FIELDS_READONLY (t) = 1;
+ }
+
+ /* Any field that is volatile means variables of this type must be
+ treated in some ways as volatile. */
+ if (TREE_THIS_VOLATILE (x))
+ C_TYPE_FIELDS_VOLATILE (t) = 1;
+
+ /* Any field of nominal variable size implies structure is too. */
+ if (C_DECL_VARIABLE_SIZE (x))
+ C_TYPE_VARIABLE_SIZE (t) = 1;
+
+ /* Detect invalid nested redefinition. */
+ if (TREE_TYPE (x) == t)
+ error ("nested redefinition of `%s'",
+ IDENTIFIER_POINTER (TYPE_NAME (t)));
+
+ /* Detect invalid bit-field size. */
+ if (DECL_INITIAL (x))
+ STRIP_NOPS (DECL_INITIAL (x));
+ if (DECL_INITIAL (x))
+ {
+ if (TREE_CODE (DECL_INITIAL (x)) == INTEGER_CST)
+ constant_expression_warning (DECL_INITIAL (x));
+ else
+ {
+ error_with_decl (x, "bit-field `%s' width not an integer constant");
+ DECL_INITIAL (x) = NULL;
+ }
+ }
+
+ /* Detect invalid bit-field type. */
+ if (DECL_INITIAL (x)
+ && TREE_CODE (TREE_TYPE (x)) != INTEGER_TYPE
+ && TREE_CODE (TREE_TYPE (x)) != ENUMERAL_TYPE)
+ {
+ error_with_decl (x, "bit-field `%s' has invalid type");
+ DECL_INITIAL (x) = NULL;
+ }
+ if (DECL_INITIAL (x) && pedantic
+ && TYPE_MAIN_VARIANT (TREE_TYPE (x)) != integer_type_node
+ && TYPE_MAIN_VARIANT (TREE_TYPE (x)) != unsigned_type_node)
+ pedwarn_with_decl (x, "bit-field `%s' type invalid in ANSI C");
+
+ /* Detect and ignore out of range field width. */
+ if (DECL_INITIAL (x))
+ {
+ unsigned HOST_WIDE_INT width = TREE_INT_CST_LOW (DECL_INITIAL (x));
+
+ if (tree_int_cst_lt (DECL_INITIAL (x), integer_zero_node))
+ {
+ DECL_INITIAL (x) = NULL;
+ error_with_decl (x, "negative width in bit-field `%s'");
+ }
+ else if (TREE_INT_CST_HIGH (DECL_INITIAL (x)) != 0
+ || width > TYPE_PRECISION (TREE_TYPE (x)))
+ {
+ DECL_INITIAL (x) = NULL;
+ pedwarn_with_decl (x, "width of `%s' exceeds its type");
+ }
+ else if (width == 0 && DECL_NAME (x) != 0)
+ {
+ error_with_decl (x, "zero width for bit-field `%s'");
+ DECL_INITIAL (x) = NULL;
+ }
+ }
+
+ /* Process valid field width. */
+ if (DECL_INITIAL (x))
+ {
+ register int width = TREE_INT_CST_LOW (DECL_INITIAL (x));
+
+ DECL_FIELD_SIZE (x) = width;
+ DECL_BIT_FIELD (x) = 1;
+ DECL_INITIAL (x) = NULL;
+
+ if (width == 0)
+ {
+ /* field size 0 => force desired amount of alignment. */
+#ifdef EMPTY_FIELD_BOUNDARY
+ DECL_ALIGN (x) = MAX (DECL_ALIGN (x), EMPTY_FIELD_BOUNDARY);
+#endif
+#ifdef PCC_BITFIELD_TYPE_MATTERS
+ DECL_ALIGN (x) = MAX (DECL_ALIGN (x),
+ TYPE_ALIGN (TREE_TYPE (x)));
+#endif
+ }
+ }
+ else
+ {
+ int min_align = (DECL_PACKED (x) ? BITS_PER_UNIT
+ : TYPE_ALIGN (TREE_TYPE (x)));
+ /* Non-bit-fields are aligned for their type, except packed
+ fields which require only BITS_PER_UNIT alignment. */
+ DECL_ALIGN (x) = MAX (DECL_ALIGN (x), min_align);
+ }
+ }
+
+ /* Now DECL_INITIAL is null on all members. */
+
+ /* Delete all duplicate fields from the fieldlist */
+ for (x = fieldlist; x && TREE_CHAIN (x);)
+ /* Anonymous fields aren't duplicates. */
+ if (DECL_NAME (TREE_CHAIN (x)) == 0)
+ x = TREE_CHAIN (x);
+ else
+ {
+ register tree y = fieldlist;
+
+ while (1)
+ {
+ if (DECL_NAME (y) == DECL_NAME (TREE_CHAIN (x)))
+ break;
+ if (y == x)
+ break;
+ y = TREE_CHAIN (y);
+ }
+ if (DECL_NAME (y) == DECL_NAME (TREE_CHAIN (x)))
+ {
+ error_with_decl (TREE_CHAIN (x), "duplicate member `%s'");
+ TREE_CHAIN (x) = TREE_CHAIN (TREE_CHAIN (x));
+ }
+ else x = TREE_CHAIN (x);
+ }
+
+ /* Now we have the nearly final fieldlist. Record it,
+ then lay out the structure or union (including the fields). */
+
+ TYPE_FIELDS (t) = fieldlist;
+
+ layout_type (t);
+
+ /* Delete all zero-width bit-fields from the front of the fieldlist */
+ while (fieldlist
+ && DECL_INITIAL (fieldlist))
+ fieldlist = TREE_CHAIN (fieldlist);
+ /* Delete all such members from the rest of the fieldlist */
+ for (x = fieldlist; x;)
+ {
+ if (TREE_CHAIN (x) && DECL_INITIAL (TREE_CHAIN (x)))
+ TREE_CHAIN (x) = TREE_CHAIN (TREE_CHAIN (x));
+ else x = TREE_CHAIN (x);
+ }
+
+ /* Now we have the truly final field list.
+ Store it in this type and in the variants. */
+
+ TYPE_FIELDS (t) = fieldlist;
+
+ /* If there are lots of fields, sort so we can look through them fast.
+ We arbitrarily consider 16 or more elts to be "a lot". */
+ {
+ int len = 0;
+
+ for (x = fieldlist; x; x = TREE_CHAIN (x))
+ {
+ if (len > 15)
+ break;
+ len += 1;
+ }
+ if (len > 15)
+ {
+ tree *field_array;
+ char *space;
+
+ len += list_length (x);
+ /* Use the same allocation policy here that make_node uses, to
+ ensure that this lives as long as the rest of the struct decl.
+ All decls in an inline function need to be saved. */
+ if (allocation_temporary_p ())
+ space = savealloc (sizeof (struct lang_type) + len * sizeof (tree));
+ else
+ space = oballoc (sizeof (struct lang_type) + len * sizeof (tree));
+
+ TYPE_LANG_SPECIFIC (t) = (struct lang_type *) space;
+ TYPE_LANG_SPECIFIC (t)->len = len;
+
+ field_array = &TYPE_LANG_SPECIFIC (t)->elts[0];
+ len = 0;
+ for (x = fieldlist; x; x = TREE_CHAIN (x))
+ field_array[len++] = x;
+
+ qsort (field_array, len, sizeof (tree), field_decl_cmp);
+ }
+ }
+
+ for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
+ {
+ TYPE_FIELDS (x) = TYPE_FIELDS (t);
+ TYPE_LANG_SPECIFIC (x) = TYPE_LANG_SPECIFIC (t);
+ TYPE_ALIGN (x) = TYPE_ALIGN (t);
+ }
+
+ /* Promote each bit-field's type to int if it is narrower than that. */
+ for (x = fieldlist; x; x = TREE_CHAIN (x))
+ if (DECL_BIT_FIELD (x)
+ && (C_PROMOTING_INTEGER_TYPE_P (TREE_TYPE (x))
+ || DECL_FIELD_SIZE (x) < TYPE_PRECISION (integer_type_node)))
+ {
+ tree type = TREE_TYPE (x);
+
+ /* Preserve unsignedness if traditional
+ or if not really getting any wider. */
+ if (TREE_UNSIGNED (type)
+ && (flag_traditional
+ ||
+ (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)
+ &&
+ DECL_FIELD_SIZE (x) == TYPE_PRECISION (integer_type_node))))
+ TREE_TYPE (x) = unsigned_type_node;
+ else
+ TREE_TYPE (x) = integer_type_node;
+ }
+
+ /* If this structure or union completes the type of any previous
+ variable declaration, lay it out and output its rtl. */
+
+ if (current_binding_level->n_incomplete != 0)
+ {
+ tree decl;
+ for (decl = current_binding_level->names; decl; decl = TREE_CHAIN (decl))
+ {
+ if (TREE_TYPE (decl) == t
+ && TREE_CODE (decl) != TYPE_DECL)
+ {
+ layout_decl (decl, 0);
+ /* This is a no-op in c-lang.c or something real in objc-actions.c. */
+ maybe_objc_check_decl (decl);
+ rest_of_decl_compilation (decl, NULL_PTR, toplevel, 0);
+ if (! toplevel)
+ expand_decl (decl);
+ --current_binding_level->n_incomplete;
+ }
+ else if (TYPE_SIZE (TREE_TYPE (decl)) == 0
+ && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
+ {
+ tree element = TREE_TYPE (decl);
+ while (TREE_CODE (element) == ARRAY_TYPE)
+ element = TREE_TYPE (element);
+ if (element == t)
+ layout_array_type (TREE_TYPE (decl));
+ }
+ }
+ }
+
+ resume_momentary (old_momentary);
+
+ /* Finish debugging output for this type. */
+ rest_of_type_compilation (t, toplevel);
+
+ /* The matching push is in start_struct. */
+ pop_obstacks ();
+
+ return t;
+}
+
+/* Lay out the type T, and its element type, and so on. */
+
+static void
+layout_array_type (t)
+ tree t;
+{
+ if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
+ layout_array_type (TREE_TYPE (t));
+ layout_type (t);
+}
+
+/* Begin compiling the definition of an enumeration type.
+ NAME is its name (or null if anonymous).
+ Returns the type object, as yet incomplete.
+ Also records info about it so that build_enumerator
+ may be used to declare the individual values as they are read. */
+
+tree
+start_enum (name)
+ tree name;
+{
+ register tree enumtype = 0;
+
+ /* If this is the real definition for a previous forward reference,
+ fill in the contents in the same object that used to be the
+ forward reference. */
+
+ if (name != 0)
+ enumtype = lookup_tag (ENUMERAL_TYPE, name, current_binding_level, 1);
+
+ /* The corresponding pop_obstacks is in finish_enum. */
+ push_obstacks_nochange ();
+ /* If these symbols and types are global, make them permanent. */
+ if (current_binding_level == global_binding_level)
+ end_temporary_allocation ();
+
+ if (enumtype == 0 || TREE_CODE (enumtype) != ENUMERAL_TYPE)
+ {
+ enumtype = make_node (ENUMERAL_TYPE);
+ pushtag (name, enumtype);
+ }
+
+ C_TYPE_BEING_DEFINED (enumtype) = 1;
+
+ if (TYPE_VALUES (enumtype) != 0)
+ {
+ /* This enum is a named one that has been declared already. */
+ error ("redeclaration of `enum %s'", IDENTIFIER_POINTER (name));
+
+ /* Completely replace its old definition.
+ The old enumerators remain defined, however. */
+ TYPE_VALUES (enumtype) = 0;
+ }
+
+ enum_next_value = integer_zero_node;
+ enum_overflow = 0;
+
+ return enumtype;
+}
+
+/* After processing and defining all the values of an enumeration type,
+ install their decls in the enumeration type and finish it off.
+ ENUMTYPE is the type object and VALUES a list of decl-value pairs.
+ Returns ENUMTYPE. */
+
+tree
+finish_enum (enumtype, values)
+ register tree enumtype, values;
+{
+ register tree pair, tem;
+ tree minnode = 0, maxnode = 0;
+ register HOST_WIDE_INT maxvalue = 0;
+ register HOST_WIDE_INT minvalue = 0;
+ register int i;
+ unsigned precision = 0;
+ int toplevel = global_binding_level == current_binding_level;
+ int temporary = allocation_temporary_p ();
+
+ if (in_parm_level_p ())
+ warning ("enum defined inside parms");
+
+ /* Calculate the maximum value of any enumerator in this type. */
+
+ for (pair = values; pair; pair = TREE_CHAIN (pair))
+ {
+ tree value = TREE_VALUE (pair);
+ if (pair == values)
+ minnode = maxnode = TREE_VALUE (pair);
+ else
+ {
+ if (tree_int_cst_lt (maxnode, value))
+ maxnode = value;
+ if (tree_int_cst_lt (value, minnode))
+ minnode = value;
+ }
+ }
+
+ TYPE_MIN_VALUE (enumtype) = minnode;
+ TYPE_MAX_VALUE (enumtype) = maxnode;
+
+ /* Determine the precision this type needs. */
+
+ if (TREE_INT_CST_HIGH (minnode) >= 0
+ ? tree_int_cst_lt (TYPE_MAX_VALUE (unsigned_type_node), maxnode)
+ : (tree_int_cst_lt (minnode, TYPE_MIN_VALUE (integer_type_node))
+ || tree_int_cst_lt (TYPE_MAX_VALUE (integer_type_node), maxnode)))
+ precision = TYPE_PRECISION (long_long_integer_type_node);
+ else
+ {
+ maxvalue = TREE_INT_CST_LOW (maxnode);
+ minvalue = TREE_INT_CST_LOW (minnode);
+
+ if (maxvalue > 0)
+ precision = floor_log2 (maxvalue) + 1;
+ if (minvalue < 0)
+ {
+ /* Compute number of bits to represent magnitude of a negative value.
+ Add one to MINVALUE since range of negative numbers
+ includes the power of two. */
+ unsigned negprecision = floor_log2 (-minvalue - 1) + 1;
+ if (negprecision > precision)
+ precision = negprecision;
+ precision += 1; /* room for sign bit */
+ }
+
+ if (!precision)
+ precision = 1;
+ }
+
+ if (flag_short_enums || precision > TYPE_PRECISION (integer_type_node))
+ /* Use the width of the narrowest normal C type which is wide enough. */
+ TYPE_PRECISION (enumtype) = TYPE_PRECISION (type_for_size (precision, 1));
+ else
+ TYPE_PRECISION (enumtype) = TYPE_PRECISION (integer_type_node);
+
+ TYPE_SIZE (enumtype) = 0;
+ layout_type (enumtype);
+
+ /* An enum can have some negative values; then it is signed. */
+ TREE_UNSIGNED (enumtype) = ! tree_int_cst_lt (minnode, integer_zero_node);
+
+ /* If the enumerators might not fit in an int, change their type now. */
+ /* It seems more useful in the debugger to leave these as int
+ unless the enumerator is wider than int. */
+ if (TYPE_PRECISION (enumtype) <= TYPE_PRECISION (integer_type_node))
+ for (pair = values; pair; pair = TREE_CHAIN (pair))
+ {
+ TREE_TYPE (TREE_PURPOSE (pair)) = enumtype;
+ DECL_SIZE (TREE_PURPOSE (pair)) = TYPE_SIZE (enumtype);
+ if (TREE_CODE (TREE_PURPOSE (pair)) != FUNCTION_DECL)
+ DECL_ALIGN (TREE_PURPOSE (pair)) = TYPE_ALIGN (enumtype);
+ }
+
+ /* Replace the decl nodes in VALUES with their names. */
+ for (pair = values; pair; pair = TREE_CHAIN (pair))
+ TREE_PURPOSE (pair) = DECL_NAME (TREE_PURPOSE (pair));
+
+ TYPE_VALUES (enumtype) = values;
+
+ /* Fix up all variant types of this enum type. */
+ for (tem = TYPE_MAIN_VARIANT (enumtype); tem; tem = TYPE_NEXT_VARIANT (tem))
+ {
+ TYPE_VALUES (tem) = TYPE_VALUES (enumtype);
+ TYPE_MIN_VALUE (tem) = TYPE_MIN_VALUE (enumtype);
+ TYPE_MAX_VALUE (tem) = TYPE_MAX_VALUE (enumtype);
+ TYPE_SIZE (tem) = TYPE_SIZE (enumtype);
+ TYPE_MODE (tem) = TYPE_MODE (enumtype);
+ TYPE_PRECISION (tem) = TYPE_PRECISION (enumtype);
+ TYPE_ALIGN (tem) = TYPE_ALIGN (enumtype);
+ TREE_UNSIGNED (tem) = TREE_UNSIGNED (enumtype);
+ }
+
+ /* Finish debugging output for this type. */
+ rest_of_type_compilation (enumtype, toplevel);
+
+ /* This matches a push in start_enum. */
+ pop_obstacks ();
+
+ return enumtype;
+}
+
+/* Build and install a CONST_DECL for one value of the
+ current enumeration type (one that was begun with start_enum).
+ Return a tree-list containing the CONST_DECL and its value.
+ Assignment of sequential values by default is handled here. */
+
+tree
+build_enumerator (name, value)
+ tree name, value;
+{
+ register tree decl;
+
+ /* Validate and default VALUE. */
+
+ /* Remove no-op casts from the value. */
+ if (value)
+ STRIP_TYPE_NOPS (value);
+
+ if (value != 0)
+ {
+ if (TREE_CODE (value) == INTEGER_CST)
+ constant_expression_warning (value);
+ else
+ {
+ error ("enumerator value for `%s' not integer constant",
+ IDENTIFIER_POINTER (name));
+ value = 0;
+ }
+ }
+
+ /* Default based on previous value. */
+ /* It should no longer be possible to have NON_LVALUE_EXPR
+ in the default. */
+ if (value == 0)
+ {
+ value = enum_next_value;
+ if (enum_overflow)
+ error ("overflow in enumeration values");
+ }
+
+ if (pedantic && ! int_fits_type_p (value, integer_type_node))
+ {
+ pedwarn ("ANSI C restricts enumerator values to range of `int'");
+ value = integer_zero_node;
+ }
+
+ /* Set basis for default for next value. */
+ enum_next_value = build_binary_op (PLUS_EXPR, value, integer_one_node, 0);
+ enum_overflow = tree_int_cst_lt (enum_next_value, value);
+
+ /* Now create a declaration for the enum value name. */
+
+ decl = build_decl (CONST_DECL, name, integer_type_node);
+ DECL_INITIAL (decl) = value;
+ TREE_TYPE (value) = integer_type_node;
+ pushdecl (decl);
+
+ return saveable_tree_cons (decl, value, NULL_TREE);
+}
+
+/* Create the FUNCTION_DECL for a function definition.
+ DECLSPECS and DECLARATOR are the parts of the declaration;
+ they describe the function's name and the type it returns,
+ but twisted together in a fashion that parallels the syntax of C.
+
+ This function creates a binding context for the function body
+ as well as setting up the FUNCTION_DECL in current_function_decl.
+
+ Returns 1 on success. If the DECLARATOR is not suitable for a function
+ (it defines a datum instead), we return 0, which tells
+ yyparse to report a parse error.
+
+ NESTED is nonzero for a function nested within another function. */
+
+int
+start_function (declspecs, declarator, nested)
+ tree declarator, declspecs;
+ int nested;
+{
+ tree decl1, old_decl;
+ tree restype;
+
+ current_function_returns_value = 0; /* Assume, until we see it does. */
+ current_function_returns_null = 0;
+ warn_about_return_type = 0;
+ current_extern_inline = 0;
+ c_function_varargs = 0;
+ named_labels = 0;
+ shadowed_labels = 0;
+
+ decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1);
+
+ /* If the declarator is not suitable for a function definition,
+ cause a syntax error. */
+ if (decl1 == 0)
+ return 0;
+
+ announce_function (decl1);
+
+ if (TYPE_SIZE (TREE_TYPE (TREE_TYPE (decl1))) == 0)
+ {
+ error ("return-type is an incomplete type");
+ /* Make it return void instead. */
+ TREE_TYPE (decl1)
+ = build_function_type (void_type_node,
+ TYPE_ARG_TYPES (TREE_TYPE (decl1)));
+ }
+
+ if (warn_about_return_type)
+ warning ("return-type defaults to `int'");
+
+ /* Save the parm names or decls from this function's declarator
+ where store_parm_decls will find them. */
+ current_function_parms = last_function_parms;
+ current_function_parm_tags = last_function_parm_tags;
+
+ /* Make the init_value nonzero so pushdecl knows this is not tentative.
+ error_mark_node is replaced below (in poplevel) with the BLOCK. */
+ DECL_INITIAL (decl1) = error_mark_node;
+
+ /* If this definition isn't a prototype and we had a prototype declaration
+ before, copy the arg type info from that prototype.
+ But not if what we had before was a builtin function. */
+ old_decl = lookup_name_current_level (DECL_NAME (decl1));
+ if (old_decl != 0 && TREE_CODE (TREE_TYPE (old_decl)) == FUNCTION_TYPE
+ && !DECL_BUILT_IN (old_decl)
+ && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1)))
+ == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (old_decl))))
+ && TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0)
+ {
+ TREE_TYPE (decl1) = TREE_TYPE (old_decl);
+ current_function_prototype_file = DECL_SOURCE_FILE (old_decl);
+ current_function_prototype_line = DECL_SOURCE_LINE (old_decl);
+ }
+
+ /* Optionally warn of old-fashioned def with no previous prototype. */
+ if (warn_strict_prototypes
+ && TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0
+ && !(old_decl != 0 && TYPE_ARG_TYPES (TREE_TYPE (old_decl)) != 0))
+ warning ("function declaration isn't a prototype");
+ /* Optionally warn of any global def with no previous prototype. */
+ else if (warn_missing_prototypes
+ && TREE_PUBLIC (decl1)
+ && !(old_decl != 0 && TYPE_ARG_TYPES (TREE_TYPE (old_decl)) != 0)
+ && strcmp ("main", IDENTIFIER_POINTER (DECL_NAME (decl1))))
+ warning_with_decl (decl1, "no previous prototype for `%s'");
+ /* Optionally warn of any def with no previous prototype
+ if the function has already been used. */
+ else if (warn_missing_prototypes
+ && old_decl != 0 && TREE_USED (old_decl)
+ && !(old_decl != 0 && TYPE_ARG_TYPES (TREE_TYPE (old_decl)) != 0))
+ warning_with_decl (decl1, "`%s' was used with no prototype before its definition");
+
+ /* This is a definition, not a reference.
+ So normally clear DECL_EXTERNAL.
+ However, `extern inline' acts like a declaration
+ except for defining how to inline. So set DECL_EXTERNAL in that case. */
+ DECL_EXTERNAL (decl1) = current_extern_inline;
+
+ /* This function exists in static storage.
+ (This does not mean `static' in the C sense!) */
+ TREE_STATIC (decl1) = 1;
+
+ /* A nested function is not global. */
+ if (current_function_decl != 0)
+ TREE_PUBLIC (decl1) = 0;
+
+ /* Record the decl so that the function name is defined.
+ If we already have a decl for this name, and it is a FUNCTION_DECL,
+ use the old decl. */
+
+ current_function_decl = pushdecl (decl1);
+
+ pushlevel (0);
+ declare_parm_level (1);
+ current_binding_level->subblocks_tag_transparent = 1;
+
+ make_function_rtl (current_function_decl);
+
+ restype = TREE_TYPE (TREE_TYPE (current_function_decl));
+ /* Promote the value to int before returning it. */
+ if (C_PROMOTING_INTEGER_TYPE_P (restype))
+ {
+ /* It retains unsignedness if traditional
+ or if not really getting wider. */
+ if (TREE_UNSIGNED (restype)
+ && (flag_traditional
+ || (TYPE_PRECISION (restype)
+ == TYPE_PRECISION (integer_type_node))))
+ restype = unsigned_type_node;
+ else
+ restype = integer_type_node;
+ }
+ DECL_RESULT (current_function_decl)
+ = build_decl (RESULT_DECL, NULL_TREE, restype);
+
+ if (!nested)
+ /* Allocate further tree nodes temporarily during compilation
+ of this function only. */
+ temporary_allocation ();
+
+ /* If this fcn was already referenced via a block-scope `extern' decl
+ (or an implicit decl), propagate certain information about the usage. */
+ if (TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (current_function_decl)))
+ TREE_ADDRESSABLE (current_function_decl) = 1;
+
+ return 1;
+}
+
+/* Record that this function is going to be a varargs function.
+ This is called before store_parm_decls, which is too early
+ to call mark_varargs directly. */
+
+void
+c_mark_varargs ()
+{
+ c_function_varargs = 1;
+}
+
+/* Store the parameter declarations into the current function declaration.
+ This is called after parsing the parameter declarations, before
+ digesting the body of the function.
+
+ For an old-style definition, modify the function's type
+ to specify at least the number of arguments. */
+
+void
+store_parm_decls ()
+{
+ register tree fndecl = current_function_decl;
+ register tree parm;
+
+ /* This is either a chain of PARM_DECLs (if a prototype was used)
+ or a list of IDENTIFIER_NODEs (for an old-fashioned C definition). */
+ tree specparms = current_function_parms;
+
+ /* This is a list of types declared among parms in a prototype. */
+ tree parmtags = current_function_parm_tags;
+
+ /* This is a chain of PARM_DECLs from old-style parm declarations. */
+ register tree parmdecls = getdecls ();
+
+ /* This is a chain of any other decls that came in among the parm
+ declarations. If a parm is declared with enum {foo, bar} x;
+ then CONST_DECLs for foo and bar are put here. */
+ tree nonparms = 0;
+
+ /* Nonzero if this definition is written with a prototype. */
+ int prototype = 0;
+
+ if (specparms != 0 && TREE_CODE (specparms) != TREE_LIST)
+ {
+ /* This case is when the function was defined with an ANSI prototype.
+ The parms already have decls, so we need not do anything here
+ except record them as in effect
+ and complain if any redundant old-style parm decls were written. */
+
+ register tree next;
+ tree others = 0;
+
+ prototype = 1;
+
+ if (parmdecls != 0)
+ {
+ tree decl, link;
+
+ error_with_decl (fndecl,
+ "parm types given both in parmlist and separately");
+ /* Get rid of the erroneous decls; don't keep them on
+ the list of parms, since they might not be PARM_DECLs. */
+ for (decl = current_binding_level->names;
+ decl; decl = TREE_CHAIN (decl))
+ if (DECL_NAME (decl))
+ IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) = 0;
+ for (link = current_binding_level->shadowed;
+ link; link = TREE_CHAIN (link))
+ IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
+ current_binding_level->names = 0;
+ current_binding_level->shadowed = 0;
+ }
+
+ specparms = nreverse (specparms);
+ for (parm = specparms; parm; parm = next)
+ {
+ next = TREE_CHAIN (parm);
+ if (TREE_CODE (parm) == PARM_DECL)
+ {
+ if (DECL_NAME (parm) == 0)
+ error_with_decl (parm, "parameter name omitted");
+ else if (TYPE_MAIN_VARIANT (TREE_TYPE (parm)) == void_type_node)
+ {
+ error_with_decl (parm, "parameter `%s' declared void");
+ /* Change the type to error_mark_node so this parameter
+ will be ignored by assign_parms. */
+ TREE_TYPE (parm) = error_mark_node;
+ }
+ pushdecl (parm);
+ }
+ else
+ {
+ /* If we find an enum constant or a type tag,
+ put it aside for the moment. */
+ TREE_CHAIN (parm) = 0;
+ others = chainon (others, parm);
+ }
+ }
+
+ /* Get the decls in their original chain order
+ and record in the function. */
+ DECL_ARGUMENTS (fndecl) = getdecls ();
+
+#if 0
+ /* If this function takes a variable number of arguments,
+ add a phony parameter to the end of the parm list,
+ to represent the position of the first unnamed argument. */
+ if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (fndecl))))
+ != void_type_node)
+ {
+ tree dummy = build_decl (PARM_DECL, NULL_TREE, void_type_node);
+ /* Let's hope the address of the unnamed parm
+ won't depend on its type. */
+ TREE_TYPE (dummy) = integer_type_node;
+ DECL_ARG_TYPE (dummy) = integer_type_node;
+ DECL_ARGUMENTS (fndecl)
+ = chainon (DECL_ARGUMENTS (fndecl), dummy);
+ }
+#endif
+
+ /* Now pushdecl the enum constants. */
+ for (parm = others; parm; parm = next)
+ {
+ next = TREE_CHAIN (parm);
+ if (DECL_NAME (parm) == 0)
+ ;
+ else if (TYPE_MAIN_VARIANT (TREE_TYPE (parm)) == void_type_node)
+ ;
+ else if (TREE_CODE (parm) != PARM_DECL)
+ pushdecl (parm);
+ }
+
+ storetags (chainon (parmtags, gettags ()));
+ }
+ else
+ {
+ /* SPECPARMS is an identifier list--a chain of TREE_LIST nodes
+ each with a parm name as the TREE_VALUE.
+
+ PARMDECLS is a chain of declarations for parameters.
+ Warning! It can also contain CONST_DECLs which are not parameters
+ but are names of enumerators of any enum types
+ declared among the parameters.
+
+ First match each formal parameter name with its declaration.
+ Associate decls with the names and store the decls
+ into the TREE_PURPOSE slots. */
+
+ for (parm = parmdecls; parm; parm = TREE_CHAIN (parm))
+ DECL_RESULT (parm) = 0;
+
+ for (parm = specparms; parm; parm = TREE_CHAIN (parm))
+ {
+ register tree tail, found = NULL;
+
+ if (TREE_VALUE (parm) == 0)
+ {
+ error_with_decl (fndecl, "parameter name missing from parameter list");
+ TREE_PURPOSE (parm) = 0;
+ continue;
+ }
+
+ /* See if any of the parmdecls specifies this parm by name.
+ Ignore any enumerator decls. */
+ for (tail = parmdecls; tail; tail = TREE_CHAIN (tail))
+ if (DECL_NAME (tail) == TREE_VALUE (parm)
+ && TREE_CODE (tail) == PARM_DECL)
+ {
+ found = tail;
+ break;
+ }
+
+ /* If declaration already marked, we have a duplicate name.
+ Complain, and don't use this decl twice. */
+ if (found && DECL_RESULT (found) != 0)
+ {
+ error_with_decl (found, "multiple parameters named `%s'");
+ found = 0;
+ }
+
+ /* If the declaration says "void", complain and ignore it. */
+ if (found && TYPE_MAIN_VARIANT (TREE_TYPE (found)) == void_type_node)
+ {
+ error_with_decl (found, "parameter `%s' declared void");
+ TREE_TYPE (found) = integer_type_node;
+ DECL_ARG_TYPE (found) = integer_type_node;
+ layout_decl (found, 0);
+ }
+
+ /* Traditionally, a parm declared float is actually a double. */
+ if (found && flag_traditional
+ && TYPE_MAIN_VARIANT (TREE_TYPE (found)) == float_type_node)
+ {
+ TREE_TYPE (found) = double_type_node;
+ DECL_ARG_TYPE (found) = double_type_node;
+ layout_decl (found, 0);
+ }
+
+ /* If no declaration found, default to int. */
+ if (!found)
+ {
+ found = build_decl (PARM_DECL, TREE_VALUE (parm),
+ integer_type_node);
+ DECL_ARG_TYPE (found) = TREE_TYPE (found);
+ DECL_SOURCE_LINE (found) = DECL_SOURCE_LINE (fndecl);
+ DECL_SOURCE_FILE (found) = DECL_SOURCE_FILE (fndecl);
+ if (extra_warnings)
+ warning_with_decl (found, "type of `%s' defaults to `int'");
+ pushdecl (found);
+ }
+
+ TREE_PURPOSE (parm) = found;
+
+ /* Mark this decl as "already found" -- see test, above.
+ It is safe to use DECL_RESULT for this
+ since it is not used in PARM_DECLs or CONST_DECLs. */
+ DECL_RESULT (found) = error_mark_node;
+ }
+
+ /* Put anything which is on the parmdecls chain and which is
+ not a PARM_DECL onto the list NONPARMS. (The types of
+ non-parm things which might appear on the list include
+ enumerators and NULL-named TYPE_DECL nodes.) Complain about
+ any actual PARM_DECLs not matched with any names. */
+
+ nonparms = 0;
+ for (parm = parmdecls; parm; )
+ {
+ tree next = TREE_CHAIN (parm);
+ TREE_CHAIN (parm) = 0;
+
+ if (TREE_CODE (parm) != PARM_DECL)
+ nonparms = chainon (nonparms, parm);
+ else
+ {
+ /* Complain about args with incomplete types. */
+ if (TYPE_SIZE (TREE_TYPE (parm)) == 0)
+ {
+ error_with_decl (parm, "parameter `%s' has incomplete type");
+ TREE_TYPE (parm) = error_mark_node;
+ }
+
+ if (DECL_RESULT (parm) == 0)
+ {
+ error_with_decl (parm,
+ "declaration for parameter `%s' but no such parameter");
+ /* Pretend the parameter was not missing.
+ This gets us to a standard state and minimizes
+ further error messages. */
+ specparms
+ = chainon (specparms,
+ tree_cons (parm, NULL_TREE, NULL_TREE));
+ }
+ }
+
+ parm = next;
+ }
+
+ /* Chain the declarations together in the order of the list of names. */
+ /* Store that chain in the function decl, replacing the list of names. */
+ parm = specparms;
+ DECL_ARGUMENTS (fndecl) = 0;
+ {
+ register tree last;
+ for (last = 0; parm; parm = TREE_CHAIN (parm))
+ if (TREE_PURPOSE (parm))
+ {
+ if (last == 0)
+ DECL_ARGUMENTS (fndecl) = TREE_PURPOSE (parm);
+ else
+ TREE_CHAIN (last) = TREE_PURPOSE (parm);
+ last = TREE_PURPOSE (parm);
+ TREE_CHAIN (last) = 0;
+ }
+ }
+
+ /* If there was a previous prototype,
+ set the DECL_ARG_TYPE of each argument according to
+ the type previously specified, and report any mismatches. */
+
+ if (TYPE_ARG_TYPES (TREE_TYPE (fndecl)))
+ {
+ register tree type;
+ for (parm = DECL_ARGUMENTS (fndecl),
+ type = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
+ parm || (type && (TYPE_MAIN_VARIANT (TREE_VALUE (type))
+ != void_type_node));
+ parm = TREE_CHAIN (parm), type = TREE_CHAIN (type))
+ {
+ if (parm == 0 || type == 0
+ || TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node)
+ {
+ error ("number of arguments doesn't match prototype");
+ error_with_file_and_line (current_function_prototype_file,
+ current_function_prototype_line,
+ "prototype declaration");
+ break;
+ }
+ /* Type for passing arg must be consistent
+ with that declared for the arg. */
+ if (! comptypes (DECL_ARG_TYPE (parm), TREE_VALUE (type)))
+ {
+ if (TYPE_MAIN_VARIANT (TREE_TYPE (parm))
+ == TYPE_MAIN_VARIANT (TREE_VALUE (type)))
+ {
+ /* Adjust argument to match prototype. E.g. a previous
+ `int foo(float);' prototype causes
+ `int foo(x) float x; {...}' to be treated like
+ `int foo(float x) {...}'. This is particularly
+ useful for argument types like uid_t. */
+ DECL_ARG_TYPE (parm) = TREE_TYPE (parm);
+#ifdef PROMOTE_PROTOTYPES
+ if (TREE_CODE (TREE_TYPE (parm)) == INTEGER_TYPE
+ && TYPE_PRECISION (TREE_TYPE (parm))
+ < TYPE_PRECISION (integer_type_node))
+ DECL_ARG_TYPE (parm) = integer_type_node;
+#endif
+ if (pedantic)
+ {
+ pedwarn ("promoted argument `%s' doesn't match prototype",
+ IDENTIFIER_POINTER (DECL_NAME (parm)));
+ warning_with_file_and_line
+ (current_function_prototype_file,
+ current_function_prototype_line,
+ "prototype declaration");
+ }
+ }
+ /* If -traditional, allow `int' argument to match
+ `unsigned' prototype. */
+ else if (! (flag_traditional
+ && TYPE_MAIN_VARIANT (TREE_TYPE (parm)) == integer_type_node
+ && TYPE_MAIN_VARIANT (TREE_VALUE (type)) == unsigned_type_node))
+ {
+ error ("argument `%s' doesn't match prototype",
+ IDENTIFIER_POINTER (DECL_NAME (parm)));
+ error_with_file_and_line (current_function_prototype_file,
+ current_function_prototype_line,
+ "prototype declaration");
+ }
+ }
+ }
+ TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = 0;
+ }
+
+ /* Otherwise, create a prototype that would match. */
+
+ else
+ {
+ register tree actual, type;
+ register tree last = 0;
+
+ for (parm = DECL_ARGUMENTS (fndecl); parm; parm = TREE_CHAIN (parm))
+ {
+ type = perm_tree_cons (NULL_TREE, DECL_ARG_TYPE (parm),
+ NULL_TREE);
+ if (last)
+ TREE_CHAIN (last) = type;
+ else
+ actual = type;
+ last = type;
+ }
+ type = perm_tree_cons (NULL_TREE, void_type_node, NULL_TREE);
+ if (last)
+ TREE_CHAIN (last) = type;
+ else
+ actual = type;
+
+ /* We are going to assign a new value for the TYPE_ACTUAL_ARG_TYPES
+ of the type of this function, but we need to avoid having this
+ affect the types of other similarly-typed functions, so we must
+ first force the generation of an identical (but separate) type
+ node for the relevant function type. The new node we create
+ will be a variant of the main variant of the original function
+ type. */
+
+ TREE_TYPE (fndecl) = build_type_copy (TREE_TYPE (fndecl));
+
+ TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = actual;
+ }
+
+ /* Now store the final chain of decls for the arguments
+ as the decl-chain of the current lexical scope.
+ Put the enumerators in as well, at the front so that
+ DECL_ARGUMENTS is not modified. */
+
+ storedecls (chainon (nonparms, DECL_ARGUMENTS (fndecl)));
+ }
+
+ /* Make sure the binding level for the top of the function body
+ gets a BLOCK if there are any in the function.
+ Otherwise, the dbx output is wrong. */
+
+ keep_next_if_subblocks = 1;
+
+ /* ??? This might be an improvement,
+ but needs to be thought about some more. */
+#if 0
+ keep_next_level_flag = 1;
+#endif
+
+ /* Write a record describing this function definition to the prototypes
+ file (if requested). */
+
+ gen_aux_info_record (fndecl, 1, 0, prototype);
+
+ /* Initialize the RTL code for the function. */
+
+ init_function_start (fndecl, input_filename, lineno);
+
+ /* If this is a varargs function, inform function.c. */
+
+ if (c_function_varargs)
+ mark_varargs ();
+
+ /* Declare __FUNCTION__ and __PRETTY_FUNCTION__ for this function. */
+
+ declare_function_name ();
+
+ /* Set up parameters and prepare for return, for the function. */
+
+ expand_function_start (fndecl, 0);
+
+ /* If this function is `main', emit a call to `__main'
+ to run global initializers, etc. */
+ if (DECL_NAME (fndecl)
+ && strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main") == 0
+ && DECL_CONTEXT (fndecl) == NULL_TREE)
+ expand_main_function ();
+}
+
+/* SPECPARMS is an identifier list--a chain of TREE_LIST nodes
+ each with a parm name as the TREE_VALUE. A null pointer as TREE_VALUE
+ stands for an ellipsis in the identifier list.
+
+ PARMLIST is the data returned by get_parm_info for the
+ parmlist that follows the semicolon.
+
+ We return a value of the same sort that get_parm_info returns,
+ except that it describes the combination of identifiers and parmlist. */
+
+tree
+combine_parm_decls (specparms, parmlist, void_at_end)
+ tree specparms, parmlist;
+ int void_at_end;
+{
+ register tree fndecl = current_function_decl;
+ register tree parm;
+
+ tree parmdecls = TREE_PURPOSE (parmlist);
+
+ /* This is a chain of any other decls that came in among the parm
+ declarations. They were separated already by get_parm_info,
+ so we just need to keep them separate. */
+ tree nonparms = TREE_VALUE (parmlist);
+
+ tree types = 0;
+
+ for (parm = parmdecls; parm; parm = TREE_CHAIN (parm))
+ DECL_RESULT (parm) = 0;
+
+ for (parm = specparms; parm; parm = TREE_CHAIN (parm))
+ {
+ register tree tail, found = NULL;
+
+ /* See if any of the parmdecls specifies this parm by name. */
+ for (tail = parmdecls; tail; tail = TREE_CHAIN (tail))
+ if (DECL_NAME (tail) == TREE_VALUE (parm))
+ {
+ found = tail;
+ break;
+ }
+
+ /* If declaration already marked, we have a duplicate name.
+ Complain, and don't use this decl twice. */
+ if (found && DECL_RESULT (found) != 0)
+ {
+ error_with_decl (found, "multiple parameters named `%s'");
+ found = 0;
+ }
+
+ /* If the declaration says "void", complain and ignore it. */
+ if (found && TYPE_MAIN_VARIANT (TREE_TYPE (found)) == void_type_node)
+ {
+ error_with_decl (found, "parameter `%s' declared void");
+ TREE_TYPE (found) = integer_type_node;
+ DECL_ARG_TYPE (found) = integer_type_node;
+ layout_decl (found, 0);
+ }
+
+ /* Traditionally, a parm declared float is actually a double. */
+ if (found && flag_traditional
+ && TYPE_MAIN_VARIANT (TREE_TYPE (found)) == float_type_node)
+ {
+ TREE_TYPE (found) = double_type_node;
+ DECL_ARG_TYPE (found) = double_type_node;
+ layout_decl (found, 0);
+ }
+
+ /* If no declaration found, default to int. */
+ if (!found)
+ {
+ found = build_decl (PARM_DECL, TREE_VALUE (parm),
+ integer_type_node);
+ DECL_ARG_TYPE (found) = TREE_TYPE (found);
+ DECL_SOURCE_LINE (found) = DECL_SOURCE_LINE (fndecl);
+ DECL_SOURCE_FILE (found) = DECL_SOURCE_FILE (fndecl);
+ error_with_decl (found, "type of parameter `%s' is not declared");
+ pushdecl (found);
+ }
+
+ TREE_PURPOSE (parm) = found;
+
+ /* Mark this decl as "already found" -- see test, above.
+ It is safe to use DECL_RESULT for this
+ since it is not used in PARM_DECLs or CONST_DECLs. */
+ DECL_RESULT (found) = error_mark_node;
+ }
+
+ /* Complain about any actual PARM_DECLs not matched with any names. */
+
+ for (parm = parmdecls; parm; )
+ {
+ tree next = TREE_CHAIN (parm);
+ TREE_CHAIN (parm) = 0;
+
+ /* Complain about args with incomplete types. */
+ if (TYPE_SIZE (TREE_TYPE (parm)) == 0)
+ {
+ error_with_decl (parm, "parameter `%s' has incomplete type");
+ TREE_TYPE (parm) = error_mark_node;
+ }
+
+ if (DECL_RESULT (parm) == 0)
+ {
+ error_with_decl (parm,
+ "declaration for parameter `%s' but no such parameter");
+ /* Pretend the parameter was not missing.
+ This gets us to a standard state and minimizes
+ further error messages. */
+ specparms
+ = chainon (specparms,
+ tree_cons (parm, NULL_TREE, NULL_TREE));
+ }
+
+ parm = next;
+ }
+
+ /* Chain the declarations together in the order of the list of names.
+ At the same time, build up a list of their types, in reverse order. */
+
+ parm = specparms;
+ parmdecls = 0;
+ {
+ register tree last;
+ for (last = 0; parm; parm = TREE_CHAIN (parm))
+ if (TREE_PURPOSE (parm))
+ {
+ if (last == 0)
+ parmdecls = TREE_PURPOSE (parm);
+ else
+ TREE_CHAIN (last) = TREE_PURPOSE (parm);
+ last = TREE_PURPOSE (parm);
+ TREE_CHAIN (last) = 0;
+
+ types = saveable_tree_cons (NULL_TREE, TREE_TYPE (parm), types);
+ }
+ }
+
+ if (void_at_end)
+ return saveable_tree_cons (parmdecls, nonparms,
+ nreverse (saveable_tree_cons (NULL_TREE, void_type_node, types)));
+
+ return saveable_tree_cons (parmdecls, nonparms, nreverse (types));
+}
+
+/* Finish up a function declaration and compile that function
+ all the way to assembler language output. The free the storage
+ for the function definition.
+
+ This is called after parsing the body of the function definition.
+
+ NESTED is nonzero if the function being finished is nested in another. */
+
+void
+finish_function (nested)
+ int nested;
+{
+ register tree fndecl = current_function_decl;
+
+/* TREE_READONLY (fndecl) = 1;
+ This caused &foo to be of type ptr-to-const-function
+ which then got a warning when stored in a ptr-to-function variable. */
+
+ poplevel (1, 0, 1);
+ BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
+
+ /* Must mark the RESULT_DECL as being in this function. */
+
+ DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
+
+ /* Obey `register' declarations if `setjmp' is called in this fn. */
+ if (flag_traditional && current_function_calls_setjmp)
+ {
+ setjmp_protect (DECL_INITIAL (fndecl));
+ setjmp_protect_args ();
+ }
+
+#ifdef DEFAULT_MAIN_RETURN
+ if (! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main"))
+ {
+ if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))
+ != integer_type_node)
+ warning_with_decl (fndecl, "return type of `%s' is not `int'");
+ else
+ {
+ /* Make it so that `main' always returns success by default. */
+ DEFAULT_MAIN_RETURN;
+ }
+ }
+#endif
+
+ /* Generate rtl for function exit. */
+ expand_function_end (input_filename, lineno);
+
+ /* So we can tell if jump_optimize sets it to 1. */
+ can_reach_end = 0;
+
+ /* Run the optimizers and output the assembler code for this function. */
+ rest_of_compilation (fndecl);
+
+ current_function_returns_null |= can_reach_end;
+
+ if (TREE_THIS_VOLATILE (fndecl) && current_function_returns_null)
+ warning ("`volatile' function does return");
+ else if (warn_return_type && can_reach_end
+ && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl))) != void_type_node)
+ /* If this function returns non-void and control can drop through,
+ complain. */
+ warning ("control reaches end of non-void function");
+ /* With just -W, complain only if function returns both with
+ and without a value. */
+ else if (extra_warnings
+ && current_function_returns_value && current_function_returns_null)
+ warning ("this function may return with or without a value");
+
+ /* Free all the tree nodes making up this function. */
+ /* Switch back to allocating nodes permanently
+ until we start another function. */
+ if (! nested)
+ permanent_allocation ();
+
+ if (DECL_SAVED_INSNS (fndecl) == 0 && ! nested)
+ {
+ /* Stop pointing to the local nodes about to be freed. */
+ /* But DECL_INITIAL must remain nonzero so we know this
+ was an actual function definition. */
+ /* For a nested function, this is done in pop_c_function_context. */
+ DECL_INITIAL (fndecl) = error_mark_node;
+ DECL_ARGUMENTS (fndecl) = 0;
+ }
+
+ if (! nested)
+ {
+ /* Let the error reporting routines know that we're outside a
+ function. For a nested function, this value is used in
+ pop_c_function_context and then reset via pop_function_context. */
+ current_function_decl = NULL;
+ }
+}
+
+/* Save and restore the variables in this file and elsewhere
+ that keep track of the progress of compilation of the current function.
+ Used for nested functions. */
+
+struct c_function
+{
+ struct c_function *next;
+ tree enum_next_value;
+ tree named_labels;
+ tree shadowed_labels;
+ int returns_value;
+ int returns_null;
+ int warn_about_return_type;
+ int extern_inline;
+ struct binding_level *binding_level;
+};
+
+struct c_function *c_function_chain;
+
+/* Save and reinitialize the variables
+ used during compilation of a C function. */
+
+void
+push_c_function_context ()
+{
+ struct c_function *p
+ = (struct c_function *) xmalloc (sizeof (struct c_function));
+
+ if (pedantic)
+ pedwarn ("ANSI C forbids nested functions");
+
+ push_function_context ();
+
+ p->next = c_function_chain;
+ c_function_chain = p;
+
+ p->enum_next_value = enum_next_value;
+ p->named_labels = named_labels;
+ p->shadowed_labels = shadowed_labels;
+ p->returns_value = current_function_returns_value;
+ p->returns_null = current_function_returns_null;
+ p->warn_about_return_type = warn_about_return_type;
+ p->extern_inline = current_extern_inline;
+ p->binding_level = current_binding_level;
+}
+
+/* Restore the variables used during compilation of a C function. */
+
+void
+pop_c_function_context ()
+{
+ struct c_function *p = c_function_chain;
+ tree link;
+
+ /* Bring back all the labels that were shadowed. */
+ for (link = shadowed_labels; link; link = TREE_CHAIN (link))
+ if (DECL_NAME (TREE_VALUE (link)) != 0)
+ IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link)))
+ = TREE_VALUE (link);
+
+ if (DECL_SAVED_INSNS (current_function_decl) == 0)
+ {
+ /* Stop pointing to the local nodes about to be freed. */
+ /* But DECL_INITIAL must remain nonzero so we know this
+ was an actual function definition. */
+ DECL_INITIAL (current_function_decl) = error_mark_node;
+ DECL_ARGUMENTS (current_function_decl) = 0;
+ }
+
+ pop_function_context ();
+
+ c_function_chain = p->next;
+
+ enum_next_value = p->enum_next_value;
+ named_labels = p->named_labels;
+ shadowed_labels = p->shadowed_labels;
+ current_function_returns_value = p->returns_value;
+ current_function_returns_null = p->returns_null;
+ warn_about_return_type = p->warn_about_return_type;
+ current_extern_inline = p->extern_inline;
+ current_binding_level = p->binding_level;
+
+ free (p);
+}
diff --git a/gnu/usr.bin/cc/cc1/c-iterate.c b/gnu/usr.bin/cc/cc1/c-iterate.c
new file mode 100644
index 000000000000..09df3e466336
--- /dev/null
+++ b/gnu/usr.bin/cc/cc1/c-iterate.c
@@ -0,0 +1,594 @@
+/* Build expressions with type checking for C compiler.
+ Copyright (C) 1987, 1988, 1989, 1992 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+
+/* This file is part of the C front end.
+ It is responsible for implementing iterators,
+ both their declarations and the expansion of statements using them. */
+
+#include "config.h"
+#include <stdio.h>
+#include "tree.h"
+#include "c-tree.h"
+#include "flags.h"
+#include "obstack.h"
+#include "rtl.h"
+
+static void expand_stmt_with_iterators_1 ();
+static tree collect_iterators ();
+static void iterator_loop_prologue ();
+static void iterator_loop_epilogue ();
+static void add_ixpansion ();
+static void delete_ixpansion();
+static int top_level_ixpansion_p ();
+static void istack_sublevel_to_current ();
+
+/* A special obstack, and a pointer to the start of
+ all the data in it (so we can free everything easily). */
+static struct obstack ixp_obstack;
+static char *ixp_firstobj;
+
+/*
+ KEEPING TRACK OF EXPANSIONS
+
+ In order to clean out expansions corresponding to statements inside
+ "{(...)}" constructs we have to keep track of all expansions. The
+ cleanup is needed when an automatic, or implicit, expansion on
+ iterator, say X, happens to a statement which contains a {(...)}
+ form with a statement already expanded on X. In this case we have
+ to go back and cleanup the inner expansion. This can be further
+ complicated by the fact that {(...)} can be nested.
+
+ To make this cleanup possible, we keep lists of all expansions, and
+ to make it work for nested constructs, we keep a stack. The list at
+ the top of the stack (ITER_STACK.CURRENT_LEVEL) corresponds to the
+ currently parsed level. All expansions of the levels below the
+ current one are kept in one list whose head is pointed to by
+ ITER_STACK.SUBLEVEL_FIRST (SUBLEVEL_LAST is there for making merges
+ easy). The process works as follows:
+
+ -- On "({" a new node is added to the stack by PUSH_ITERATOR_STACK.
+ The sublevel list is not changed at this point.
+
+ -- On "})" the list for the current level is appended to the sublevel
+ list.
+
+ -- On ";" sublevel lists are appended to the current level lists.
+ The reason is this: if they have not been superseded by the
+ expansion at the current level, they still might be
+ superseded later by the expansion on the higher level.
+ The levels do not have to distinguish levels below, so we
+ can merge the lists together. */
+
+struct ixpansion
+{
+ tree ixdecl; /* Iterator decl */
+ rtx ixprologue_start; /* First insn of epilogue. NULL means */
+ /* explicit (FOR) expansion*/
+ rtx ixprologue_end;
+ rtx ixepilogue_start;
+ rtx ixepilogue_end;
+ struct ixpansion *next; /* Next in the list */
+};
+
+struct iter_stack_node
+{
+ struct ixpansion *first; /* Head of list of ixpansions */
+ struct ixpansion *last; /* Last node in list of ixpansions */
+ struct iter_stack_node *next; /* Next level iterator stack node */
+};
+
+struct iter_stack_node *iter_stack;
+
+struct iter_stack_node sublevel_ixpansions;
+
+/* During collect_iterators, a list of SAVE_EXPRs already scanned. */
+static tree save_exprs;
+
+/* Initialize our obstack once per compilation. */
+
+void
+init_iterators ()
+{
+ gcc_obstack_init (&ixp_obstack);
+ ixp_firstobj = (char *) obstack_alloc (&ixp_obstack, 0);
+}
+
+/* Handle the start of an explicit `for' loop for iterator IDECL. */
+
+void
+iterator_for_loop_start (idecl)
+ tree idecl;
+{
+ ITERATOR_BOUND_P (idecl) = 1;
+ add_ixpansion (idecl, 0, 0, 0, 0);
+ iterator_loop_prologue (idecl, 0, 0);
+}
+
+/* Handle the end of an explicit `for' loop for iterator IDECL. */
+
+void
+iterator_for_loop_end (idecl)
+ tree idecl;
+{
+ iterator_loop_epilogue (idecl, 0, 0);
+ ITERATOR_BOUND_P (idecl) = 0;
+}
+
+/*
+ ITERATOR RTL EXPANSIONS
+
+ Expanding simple statements with iterators is straightforward:
+ collect the list of all free iterators in the statement, and
+ generate a loop for each of them.
+
+ An iterator is "free" if it has not been "bound" by a FOR
+ operator. The DECL_RTL of the iterator is the loop counter. */
+
+/* Expand a statement STMT, possibly containing iterator usage, into RTL. */
+
+void
+iterator_expand (stmt)
+ tree stmt;
+{
+ tree iter_list;
+ save_exprs = NULL_TREE;
+ iter_list = collect_iterators (stmt, NULL_TREE);
+ expand_stmt_with_iterators_1 (stmt, iter_list);
+ istack_sublevel_to_current ();
+}
+
+
+static void
+expand_stmt_with_iterators_1 (stmt, iter_list)
+ tree stmt, iter_list;
+{
+ if (iter_list == 0)
+ expand_expr_stmt (stmt);
+ else
+ {
+ tree current_iterator = TREE_VALUE (iter_list);
+ tree iter_list_tail = TREE_CHAIN (iter_list);
+ rtx p_start, p_end, e_start, e_end;
+
+ iterator_loop_prologue (current_iterator, &p_start, &p_end);
+ expand_stmt_with_iterators_1 (stmt, iter_list_tail);
+ iterator_loop_epilogue (current_iterator, &e_start, &e_end);
+
+ /** Delete all inner expansions based on current_iterator **/
+ /** before adding the outer one. **/
+
+ delete_ixpansion (current_iterator);
+ add_ixpansion (current_iterator, p_start, p_end, e_start, e_end);
+ }
+}
+
+
+/* Return a list containing all the free (i.e. not bound by a
+ containing `for' statement) iterators mentioned in EXP, plus those
+ in LIST. Do not add duplicate entries to the list. */
+
+static tree
+collect_iterators (exp, list)
+ tree exp, list;
+{
+ if (exp == 0) return list;
+
+ switch (TREE_CODE (exp))
+ {
+ case VAR_DECL:
+ if (! ITERATOR_P (exp) || ITERATOR_BOUND_P (exp))
+ return list;
+ if (value_member (exp, list))
+ return list;
+ return tree_cons (NULL_TREE, exp, list);
+
+ case TREE_LIST:
+ {
+ tree tail;
+ for (tail = exp; tail; tail = TREE_CHAIN (tail))
+ list = collect_iterators (TREE_VALUE (tail), list);
+ return list;
+ }
+
+ case SAVE_EXPR:
+ /* In each scan, scan a given save_expr only once. */
+ {
+ tree tail;
+ for (tail = save_exprs; tail; tail = TREE_CHAIN (tail))
+ if (TREE_VALUE (tail) == exp)
+ return list;
+ }
+ save_exprs = tree_cons (NULL_TREE, exp, save_exprs);
+ return collect_iterators (TREE_OPERAND (exp, 0), list);
+
+ /* we do not automatically iterate blocks -- one must */
+ /* use the FOR construct to do that */
+
+ case BLOCK:
+ return list;
+
+ default:
+ switch (TREE_CODE_CLASS (TREE_CODE (exp)))
+ {
+ case '1':
+ return collect_iterators (TREE_OPERAND (exp, 0), list);
+
+ case '2':
+ case '<':
+ return collect_iterators (TREE_OPERAND (exp, 0),
+ collect_iterators (TREE_OPERAND (exp, 1),
+ list));
+
+ case 'e':
+ case 'r':
+ {
+ int num_args = tree_code_length[(int) TREE_CODE (exp)];
+ int i;
+
+ /* Some tree codes have RTL, not trees, as operands. */
+ switch (TREE_CODE (exp))
+ {
+ case CALL_EXPR:
+ num_args = 2;
+ break;
+ case METHOD_CALL_EXPR:
+ num_args = 3;
+ break;
+ case WITH_CLEANUP_EXPR:
+ num_args = 1;
+ break;
+ case RTL_EXPR:
+ return list;
+ }
+
+ for (i = 0; i < num_args; i++)
+ list = collect_iterators (TREE_OPERAND (exp, i), list);
+ return list;
+ }
+ default:
+ return list;
+ }
+ }
+}
+
+/* Emit rtl for the start of a loop for iterator IDECL.
+
+ If necessary, create loop counter rtx and store it as DECL_RTL of IDECL.
+
+ The prologue normally starts and ends with notes, which are returned
+ by this function in *START_NOTE and *END_NODE.
+ If START_NOTE and END_NODE are 0, we don't make those notes. */
+
+static void
+iterator_loop_prologue (idecl, start_note, end_note)
+ tree idecl;
+ rtx *start_note, *end_note;
+{
+ /* Force the save_expr in DECL_INITIAL to be calculated
+ if it hasn't been calculated yet. */
+ expand_expr (DECL_INITIAL (idecl), 0, VOIDmode, 0);
+
+ if (DECL_RTL (idecl) == 0)
+ expand_decl (idecl);
+
+ if (start_note)
+ *start_note = emit_note (0, NOTE_INSN_DELETED);
+ /* Initialize counter. */
+ expand_expr (build (MODIFY_EXPR, TREE_TYPE (idecl),
+ idecl, integer_zero_node),
+ 0, VOIDmode, 0);
+
+ expand_start_loop_continue_elsewhere (1);
+
+ ITERATOR_BOUND_P (idecl) = 1;
+
+ if (end_note)
+ *end_note = emit_note (0, NOTE_INSN_DELETED);
+}
+
+/* Similar to the previous function, but for the end of the loop.
+
+ DECL_RTL is zeroed unless we are inside "({...})". The reason for that is
+ described below.
+
+ When we create two (or more) loops based on the same IDECL, and
+ both inside the same "({...})" construct, we must be prepared to
+ delete both of the loops and create a single one on the level
+ above, i.e. enclosing the "({...})". The new loop has to use the
+ same counter rtl because the references to the iterator decl
+ (IDECL) have already been expanded as references to the counter
+ rtl.
+
+ It is incorrect to use the same counter reg in different functions,
+ and it is desirable to use different counters in disjoint loops
+ when we know there's no need to combine them (because then they can
+ get allocated separately). */
+
+static void
+iterator_loop_epilogue (idecl, start_note, end_note)
+ tree idecl;
+ rtx *start_note, *end_note;
+{
+ tree test, incr;
+
+ if (start_note)
+ *start_note = emit_note (0, NOTE_INSN_DELETED);
+ expand_loop_continue_here ();
+ incr = build_binary_op (PLUS_EXPR, idecl, integer_one_node, 0);
+ expand_expr (build (MODIFY_EXPR, TREE_TYPE (idecl), idecl, incr),
+ 0, VOIDmode, 0);
+ test = build_binary_op (LT_EXPR, idecl, DECL_INITIAL (idecl), 0);
+ expand_exit_loop_if_false (0, test);
+ expand_end_loop ();
+
+ ITERATOR_BOUND_P (idecl) = 0;
+ /* we can reset rtl since there is not chance that this expansion */
+ /* would be superceded by a higher level one */
+ if (top_level_ixpansion_p ())
+ DECL_RTL (idecl) = 0;
+ if (end_note)
+ *end_note = emit_note (0, NOTE_INSN_DELETED);
+}
+
+/* Return true if we are not currently inside a "({...})" construct. */
+
+static int
+top_level_ixpansion_p ()
+{
+ return iter_stack == 0;
+}
+
+/* Given two chains of iter_stack_nodes,
+ append the nodes in X into Y. */
+
+static void
+isn_append (x, y)
+ struct iter_stack_node *x, *y;
+{
+ if (x->first == 0)
+ return;
+
+ if (y->first == 0)
+ {
+ y->first = x->first;
+ y->last = x->last;
+ }
+ else
+ {
+ y->last->next = x->first;
+ y->last = x->last;
+ }
+}
+
+/** Make X empty **/
+
+#define ISN_ZERO(X) (X).first=(X).last=0
+
+/* Move the ixpansions in sublevel_ixpansions into the current
+ node on the iter_stack, or discard them if the iter_stack is empty.
+ We do this at the end of a statement. */
+
+static void
+istack_sublevel_to_current ()
+{
+ /* At the top level we can throw away sublevel's expansions **/
+ /* because there is nobody above us to ask for a cleanup **/
+ if (iter_stack != 0)
+ /** Merging with empty sublevel list is a no-op **/
+ if (sublevel_ixpansions.last)
+ isn_append (&sublevel_ixpansions, iter_stack);
+
+ if (iter_stack == 0)
+ obstack_free (&ixp_obstack, ixp_firstobj);
+
+ ISN_ZERO (sublevel_ixpansions);
+}
+
+/* Push a new node on the iter_stack, when we enter a ({...}). */
+
+void
+push_iterator_stack ()
+{
+ struct iter_stack_node *new_top
+ = (struct iter_stack_node*)
+ obstack_alloc (&ixp_obstack, sizeof (struct iter_stack_node));
+
+ new_top->first = 0;
+ new_top->last = 0;
+ new_top->next = iter_stack;
+ iter_stack = new_top;
+}
+
+/* Pop iter_stack, moving the ixpansions in the node being popped
+ into sublevel_ixpansions. */
+
+void
+pop_iterator_stack ()
+{
+ if (iter_stack == 0)
+ abort ();
+
+ isn_append (iter_stack, &sublevel_ixpansions);
+ /** Pop current level node: */
+ iter_stack = iter_stack->next;
+}
+
+
+/* Record an iterator expansion ("ixpansion") for IDECL.
+ The remaining paramters are the notes in the loop entry
+ and exit rtl. */
+
+static void
+add_ixpansion (idecl, pro_start, pro_end, epi_start, epi_end)
+ tree idecl;
+ rtx pro_start, pro_end, epi_start, epi_end;
+{
+ struct ixpansion* newix;
+
+ /* Do nothing if we are not inside "({...})",
+ as in that case this expansion can't need subsequent RTL modification. */
+ if (iter_stack == 0)
+ return;
+
+ newix = (struct ixpansion*) obstack_alloc (&ixp_obstack,
+ sizeof (struct ixpansion));
+ newix->ixdecl = idecl;
+ newix->ixprologue_start = pro_start;
+ newix->ixprologue_end = pro_end;
+ newix->ixepilogue_start = epi_start;
+ newix->ixepilogue_end = epi_end;
+
+ newix->next = iter_stack->first;
+ iter_stack->first = newix;
+ if (iter_stack->last == 0)
+ iter_stack->last = newix;
+}
+
+/* Delete the RTL for all ixpansions for iterator IDECL
+ in our sublevels. We do this when we make a larger
+ containing expansion for IDECL. */
+
+static void
+delete_ixpansion (idecl)
+ tree idecl;
+{
+ struct ixpansion* previx = 0, *ix;
+
+ for (ix = sublevel_ixpansions.first; ix; ix = ix->next)
+ if (ix->ixdecl == idecl)
+ {
+ /** zero means that this is a mark for FOR -- **/
+ /** we do not delete anything, just issue an error. **/
+
+ if (ix->ixprologue_start == 0)
+ error_with_decl (idecl,
+ "`for (%s)' appears within implicit iteration");
+ else
+ {
+ rtx insn;
+ /* We delete all insns, including notes because leaving loop */
+ /* notes and barriers produced by iterator expansion would */
+ /* be misleading to other phases */
+
+ for (insn = NEXT_INSN (ix->ixprologue_start);
+ insn != ix->ixprologue_end;
+ insn = NEXT_INSN (insn))
+ delete_insn (insn);
+ for (insn = NEXT_INSN (ix->ixepilogue_start);
+ insn != ix->ixepilogue_end;
+ insn = NEXT_INSN (insn))
+ delete_insn (insn);
+ }
+
+ /* Delete this ixpansion from sublevel_ixpansions. */
+ if (previx)
+ previx->next = ix->next;
+ else
+ sublevel_ixpansions.first = ix->next;
+ if (sublevel_ixpansions.last == ix)
+ sublevel_ixpansions.last = previx;
+ }
+ else
+ previx = ix;
+}
+
+#ifdef DEBUG_ITERATORS
+
+/* The functions below are for use from source level debugger.
+ They print short forms of iterator lists and the iterator stack. */
+
+/* Print the name of the iterator D. */
+
+void
+prdecl (d)
+ tree d;
+{
+ if (d)
+ {
+ if (TREE_CODE (d) == VAR_DECL)
+ {
+ tree tname = DECL_NAME (d);
+ char *dname = IDENTIFIER_POINTER (tname);
+ fprintf (stderr, dname);
+ }
+ else
+ fprintf (stderr, "<<Not a Decl!!!>>");
+ }
+ else
+ fprintf (stderr, "<<NULL!!>>");
+}
+
+/* Print Iterator List -- names only */
+
+tree
+pil (head)
+ tree head;
+{
+ tree current, next;
+ for (current = head; current; current = next)
+ {
+ tree node = TREE_VALUE (current);
+ prdecl (node);
+ next = TREE_CHAIN (current);
+ if (next) fprintf (stderr, ",");
+ }
+ fprintf (stderr, "\n");
+}
+
+/* Print IXpansion List */
+
+struct ixpansion *
+pixl (head)
+ struct ixpansion *head;
+{
+ struct ixpansion *current, *next;
+ fprintf (stderr, "> ");
+ if (head == 0)
+ fprintf (stderr, "(empty)");
+
+ for (current=head; current; current = next)
+ {
+ tree node = current->ixdecl;
+ prdecl (node);
+ next = current->next;
+ if (next)
+ fprintf (stderr, ",");
+ }
+ fprintf (stderr, "\n");
+ return head;
+}
+
+/* Print Iterator Stack*/
+
+void
+pis ()
+{
+ struct iter_stack_node *stack_node;
+
+ fprintf (stderr, "--SubLevel: ");
+ pixl (sublevel_ixpansions.first);
+ fprintf (stderr, "--Stack:--\n");
+ for (stack_node = iter_stack;
+ stack_node;
+ stack_node = stack_node->next)
+ pixl (stack_node->first);
+}
+
+#endif /* DEBUG_ITERATORS */
diff --git a/gnu/usr.bin/cc/cc1/c-lang.c b/gnu/usr.bin/cc/cc1/c-lang.c
new file mode 100644
index 000000000000..8b46b3c10cb5
--- /dev/null
+++ b/gnu/usr.bin/cc/cc1/c-lang.c
@@ -0,0 +1,129 @@
+/* Language-specific hook definitions for C front end.
+ Copyright (C) 1991 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+
+#include "config.h"
+#include "tree.h"
+#include <stdio.h>
+#include "input.h"
+
+/* Each of the functions defined here
+ is an alternative to a function in objc-actions.c. */
+
+int
+lang_decode_option (p)
+ char *p;
+{
+ return c_decode_option (p);
+}
+
+void
+lang_init ()
+{
+ /* the beginning of the file is a new line; check for # */
+ /* With luck, we discover the real source file's name from that
+ and put it in input_filename. */
+ ungetc (check_newline (), finput);
+}
+
+void
+lang_finish ()
+{
+}
+
+char *
+lang_identify ()
+{
+ return "c";
+}
+
+void
+print_lang_statistics ()
+{
+}
+
+/* Used by c-lex.c, but only for objc. */
+
+tree
+lookup_interface (arg)
+ tree arg;
+{
+ return 0;
+}
+
+tree
+is_class_name (arg)
+ tree arg;
+{
+ return 0;
+}
+
+void
+maybe_objc_check_decl (decl)
+ tree decl;
+{
+}
+
+int
+maybe_objc_comptypes (lhs, rhs, reflexive)
+ tree lhs, rhs;
+ int reflexive;
+{
+ return -1;
+}
+
+tree
+maybe_objc_method_name (decl)
+ tree decl;
+{
+ return 0;
+}
+
+tree
+maybe_building_objc_message_expr ()
+{
+ return 0;
+}
+
+int
+recognize_objc_keyword ()
+{
+ return 0;
+}
+
+tree
+build_objc_string (len, str)
+ int len;
+ char *str;
+{
+ abort ();
+ return NULL_TREE;
+}
+
+void
+GNU_xref_begin ()
+{
+ fatal ("GCC does not yet support XREF");
+}
+
+void
+GNU_xref_end ()
+{
+ fatal ("GCC does not yet support XREF");
+}
diff --git a/gnu/usr.bin/cc/cc1/c-lex.c b/gnu/usr.bin/cc/cc1/c-lex.c
new file mode 100644
index 000000000000..d83b5dccb623
--- /dev/null
+++ b/gnu/usr.bin/cc/cc1/c-lex.c
@@ -0,0 +1,2111 @@
+/* Lexical analyzer for C and Objective C.
+ Copyright (C) 1987, 1988, 1989, 1992 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+
+#include <stdio.h>
+#include <errno.h>
+#include <setjmp.h>
+
+#include "config.h"
+#include "rtl.h"
+#include "tree.h"
+#include "input.h"
+#include "c-lex.h"
+#include "c-tree.h"
+#include "flags.h"
+#include "c-parse.h"
+
+#ifdef MULTIBYTE_CHARS
+#include <stdlib.h>
+#include <locale.h>
+#endif
+
+#ifndef errno
+extern int errno;
+#endif
+
+/* The elements of `ridpointers' are identifier nodes
+ for the reserved type names and storage classes.
+ It is indexed by a RID_... value. */
+tree ridpointers[(int) RID_MAX];
+
+/* Cause the `yydebug' variable to be defined. */
+#define YYDEBUG 1
+
+/* the declaration found for the last IDENTIFIER token read in.
+ yylex must look this up to detect typedefs, which get token type TYPENAME,
+ so it is left around in case the identifier is not a typedef but is
+ used in a context which makes it a reference to a variable. */
+tree lastiddecl;
+
+/* Nonzero enables objc features. */
+
+int doing_objc_thang;
+
+extern tree is_class_name ();
+
+extern int yydebug;
+
+/* File used for outputting assembler code. */
+extern FILE *asm_out_file;
+
+#ifndef WCHAR_TYPE_SIZE
+#ifdef INT_TYPE_SIZE
+#define WCHAR_TYPE_SIZE INT_TYPE_SIZE
+#else
+#define WCHAR_TYPE_SIZE BITS_PER_WORD
+#endif
+#endif
+
+/* Number of bytes in a wide character. */
+#define WCHAR_BYTES (WCHAR_TYPE_SIZE / BITS_PER_UNIT)
+
+static int maxtoken; /* Current nominal length of token buffer. */
+char *token_buffer; /* Pointer to token buffer.
+ Actual allocated length is maxtoken + 2.
+ This is not static because objc-parse.y uses it. */
+
+/* Nonzero if end-of-file has been seen on input. */
+static int end_of_file;
+
+/* Buffered-back input character; faster than using ungetc. */
+static int nextchar = -1;
+
+int check_newline ();
+
+/* Nonzero tells yylex to ignore \ in string constants. */
+static int ignore_escape_flag = 0;
+
+/* C code produced by gperf version 2.5 (GNU C++ version) */
+/* Command-line: gperf -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$ c-parse.gperf */
+struct resword { char *name; short token; enum rid rid; };
+
+#define TOTAL_KEYWORDS 79
+#define MIN_WORD_LENGTH 2
+#define MAX_WORD_LENGTH 20
+#define MIN_HASH_VALUE 10
+#define MAX_HASH_VALUE 144
+/* maximum key range = 135, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#endif
+static unsigned int
+hash (str, len)
+ register char *str;
+ register int unsigned len;
+{
+ static unsigned char asso_values[] =
+ {
+ 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
+ 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
+ 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
+ 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
+ 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
+ 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
+ 145, 145, 145, 145, 25, 145, 145, 145, 145, 145,
+ 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
+ 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
+ 145, 145, 145, 145, 145, 1, 145, 46, 8, 15,
+ 61, 6, 36, 48, 3, 5, 145, 18, 63, 25,
+ 29, 76, 1, 145, 13, 2, 1, 51, 37, 9,
+ 9, 1, 3, 145, 145, 145, 145, 145,
+ };
+ register int hval = len;
+
+ switch (hval)
+ {
+ default:
+ case 3:
+ hval += asso_values[str[2]];
+ case 2:
+ case 1:
+ hval += asso_values[str[0]];
+ }
+ return hval + asso_values[str[len - 1]];
+}
+
+static struct resword wordlist[] =
+{
+ {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
+ {"",},
+ {"int", TYPESPEC, RID_INT},
+ {"",}, {"",},
+ {"__typeof__", TYPEOF, NORID},
+ {"__signed__", TYPESPEC, RID_SIGNED},
+ {"__imag__", IMAGPART, NORID},
+ {"switch", SWITCH, NORID},
+ {"__inline__", SCSPEC, RID_INLINE},
+ {"else", ELSE, NORID},
+ {"__iterator__", SCSPEC, RID_ITERATOR},
+ {"__inline", SCSPEC, RID_INLINE},
+ {"__extension__", EXTENSION, NORID},
+ {"struct", STRUCT, NORID},
+ {"__real__", REALPART, NORID},
+ {"__const", TYPE_QUAL, RID_CONST},
+ {"while", WHILE, NORID},
+ {"__const__", TYPE_QUAL, RID_CONST},
+ {"case", CASE, NORID},
+ {"__complex__", TYPESPEC, RID_COMPLEX},
+ {"__iterator", SCSPEC, RID_ITERATOR},
+ {"bycopy", TYPE_QUAL, RID_BYCOPY},
+ {"",}, {"",}, {"",},
+ {"__complex", TYPESPEC, RID_COMPLEX},
+ {"",},
+ {"in", TYPE_QUAL, RID_IN},
+ {"break", BREAK, NORID},
+ {"@defs", DEFS, NORID},
+ {"",}, {"",}, {"",},
+ {"extern", SCSPEC, RID_EXTERN},
+ {"if", IF, NORID},
+ {"typeof", TYPEOF, NORID},
+ {"typedef", SCSPEC, RID_TYPEDEF},
+ {"__typeof", TYPEOF, NORID},
+ {"sizeof", SIZEOF, NORID},
+ {"",},
+ {"return", RETURN, NORID},
+ {"const", TYPE_QUAL, RID_CONST},
+ {"__volatile__", TYPE_QUAL, RID_VOLATILE},
+ {"@private", PRIVATE, NORID},
+ {"@selector", SELECTOR, NORID},
+ {"__volatile", TYPE_QUAL, RID_VOLATILE},
+ {"__asm__", ASM_KEYWORD, NORID},
+ {"",}, {"",},
+ {"continue", CONTINUE, NORID},
+ {"__alignof__", ALIGNOF, NORID},
+ {"__imag", IMAGPART, NORID},
+ {"__attribute__", ATTRIBUTE, NORID},
+ {"",}, {"",},
+ {"__attribute", ATTRIBUTE, NORID},
+ {"for", FOR, NORID},
+ {"",},
+ {"@encode", ENCODE, NORID},
+ {"id", OBJECTNAME, RID_ID},
+ {"static", SCSPEC, RID_STATIC},
+ {"@interface", INTERFACE, NORID},
+ {"",},
+ {"__signed", TYPESPEC, RID_SIGNED},
+ {"",},
+ {"__label__", LABEL, NORID},
+ {"",}, {"",},
+ {"__asm", ASM_KEYWORD, NORID},
+ {"char", TYPESPEC, RID_CHAR},
+ {"",},
+ {"inline", SCSPEC, RID_INLINE},
+ {"out", TYPE_QUAL, RID_OUT},
+ {"register", SCSPEC, RID_REGISTER},
+ {"__real", REALPART, NORID},
+ {"short", TYPESPEC, RID_SHORT},
+ {"",},
+ {"enum", ENUM, NORID},
+ {"inout", TYPE_QUAL, RID_INOUT},
+ {"",},
+ {"oneway", TYPE_QUAL, RID_ONEWAY},
+ {"union", UNION, NORID},
+ {"",},
+ {"__alignof", ALIGNOF, NORID},
+ {"",},
+ {"@implementation", IMPLEMENTATION, NORID},
+ {"",},
+ {"@class", CLASS, NORID},
+ {"",},
+ {"@public", PUBLIC, NORID},
+ {"asm", ASM_KEYWORD, NORID},
+ {"",}, {"",}, {"",}, {"",}, {"",},
+ {"default", DEFAULT, NORID},
+ {"",},
+ {"void", TYPESPEC, RID_VOID},
+ {"",},
+ {"@protected", PROTECTED, NORID},
+ {"@protocol", PROTOCOL, NORID},
+ {"",}, {"",}, {"",},
+ {"volatile", TYPE_QUAL, RID_VOLATILE},
+ {"",}, {"",},
+ {"signed", TYPESPEC, RID_SIGNED},
+ {"float", TYPESPEC, RID_FLOAT},
+ {"@end", END, NORID},
+ {"",}, {"",},
+ {"unsigned", TYPESPEC, RID_UNSIGNED},
+ {"@compatibility_alias", ALIAS, NORID},
+ {"double", TYPESPEC, RID_DOUBLE},
+ {"",}, {"",},
+ {"auto", SCSPEC, RID_AUTO},
+ {"",},
+ {"goto", GOTO, NORID},
+ {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
+ {"do", DO, NORID},
+ {"",}, {"",}, {"",}, {"",},
+ {"long", TYPESPEC, RID_LONG},
+};
+
+#ifdef __GNUC__
+__inline
+#endif
+struct resword *
+is_reserved_word (str, len)
+ register char *str;
+ register unsigned int len;
+{
+ if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
+ {
+ register int key = hash (str, len);
+
+ if (key <= MAX_HASH_VALUE && key >= 0)
+ {
+ register char *s = wordlist[key].name;
+
+ if (*s == *str && !strcmp (str + 1, s + 1))
+ return &wordlist[key];
+ }
+ }
+ return 0;
+}
+
+/* Return something to represent absolute declarators containing a *.
+ TARGET is the absolute declarator that the * contains.
+ TYPE_QUALS is a list of modifiers such as const or volatile
+ to apply to the pointer type, represented as identifiers.
+
+ We return an INDIRECT_REF whose "contents" are TARGET
+ and whose type is the modifier list. */
+
+tree
+make_pointer_declarator (type_quals, target)
+ tree type_quals, target;
+{
+ return build1 (INDIRECT_REF, type_quals, target);
+}
+
+void
+forget_protocol_qualifiers ()
+{
+ int i, n = sizeof wordlist / sizeof (struct resword);
+
+ for (i = 0; i < n; i++)
+ if ((int) wordlist[i].rid >= (int) RID_IN
+ && (int) wordlist[i].rid <= (int) RID_ONEWAY)
+ wordlist[i].name = "";
+}
+
+void
+remember_protocol_qualifiers ()
+{
+ int i, n = sizeof wordlist / sizeof (struct resword);
+
+ for (i = 0; i < n; i++)
+ if (wordlist[i].rid == RID_IN)
+ wordlist[i].name = "in";
+ else if (wordlist[i].rid == RID_OUT)
+ wordlist[i].name = "out";
+ else if (wordlist[i].rid == RID_INOUT)
+ wordlist[i].name = "inout";
+ else if (wordlist[i].rid == RID_BYCOPY)
+ wordlist[i].name = "bycopy";
+ else if (wordlist[i].rid == RID_ONEWAY)
+ wordlist[i].name = "oneway";
+}
+
+void
+init_lex ()
+{
+ /* Make identifier nodes long enough for the language-specific slots. */
+ set_identifier_size (sizeof (struct lang_identifier));
+
+ /* Start it at 0, because check_newline is called at the very beginning
+ and will increment it to 1. */
+ lineno = 0;
+
+#ifdef MULTIBYTE_CHARS
+ /* Change to the native locale for multibyte conversions. */
+ setlocale (LC_CTYPE, "");
+#endif
+
+ maxtoken = 40;
+ token_buffer = (char *) xmalloc (maxtoken + 2);
+
+ ridpointers[(int) RID_INT] = get_identifier ("int");
+ ridpointers[(int) RID_CHAR] = get_identifier ("char");
+ ridpointers[(int) RID_VOID] = get_identifier ("void");
+ ridpointers[(int) RID_FLOAT] = get_identifier ("float");
+ ridpointers[(int) RID_DOUBLE] = get_identifier ("double");
+ ridpointers[(int) RID_SHORT] = get_identifier ("short");
+ ridpointers[(int) RID_LONG] = get_identifier ("long");
+ ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned");
+ ridpointers[(int) RID_SIGNED] = get_identifier ("signed");
+ ridpointers[(int) RID_INLINE] = get_identifier ("inline");
+ ridpointers[(int) RID_CONST] = get_identifier ("const");
+ ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
+ ridpointers[(int) RID_AUTO] = get_identifier ("auto");
+ ridpointers[(int) RID_STATIC] = get_identifier ("static");
+ ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
+ ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
+ ridpointers[(int) RID_REGISTER] = get_identifier ("register");
+ ridpointers[(int) RID_ITERATOR] = get_identifier ("iterator");
+ ridpointers[(int) RID_COMPLEX] = get_identifier ("complex");
+ ridpointers[(int) RID_ID] = get_identifier ("id");
+ ridpointers[(int) RID_IN] = get_identifier ("in");
+ ridpointers[(int) RID_OUT] = get_identifier ("out");
+ ridpointers[(int) RID_INOUT] = get_identifier ("inout");
+ ridpointers[(int) RID_BYCOPY] = get_identifier ("bycopy");
+ ridpointers[(int) RID_ONEWAY] = get_identifier ("oneway");
+ forget_protocol_qualifiers();
+
+ /* Some options inhibit certain reserved words.
+ Clear those words out of the hash table so they won't be recognized. */
+#define UNSET_RESERVED_WORD(STRING) \
+ do { struct resword *s = is_reserved_word (STRING, sizeof (STRING) - 1); \
+ if (s) s->name = ""; } while (0)
+
+ if (! doing_objc_thang)
+ UNSET_RESERVED_WORD ("id");
+
+ if (flag_traditional)
+ {
+ UNSET_RESERVED_WORD ("const");
+ UNSET_RESERVED_WORD ("volatile");
+ UNSET_RESERVED_WORD ("typeof");
+ UNSET_RESERVED_WORD ("signed");
+ UNSET_RESERVED_WORD ("inline");
+ UNSET_RESERVED_WORD ("iterator");
+ UNSET_RESERVED_WORD ("complex");
+ }
+ if (flag_no_asm)
+ {
+ UNSET_RESERVED_WORD ("asm");
+ UNSET_RESERVED_WORD ("typeof");
+ UNSET_RESERVED_WORD ("inline");
+ UNSET_RESERVED_WORD ("iterator");
+ UNSET_RESERVED_WORD ("complex");
+ }
+}
+
+void
+reinit_parse_for_function ()
+{
+}
+
+/* Function used when yydebug is set, to print a token in more detail. */
+
+void
+yyprint (file, yychar, yylval)
+ FILE *file;
+ int yychar;
+ YYSTYPE yylval;
+{
+ tree t;
+ switch (yychar)
+ {
+ case IDENTIFIER:
+ case TYPENAME:
+ case OBJECTNAME:
+ t = yylval.ttype;
+ if (IDENTIFIER_POINTER (t))
+ fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
+ break;
+
+ case CONSTANT:
+ t = yylval.ttype;
+ if (TREE_CODE (t) == INTEGER_CST)
+ fprintf (file,
+#if HOST_BITS_PER_WIDE_INT == 64
+#if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
+ " 0x%lx%016lx",
+#else
+ " 0x%x%016x",
+#endif
+#else
+#if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
+ " 0x%lx%08lx",
+#else
+ " 0x%x%08x",
+#endif
+#endif
+ TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
+ break;
+ }
+}
+
+
+/* If C is not whitespace, return C.
+ Otherwise skip whitespace and return first nonwhite char read. */
+
+static int
+skip_white_space (c)
+ register int c;
+{
+ static int newline_warning = 0;
+
+ for (;;)
+ {
+ switch (c)
+ {
+ /* We don't recognize comments here, because
+ cpp output can include / and * consecutively as operators.
+ Also, there's no need, since cpp removes all comments. */
+
+ case '\n':
+ c = check_newline ();
+ break;
+
+ case ' ':
+ case '\t':
+ case '\f':
+ case '\v':
+ case '\b':
+ c = getc (finput);
+ break;
+
+ case '\r':
+ /* ANSI C says the effects of a carriage return in a source file
+ are undefined. */
+ if (pedantic && !newline_warning)
+ {
+ warning ("carriage return in source file");
+ warning ("(we only warn about the first carriage return)");
+ newline_warning = 1;
+ }
+ c = getc (finput);
+ break;
+
+ case '\\':
+ c = getc (finput);
+ if (c == '\n')
+ lineno++;
+ else
+ error ("stray '\\' in program");
+ c = getc (finput);
+ break;
+
+ default:
+ return (c);
+ }
+ }
+}
+
+/* Skips all of the white space at the current location in the input file.
+ Must use and reset nextchar if it has the next character. */
+
+void
+position_after_white_space ()
+{
+ register int c;
+
+ if (nextchar != -1)
+ c = nextchar, nextchar = -1;
+ else
+ c = getc (finput);
+
+ ungetc (skip_white_space (c), finput);
+}
+
+/* Make the token buffer longer, preserving the data in it.
+ P should point to just beyond the last valid character in the old buffer.
+ The value we return is a pointer to the new buffer
+ at a place corresponding to P. */
+
+static char *
+extend_token_buffer (p)
+ char *p;
+{
+ int offset = p - token_buffer;
+
+ maxtoken = maxtoken * 2 + 10;
+ token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2);
+
+ return token_buffer + offset;
+}
+
+/* At the beginning of a line, increment the line number
+ and process any #-directive on this line.
+ If the line is a #-directive, read the entire line and return a newline.
+ Otherwise, return the line's first non-whitespace character. */
+
+int
+check_newline ()
+{
+ register int c;
+ register int token;
+
+ lineno++;
+
+ /* Read first nonwhite char on the line. */
+
+ c = getc (finput);
+ while (c == ' ' || c == '\t')
+ c = getc (finput);
+
+ if (c != '#')
+ {
+ /* If not #, return it so caller will use it. */
+ return c;
+ }
+
+ /* Read first nonwhite char after the `#'. */
+
+ c = getc (finput);
+ while (c == ' ' || c == '\t')
+ c = getc (finput);
+
+ /* If a letter follows, then if the word here is `line', skip
+ it and ignore it; otherwise, ignore the line, with an error
+ if the word isn't `pragma', `ident', `define', or `undef'. */
+
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
+ {
+ if (c == 'p')
+ {
+ if (getc (finput) == 'r'
+ && getc (finput) == 'a'
+ && getc (finput) == 'g'
+ && getc (finput) == 'm'
+ && getc (finput) == 'a'
+ && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
+ {
+#ifdef HANDLE_SYSV_PRAGMA
+ return handle_sysv_pragma (finput, c);
+#endif /* HANDLE_SYSV_PRAGMA */
+#ifdef HANDLE_PRAGMA
+ HANDLE_PRAGMA (finput);
+#endif /* HANDLE_PRAGMA */
+ goto skipline;
+ }
+ }
+
+ else if (c == 'd')
+ {
+ if (getc (finput) == 'e'
+ && getc (finput) == 'f'
+ && getc (finput) == 'i'
+ && getc (finput) == 'n'
+ && getc (finput) == 'e'
+ && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
+ {
+#ifdef DWARF_DEBUGGING_INFO
+ if ((debug_info_level == DINFO_LEVEL_VERBOSE)
+ && (write_symbols == DWARF_DEBUG))
+ dwarfout_define (lineno, get_directive_line (finput));
+#endif /* DWARF_DEBUGGING_INFO */
+ goto skipline;
+ }
+ }
+ else if (c == 'u')
+ {
+ if (getc (finput) == 'n'
+ && getc (finput) == 'd'
+ && getc (finput) == 'e'
+ && getc (finput) == 'f'
+ && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
+ {
+#ifdef DWARF_DEBUGGING_INFO
+ if ((debug_info_level == DINFO_LEVEL_VERBOSE)
+ && (write_symbols == DWARF_DEBUG))
+ dwarfout_undef (lineno, get_directive_line (finput));
+#endif /* DWARF_DEBUGGING_INFO */
+ goto skipline;
+ }
+ }
+ else if (c == 'l')
+ {
+ if (getc (finput) == 'i'
+ && getc (finput) == 'n'
+ && getc (finput) == 'e'
+ && ((c = getc (finput)) == ' ' || c == '\t'))
+ goto linenum;
+ }
+ else if (c == 'i')
+ {
+ if (getc (finput) == 'd'
+ && getc (finput) == 'e'
+ && getc (finput) == 'n'
+ && getc (finput) == 't'
+ && ((c = getc (finput)) == ' ' || c == '\t'))
+ {
+ /* #ident. The pedantic warning is now in cccp.c. */
+
+ /* Here we have just seen `#ident '.
+ A string constant should follow. */
+
+ while (c == ' ' || c == '\t')
+ c = getc (finput);
+
+ /* If no argument, ignore the line. */
+ if (c == '\n')
+ return c;
+
+ ungetc (c, finput);
+ token = yylex ();
+ if (token != STRING
+ || TREE_CODE (yylval.ttype) != STRING_CST)
+ {
+ error ("invalid #ident");
+ goto skipline;
+ }
+
+ if (!flag_no_ident)
+ {
+#ifdef ASM_OUTPUT_IDENT
+ ASM_OUTPUT_IDENT (asm_out_file, TREE_STRING_POINTER (yylval.ttype));
+#endif
+ }
+
+ /* Skip the rest of this line. */
+ goto skipline;
+ }
+ }
+
+ error ("undefined or invalid # directive");
+ goto skipline;
+ }
+
+linenum:
+ /* Here we have either `#line' or `# <nonletter>'.
+ In either case, it should be a line number; a digit should follow. */
+
+ while (c == ' ' || c == '\t')
+ c = getc (finput);