OSDN Git Service

* patch_tester.sh (usage): Watermark is not lexicographic.
[pf3gnuchains/gcc-fork.git] / gcc / toplev.c
1 /* Top level of GCC compilers (cc1, cc1plus, etc.)
2    Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3    1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4    Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22 /* This is the top level of cc1/c++.
23    It parses command args, opens files, invokes the various passes
24    in the proper order, and counts the time used by each.
25    Error messages and low-level interface to malloc also handled here.  */
26
27 #include "config.h"
28 #undef FLOAT /* This is for hpux. They should change hpux.  */
29 #undef FFS  /* Some systems define this in param.h.  */
30 #include "system.h"
31 #include "coretypes.h"
32 #include "tm.h"
33 #include <signal.h>
34
35 #ifdef HAVE_SYS_RESOURCE_H
36 # include <sys/resource.h>
37 #endif
38
39 #ifdef HAVE_SYS_TIMES_H
40 # include <sys/times.h>
41 #endif
42
43 #include "line-map.h"
44 #include "input.h"
45 #include "tree.h"
46 #include "version.h"
47 #include "rtl.h"
48 #include "tm_p.h"
49 #include "flags.h"
50 #include "insn-attr.h"
51 #include "insn-config.h"
52 #include "insn-flags.h"
53 #include "hard-reg-set.h"
54 #include "recog.h"
55 #include "output.h"
56 #include "except.h"
57 #include "function.h"
58 #include "toplev.h"
59 #include "expr.h"
60 #include "basic-block.h"
61 #include "intl.h"
62 #include "ggc.h"
63 #include "graph.h"
64 #include "regs.h"
65 #include "timevar.h"
66 #include "diagnostic.h"
67 #include "params.h"
68 #include "reload.h"
69 #include "dwarf2asm.h"
70 #include "integrate.h"
71 #include "real.h"
72 #include "debug.h"
73 #include "target.h"
74 #include "langhooks.h"
75 #include "cfglayout.h"
76 #include "cfgloop.h"
77 #include "hosthooks.h"
78 #include "cgraph.h"
79 #include "opts.h"
80 #include "coverage.h"
81 #include "value-prof.h"
82 #include "alloc-pool.h"
83 #include "tree-mudflap.h"
84 #include "tree-pass.h"
85
86 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
87 #include "dwarf2out.h"
88 #endif
89
90 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
91 #include "dbxout.h"
92 #endif
93
94 #ifdef SDB_DEBUGGING_INFO
95 #include "sdbout.h"
96 #endif
97
98 #ifdef XCOFF_DEBUGGING_INFO
99 #include "xcoffout.h"           /* Needed for external data
100                                    declarations for e.g. AIX 4.x.  */
101 #endif
102
103 static void general_init (const char *);
104 static void do_compile (void);
105 static void process_options (void);
106 static void backend_init (void);
107 static int lang_dependent_init (const char *);
108 static void init_asm_output (const char *);
109 static void finalize (void);
110
111 static void crash_signal (int) ATTRIBUTE_NORETURN;
112 static void setup_core_dumping (void);
113 static void compile_file (void);
114
115 /* Nonzero to dump debug info whilst parsing (-dy option).  */
116 static int set_yydebug;
117
118 /* True if we don't need a backend (e.g. preprocessing only).  */
119 static bool no_backend;
120
121 /* Length of line when printing switch values.  */
122 #define MAX_LINE 75
123
124 /* Name of program invoked, sans directories.  */
125
126 const char *progname;
127
128 /* Copy of argument vector to toplev_main.  */
129 static const char **save_argv;
130
131 /* Name of top-level original source file (what was input to cpp).
132    This comes from the #-command at the beginning of the actual input.
133    If there isn't any there, then this is the cc1 input file name.  */
134
135 const char *main_input_filename;
136
137 /* Used to enable -fvar-tracking, -fweb and -frename-registers according
138    to optimize and default_debug_hooks in process_options ().  */
139 #define AUTODETECT_VALUE 2
140
141 /* Current position in real source file.  */
142
143 location_t input_location;
144
145 struct line_maps *line_table;
146
147 /* Name to use as base of names for dump output files.  */
148
149 const char *dump_base_name;
150
151 /* Name to use as a base for auxiliary output files.  */
152
153 const char *aux_base_name;
154
155 /* A mask of target_flags that includes bit X if X was set or cleared
156    on the command line.  */
157
158 int target_flags_explicit;
159
160 /* Debug hooks - dependent upon command line options.  */
161
162 const struct gcc_debug_hooks *debug_hooks;
163
164 /* Debug hooks - target default.  */
165
166 static const struct gcc_debug_hooks *default_debug_hooks;
167
168 /* Other flags saying which kinds of debugging dump have been requested.  */
169
170 int rtl_dump_and_exit;
171 int flag_print_asm_name;
172 enum graph_dump_types graph_dump_format;
173
174 /* Name for output file of assembly code, specified with -o.  */
175
176 const char *asm_file_name;
177
178 /* Nonzero means do optimizations.  -O.
179    Particular numeric values stand for particular amounts of optimization;
180    thus, -O2 stores 2 here.  However, the optimizations beyond the basic
181    ones are not controlled directly by this variable.  Instead, they are
182    controlled by individual `flag_...' variables that are defaulted
183    based on this variable.  */
184
185 int optimize = 0;
186
187 /* Nonzero means optimize for size.  -Os.
188    The only valid values are zero and nonzero. When optimize_size is
189    nonzero, optimize defaults to 2, but certain individual code
190    bloating optimizations are disabled.  */
191
192 int optimize_size = 0;
193
194 /* The FUNCTION_DECL for the function currently being compiled,
195    or 0 if between functions.  */
196 tree current_function_decl;
197
198 /* Set to the FUNC_BEGIN label of the current function, or NULL
199    if none.  */
200 const char * current_function_func_begin_label;
201
202 /* Temporarily suppress certain warnings.
203    This is set while reading code from a system header file.  */
204
205 int in_system_header = 0;
206
207 /* Nonzero means to collect statistics which might be expensive
208    and to print them when we are done.  */
209 int flag_detailed_statistics = 0;
210
211 /* A random sequence of characters, unless overridden by user.  */
212 static const char *flag_random_seed;
213
214 /* A local time stamp derived from the time of compilation. It will be
215    zero if the system cannot provide a time.  It will be -1u, if the
216    user has specified a particular random seed.  */
217 unsigned local_tick;
218
219 /* -f flags.  */
220
221 /* Nonzero means `char' should be signed.  */
222
223 int flag_signed_char;
224
225 /* Nonzero means give an enum type only as many bytes as it needs.  A value
226    of 2 means it has not yet been initialized.  */
227
228 int flag_short_enums;
229
230 /* Nonzero if structures and unions should be returned in memory.
231
232    This should only be defined if compatibility with another compiler or
233    with an ABI is needed, because it results in slower code.  */
234
235 #ifndef DEFAULT_PCC_STRUCT_RETURN
236 #define DEFAULT_PCC_STRUCT_RETURN 1
237 #endif
238
239 /* Nonzero for -fpcc-struct-return: return values the same way PCC does.  */
240
241 int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
242
243 /* 0 means straightforward implementation of complex divide acceptable.
244    1 means wide ranges of inputs must work for complex divide.
245    2 means C99-like requirements for complex multiply and divide.  */
246
247 int flag_complex_method = 1;
248
249 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
250    not just because the tree inliner turned us off.  */
251
252 int flag_really_no_inline = 2;
253
254 /* Nonzero means we should be saving declaration info into a .X file.  */
255
256 int flag_gen_aux_info = 0;
257
258 /* Specified name of aux-info file.  */
259
260 const char *aux_info_file_name;
261
262 /* Nonzero if we are compiling code for a shared library, zero for
263    executable.  */
264
265 int flag_shlib;
266
267 /* Generate code for GNU or NeXT Objective-C runtime environment.  */
268
269 #ifdef NEXT_OBJC_RUNTIME
270 int flag_next_runtime = 1;
271 #else
272 int flag_next_runtime = 0;
273 #endif
274
275 /* Set to the default thread-local storage (tls) model to use.  */
276
277 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
278
279 /* Nonzero means change certain warnings into errors.
280    Usually these are warnings about failure to conform to some standard.  */
281
282 int flag_pedantic_errors = 0;
283
284 /* Nonzero means make permerror produce warnings instead of errors.  */
285
286 int flag_permissive = 0;
287
288 /* -dA causes debug commentary information to be produced in
289    the generated assembly code (to make it more readable).  This option
290    is generally only of use to those who actually need to read the
291    generated assembly code (perhaps while debugging the compiler itself).
292    Currently, this switch is only used by dwarfout.c; however, it is intended
293    to be a catchall for printing debug information in the assembler file.  */
294
295 int flag_debug_asm = 0;
296
297 /* -dP causes the rtl to be emitted as a comment in assembly.  */
298
299 int flag_dump_rtl_in_asm = 0;
300
301 /* When non-NULL, indicates that whenever space is allocated on the
302    stack, the resulting stack pointer must not pass this
303    address---that is, for stacks that grow downward, the stack pointer
304    must always be greater than or equal to this address; for stacks
305    that grow upward, the stack pointer must be less than this address.
306    At present, the rtx may be either a REG or a SYMBOL_REF, although
307    the support provided depends on the backend.  */
308 rtx stack_limit_rtx;
309
310 /* Nonzero if we should track variables.  When
311    flag_var_tracking == AUTODETECT_VALUE it will be set according
312    to optimize, debug_info_level and debug_hooks in process_options ().  */
313 int flag_var_tracking = AUTODETECT_VALUE;
314
315 /* True if the user has tagged the function with the 'section'
316    attribute.  */
317
318 bool user_defined_section_attribute = false;
319
320 /* Values of the -falign-* flags: how much to align labels in code.
321    0 means `use default', 1 means `don't align'.
322    For each variable, there is an _log variant which is the power
323    of two not less than the variable, for .align output.  */
324
325 int align_loops_log;
326 int align_loops_max_skip;
327 int align_jumps_log;
328 int align_jumps_max_skip;
329 int align_labels_log;
330 int align_labels_max_skip;
331 int align_functions_log;
332
333 typedef struct
334 {
335   const char *const string;
336   int *const variable;
337   const int on_value;
338 }
339 lang_independent_options;
340
341 /* Nonzero if subexpressions must be evaluated from left-to-right.  */
342 int flag_evaluation_order = 0;
343
344 /* The user symbol prefix after having resolved same.  */
345 const char *user_label_prefix;
346
347 static const param_info lang_independent_params[] = {
348 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \
349   { OPTION, DEFAULT, false, MIN, MAX, HELP },
350 #include "params.def"
351 #undef DEFPARAM
352   { NULL, 0, false, 0, 0, NULL }
353 };
354
355 /* Output files for assembler code (real compiler output)
356    and debugging dumps.  */
357
358 FILE *asm_out_file;
359 FILE *aux_info_file;
360 FILE *dump_file = NULL;
361 const char *dump_file_name;
362
363 /* The current working directory of a translation.  It's generally the
364    directory from which compilation was initiated, but a preprocessed
365    file may specify the original directory in which it was
366    created.  */
367
368 static const char *src_pwd;
369
370 /* Initialize src_pwd with the given string, and return true.  If it
371    was already initialized, return false.  As a special case, it may
372    be called with a NULL argument to test whether src_pwd has NOT been
373    initialized yet.  */
374
375 bool
376 set_src_pwd (const char *pwd)
377 {
378   if (src_pwd)
379     {
380       if (strcmp (src_pwd, pwd) == 0)
381         return true;
382       else
383         return false;
384     }
385
386   src_pwd = xstrdup (pwd);
387   return true;
388 }
389
390 /* Return the directory from which the translation unit was initiated,
391    in case set_src_pwd() was not called before to assign it a
392    different value.  */
393
394 const char *
395 get_src_pwd (void)
396 {
397   if (! src_pwd)
398     {
399       src_pwd = getpwd ();
400       if (!src_pwd)
401         src_pwd = ".";
402     }
403
404    return src_pwd;
405 }
406
407 /* Called when the start of a function definition is parsed,
408    this function prints on stderr the name of the function.  */
409 void
410 announce_function (tree decl)
411 {
412   if (!quiet_flag)
413     {
414       if (rtl_dump_and_exit)
415         fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
416       else
417         fprintf (stderr, " %s", lang_hooks.decl_printable_name (decl, 2));
418       fflush (stderr);
419       pp_needs_newline (global_dc->printer) = true;
420       diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL);
421     }
422 }
423
424 /* Initialize local_tick with the time of day, or -1 if
425    flag_random_seed is set.  */
426
427 static void
428 init_local_tick (void)
429 {
430   if (!flag_random_seed)
431     {
432       /* Get some more or less random data.  */
433 #ifdef HAVE_GETTIMEOFDAY
434       {
435         struct timeval tv;
436
437         gettimeofday (&tv, NULL);
438         local_tick = tv.tv_sec * 1000 + tv.tv_usec / 1000;
439       }
440 #else
441       {
442         time_t now = time (NULL);
443
444         if (now != (time_t)-1)
445           local_tick = (unsigned) now;
446       }
447 #endif
448     }
449   else
450     local_tick = -1;
451 }
452
453 /* Set up a default flag_random_seed and local_tick, unless the user
454    already specified one.  Must be called after init_local_tick.  */
455
456 static void
457 init_random_seed (void)
458 {
459   unsigned HOST_WIDE_INT value;
460   static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
461
462   value = local_tick ^ getpid ();
463
464   sprintf (random_seed, HOST_WIDE_INT_PRINT_HEX, value);
465   flag_random_seed = random_seed;
466 }
467
468 /* Obtain the random_seed string.  Unless NOINIT, initialize it if
469    it's not provided in the command line.  */
470
471 const char *
472 get_random_seed (bool noinit)
473 {
474   if (!flag_random_seed && !noinit)
475     init_random_seed ();
476   return flag_random_seed;
477 }
478
479 /* Modify the random_seed string to VAL.  Return its previous
480    value.  */
481
482 const char *
483 set_random_seed (const char *val)
484 {
485   const char *old = flag_random_seed;
486   flag_random_seed = val;
487   return old;
488 }
489
490 /* Decode the string P as an integral parameter.
491    If the string is indeed an integer return its numeric value else
492    issue an Invalid Option error for the option PNAME and return DEFVAL.
493    If PNAME is zero just return DEFVAL, do not call error.  */
494
495 int
496 read_integral_parameter (const char *p, const char *pname, const int  defval)
497 {
498   const char *endp = p;
499
500   while (*endp)
501     {
502       if (ISDIGIT (*endp))
503         endp++;
504       else
505         break;
506     }
507
508   if (*endp != 0)
509     {
510       if (pname != 0)
511         error ("invalid option argument %qs", pname);
512       return defval;
513     }
514
515   return atoi (p);
516 }
517
518 /* When compiling with a recent enough GCC, we use the GNU C "extern inline"
519    for floor_log2 and exact_log2; see toplev.h.  That construct, however,
520    conflicts with the ISO C++ One Definition Rule.   */
521
522 #if GCC_VERSION < 3004 || !defined (__cplusplus)
523
524 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
525    If X is 0, return -1.  */
526
527 int
528 floor_log2 (unsigned HOST_WIDE_INT x)
529 {
530   int t = 0;
531
532   if (x == 0)
533     return -1;
534
535 #ifdef CLZ_HWI
536   t = HOST_BITS_PER_WIDE_INT - 1 - (int) CLZ_HWI (x);
537 #else
538   if (HOST_BITS_PER_WIDE_INT > 64)
539     if (x >= (unsigned HOST_WIDE_INT) 1 << (t + 64))
540       t += 64;
541   if (HOST_BITS_PER_WIDE_INT > 32)
542     if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 32))
543       t += 32;
544   if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 16))
545     t += 16;
546   if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 8))
547     t += 8;
548   if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 4))
549     t += 4;
550   if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 2))
551     t += 2;
552   if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 1))
553     t += 1;
554 #endif
555
556   return t;
557 }
558
559 /* Return the logarithm of X, base 2, considering X unsigned,
560    if X is a power of 2.  Otherwise, returns -1.  */
561
562 int
563 exact_log2 (unsigned HOST_WIDE_INT x)
564 {
565   if (x != (x & -x))
566     return -1;
567 #ifdef CTZ_HWI
568   return x ? CTZ_HWI (x) : -1;
569 #else
570   return floor_log2 (x);
571 #endif
572 }
573
574 #endif /*  GCC_VERSION < 3004 || !defined (__cplusplus)  */
575
576 /* Handler for fatal signals, such as SIGSEGV.  These are transformed
577    into ICE messages, which is much more user friendly.  In case the
578    error printer crashes, reset the signal to prevent infinite recursion.  */
579
580 static void
581 crash_signal (int signo)
582 {
583   signal (signo, SIG_DFL);
584
585   /* If we crashed while processing an ASM statement, then be a little more
586      graceful.  It's most likely the user's fault.  */
587   if (this_is_asm_operands)
588     {
589       output_operand_lossage ("unrecoverable error");
590       exit (FATAL_EXIT_CODE);
591     }
592
593   internal_error ("%s", strsignal (signo));
594 }
595
596 /* Arrange to dump core on error.  (The regular error message is still
597    printed first, except in the case of abort().)  */
598
599 static void
600 setup_core_dumping (void)
601 {
602 #ifdef SIGABRT
603   signal (SIGABRT, SIG_DFL);
604 #endif
605 #if defined(HAVE_SETRLIMIT)
606   {
607     struct rlimit rlim;
608     if (getrlimit (RLIMIT_CORE, &rlim) != 0)
609       fatal_error ("getting core file size maximum limit: %m");
610     rlim.rlim_cur = rlim.rlim_max;
611     if (setrlimit (RLIMIT_CORE, &rlim) != 0)
612       fatal_error ("setting core file size limit to maximum: %m");
613   }
614 #endif
615   diagnostic_abort_on_error (global_dc);
616 }
617
618
619 /* Strip off a legitimate source ending from the input string NAME of
620    length LEN.  Rather than having to know the names used by all of
621    our front ends, we strip off an ending of a period followed by
622    up to five characters.  (Java uses ".class".)  */
623
624 void
625 strip_off_ending (char *name, int len)
626 {
627   int i;
628   for (i = 2; i < 6 && len > i; i++)
629     {
630       if (name[len - i] == '.')
631         {
632           name[len - i] = '\0';
633           break;
634         }
635     }
636 }
637
638 /* Output a quoted string.  */
639
640 void
641 output_quoted_string (FILE *asm_file, const char *string)
642 {
643 #ifdef OUTPUT_QUOTED_STRING
644   OUTPUT_QUOTED_STRING (asm_file, string);
645 #else
646   char c;
647
648   putc ('\"', asm_file);
649   while ((c = *string++) != 0)
650     {
651       if (ISPRINT (c))
652         {
653           if (c == '\"' || c == '\\')
654             putc ('\\', asm_file);
655           putc (c, asm_file);
656         }
657       else
658         fprintf (asm_file, "\\%03o", (unsigned char) c);
659     }
660   putc ('\"', asm_file);
661 #endif
662 }
663
664 /* Output a file name in the form wanted by System V.  */
665
666 void
667 output_file_directive (FILE *asm_file, const char *input_name)
668 {
669   int len;
670   const char *na;
671
672   if (input_name == NULL)
673     input_name = "<stdin>";
674   else
675     input_name = remap_debug_filename (input_name);
676
677   len = strlen (input_name);
678   na = input_name + len;
679
680   /* NA gets INPUT_NAME sans directory names.  */
681   while (na > input_name)
682     {
683       if (IS_DIR_SEPARATOR (na[-1]))
684         break;
685       na--;
686     }
687
688 #ifdef ASM_OUTPUT_SOURCE_FILENAME
689   ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
690 #else
691   fprintf (asm_file, "\t.file\t");
692   output_quoted_string (asm_file, na);
693   fputc ('\n', asm_file);
694 #endif
695 }
696
697 /* A subroutine of wrapup_global_declarations.  We've come to the end of
698    the compilation unit.  All deferred variables should be undeferred,
699    and all incomplete decls should be finalized.  */
700
701 void
702 wrapup_global_declaration_1 (tree decl)
703 {
704   /* We're not deferring this any longer.  Assignment is conditional to
705      avoid needlessly dirtying PCH pages.  */
706   if (CODE_CONTAINS_STRUCT (TREE_CODE (decl), TS_DECL_WITH_VIS)
707       && DECL_DEFER_OUTPUT (decl) != 0)
708     DECL_DEFER_OUTPUT (decl) = 0;
709
710   if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
711     lang_hooks.finish_incomplete_decl (decl);
712 }
713
714 /* A subroutine of wrapup_global_declarations.  Decide whether or not DECL
715    needs to be output.  Return true if it is output.  */
716
717 bool
718 wrapup_global_declaration_2 (tree decl)
719 {
720   if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
721     return false;
722
723   /* Don't write out static consts, unless we still need them.
724
725      We also keep static consts if not optimizing (for debugging),
726      unless the user specified -fno-keep-static-consts.
727      ??? They might be better written into the debug information.
728      This is possible when using DWARF.
729
730      A language processor that wants static constants to be always
731      written out (even if it is not used) is responsible for
732      calling rest_of_decl_compilation itself.  E.g. the C front-end
733      calls rest_of_decl_compilation from finish_decl.
734      One motivation for this is that is conventional in some
735      environments to write things like:
736      static const char rcsid[] = "... version string ...";
737      intending to force the string to be in the executable.
738
739      A language processor that would prefer to have unneeded
740      static constants "optimized away" would just defer writing
741      them out until here.  E.g. C++ does this, because static
742      constants are often defined in header files.
743
744      ??? A tempting alternative (for both C and C++) would be
745      to force a constant to be written if and only if it is
746      defined in a main file, as opposed to an include file.  */
747
748   if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
749     {
750       struct varpool_node *node;
751       bool needed = true;
752       node = varpool_node (decl);
753
754       if (node->finalized)
755         needed = false;
756       else if (node->alias)
757         needed = false;
758       else if (!cgraph_global_info_ready
759                && (TREE_USED (decl)
760                    || TREE_USED (DECL_ASSEMBLER_NAME (decl))))
761         /* needed */;
762       else if (node->needed)
763         /* needed */;
764       else if (DECL_COMDAT (decl))
765         needed = false;
766       else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
767                && (optimize || !flag_keep_static_consts
768                    || DECL_ARTIFICIAL (decl)))
769         needed = false;
770
771       if (needed)
772         {
773           rest_of_decl_compilation (decl, 1, 1);
774           return true;
775         }
776     }
777
778   return false;
779 }
780
781 /* Do any final processing required for the declarations in VEC, of
782    which there are LEN.  We write out inline functions and variables
783    that have been deferred until this point, but which are required.
784    Returns nonzero if anything was put out.  */
785
786 bool
787 wrapup_global_declarations (tree *vec, int len)
788 {
789   bool reconsider, output_something = false;
790   int i;
791
792   for (i = 0; i < len; i++)
793     wrapup_global_declaration_1 (vec[i]);
794
795   /* Now emit any global variables or functions that we have been
796      putting off.  We need to loop in case one of the things emitted
797      here references another one which comes earlier in the list.  */
798   do
799     {
800       reconsider = false;
801       for (i = 0; i < len; i++)
802         reconsider |= wrapup_global_declaration_2 (vec[i]);
803       if (reconsider)
804         output_something = true;
805     }
806   while (reconsider);
807
808   return output_something;
809 }
810
811 /* A subroutine of check_global_declarations.  Issue appropriate warnings
812    for the global declaration DECL.  */
813
814 void
815 check_global_declaration_1 (tree decl)
816 {
817   /* Warn about any function declared static but not defined.  We don't
818      warn about variables, because many programs have static variables
819      that exist only to get some text into the object file.  */
820   if (TREE_CODE (decl) == FUNCTION_DECL
821       && DECL_INITIAL (decl) == 0
822       && DECL_EXTERNAL (decl)
823       && ! DECL_ARTIFICIAL (decl)
824       && ! TREE_NO_WARNING (decl)
825       && ! TREE_PUBLIC (decl)
826       && (warn_unused_function
827           || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
828     {
829       if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
830         pedwarn ("%q+F used but never defined", decl);
831       else
832         warning (OPT_Wunused_function, "%q+F declared %<static%> but never defined", decl);
833       /* This symbol is effectively an "extern" declaration now.  */
834       TREE_PUBLIC (decl) = 1;
835       assemble_external (decl);
836     }
837
838   /* Warn about static fns or vars defined but not used.  */
839   if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
840        /* We don't warn about "static const" variables because the
841           "rcs_id" idiom uses that construction.  */
842        || (warn_unused_variable
843            && TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
844       && ! DECL_IN_SYSTEM_HEADER (decl)
845       && ! TREE_USED (decl)
846       /* The TREE_USED bit for file-scope decls is kept in the identifier,
847          to handle multiple external decls in different scopes.  */
848       && ! (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl)))
849       && ! DECL_EXTERNAL (decl)
850       && ! TREE_PUBLIC (decl)
851       /* A volatile variable might be used in some non-obvious way.  */
852       && ! TREE_THIS_VOLATILE (decl)
853       /* Global register variables must be declared to reserve them.  */
854       && ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
855       /* Otherwise, ask the language.  */
856       && lang_hooks.decls.warn_unused_global (decl))
857     warning ((TREE_CODE (decl) == FUNCTION_DECL) 
858              ? OPT_Wunused_function 
859              : OPT_Wunused_variable, 
860              "%q+D defined but not used", decl);
861 }
862
863 /* Issue appropriate warnings for the global declarations in VEC (of
864    which there are LEN).  */
865
866 void
867 check_global_declarations (tree *vec, int len)
868 {
869   int i;
870
871   for (i = 0; i < len; i++)
872     check_global_declaration_1 (vec[i]);
873 }
874
875 /* Emit debugging information for all global declarations in VEC.  */
876
877 void
878 emit_debug_global_declarations (tree *vec, int len)
879 {
880   int i;
881
882   /* Avoid confusing the debug information machinery when there are errors.  */
883   if (errorcount != 0 || sorrycount != 0)
884     return;
885
886   timevar_push (TV_SYMOUT);
887   for (i = 0; i < len; i++)
888     debug_hooks->global_decl (vec[i]);
889   timevar_pop (TV_SYMOUT);
890 }
891
892 /* Warn about a use of an identifier which was marked deprecated.  */
893 void
894 warn_deprecated_use (tree node)
895 {
896   if (node == 0 || !warn_deprecated_decl)
897     return;
898
899   if (DECL_P (node))
900     {
901       expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (node));
902       warning (OPT_Wdeprecated_declarations,
903                "%qD is deprecated (declared at %s:%d)",
904                node, xloc.file, xloc.line);
905     }
906   else if (TYPE_P (node))
907     {
908       const char *what = NULL;
909       tree decl = TYPE_STUB_DECL (node);
910
911       if (TYPE_NAME (node))
912         {
913           if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
914             what = IDENTIFIER_POINTER (TYPE_NAME (node));
915           else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
916                    && DECL_NAME (TYPE_NAME (node)))
917             what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
918         }
919
920       if (decl)
921         {
922           expanded_location xloc
923             = expand_location (DECL_SOURCE_LOCATION (decl));
924           if (what)
925             warning (OPT_Wdeprecated_declarations,
926                      "%qs is deprecated (declared at %s:%d)", what,
927                      xloc.file, xloc.line);
928           else
929             warning (OPT_Wdeprecated_declarations,
930                      "type is deprecated (declared at %s:%d)",
931                      xloc.file, xloc.line);
932         }
933       else
934         {
935           if (what)
936             warning (OPT_Wdeprecated_declarations, "%qs is deprecated", what);
937           else
938             warning (OPT_Wdeprecated_declarations, "type is deprecated");
939         }
940     }
941 }
942
943 /* Compile an entire translation unit.  Write a file of assembly
944    output and various debugging dumps.  */
945
946 static void
947 compile_file (void)
948 {
949   /* Initialize yet another pass.  */
950
951   init_cgraph ();
952   init_final (main_input_filename);
953   coverage_init (aux_base_name);
954
955   timevar_push (TV_PARSE);
956
957   /* Call the parser, which parses the entire file (calling
958      rest_of_compilation for each function).  */
959   lang_hooks.parse_file (set_yydebug);
960
961   /* In case there were missing block closers,
962      get us back to the global binding level.  */
963   lang_hooks.clear_binding_stack ();
964
965   /* Compilation is now finished except for writing
966      what's left of the symbol table output.  */
967   timevar_pop (TV_PARSE);
968
969   if (flag_syntax_only)
970     return;
971
972   lang_hooks.decls.final_write_globals ();
973
974   if (errorcount || sorrycount)
975     return;
976
977   varpool_assemble_pending_decls ();
978   finish_aliases_2 ();
979
980   /* This must occur after the loop to output deferred functions.
981      Else the coverage initializer would not be emitted if all the
982      functions in this compilation unit were deferred.  */
983   coverage_finish ();
984
985   /* Likewise for mudflap static object registrations.  */
986   if (flag_mudflap)
987     mudflap_finish_file ();
988
989   /* Likewise for emulated thread-local storage.  */
990   if (!targetm.have_tls)
991     emutls_finish ();
992
993   output_shared_constant_pool ();
994   output_object_blocks ();
995
996   /* Write out any pending weak symbol declarations.  */
997   weak_finish ();
998
999   /* Do dbx symbols.  */
1000   timevar_push (TV_SYMOUT);
1001
1002 #if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
1003   if (dwarf2out_do_frame ())
1004     dwarf2out_frame_finish ();
1005 #endif
1006
1007   (*debug_hooks->finish) (main_input_filename);
1008   timevar_pop (TV_SYMOUT);
1009
1010   /* Output some stuff at end of file if nec.  */
1011
1012   dw2_output_indirect_constants ();
1013
1014   /* Flush any pending external directives.  */
1015   process_pending_assemble_externals ();
1016
1017   /* Attach a special .ident directive to the end of the file to identify
1018      the version of GCC which compiled this code.  The format of the .ident
1019      string is patterned after the ones produced by native SVR4 compilers.  */
1020 #ifdef IDENT_ASM_OP
1021   if (!flag_no_ident)
1022     {
1023       const char *pkg_version = "(GNU) ";
1024
1025       if (strcmp ("(GCC) ", pkgversion_string))
1026         pkg_version = pkgversion_string;
1027       fprintf (asm_out_file, "%s\"GCC: %s%s\"\n",
1028                IDENT_ASM_OP, pkg_version, version_string);
1029     }
1030 #endif
1031
1032   /* This must be at the end.  Some target ports emit end of file directives
1033      into the assembly file here, and hence we can not output anything to the
1034      assembly file after this point.  */
1035   targetm.asm_out.file_end ();
1036 }
1037
1038 /* Parse a -d... command line switch.  */
1039
1040 void
1041 decode_d_option (const char *arg)
1042 {
1043   int c;
1044
1045   while (*arg)
1046     switch (c = *arg++)
1047       {
1048       case 'A':
1049         flag_debug_asm = 1;
1050         break;
1051       case 'p':
1052         flag_print_asm_name = 1;
1053         break;
1054       case 'P':
1055         flag_dump_rtl_in_asm = 1;
1056         flag_print_asm_name = 1;
1057         break;
1058       case 'v':
1059         graph_dump_format = vcg;
1060         break;
1061       case 'x':
1062         rtl_dump_and_exit = 1;
1063         break;
1064       case 'y':
1065         set_yydebug = 1;
1066         break;
1067       case 'D': /* These are handled by the preprocessor.  */
1068       case 'I':
1069         break;
1070       case 'H':
1071         setup_core_dumping();
1072         break;
1073
1074       case 'a':
1075       default:
1076         if (!enable_rtl_dump_file (c))
1077           warning (0, "unrecognized gcc debugging option: %c", c);
1078         break;
1079       }
1080 }
1081
1082 /* Indexed by enum debug_info_type.  */
1083 const char *const debug_type_names[] =
1084 {
1085   "none", "stabs", "coff", "dwarf-2", "xcoff", "vms"
1086 };
1087
1088 /* Print version information to FILE.
1089    Each line begins with INDENT (for the case where FILE is the
1090    assembler output file).  */
1091
1092 void
1093 print_version (FILE *file, const char *indent)
1094 {
1095   static const char fmt1[] =
1096 #ifdef __GNUC__
1097     N_("%s%s%s %sversion %s (%s)\n%s\tcompiled by GNU C version %s, ")
1098 #else
1099     N_("%s%s%s %sversion %s (%s) compiled by CC, ")
1100 #endif
1101     ;
1102   static const char fmt2[] =
1103     N_("GMP version %s, MPFR version %s.\n");
1104   static const char fmt3[] =
1105     N_("%s%swarning: %s header version %s differs from library version %s.\n");
1106   static const char fmt4[] =
1107     N_("%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n");
1108 #ifndef __VERSION__
1109 #define __VERSION__ "[?]"
1110 #endif
1111   fprintf (file,
1112            file == stderr ? _(fmt1) : fmt1,
1113            indent, *indent != 0 ? " " : "",
1114            lang_hooks.name, pkgversion_string, version_string, TARGET_NAME,
1115            indent, __VERSION__);
1116
1117   /* We need to stringify the GMP macro values.  Ugh, gmp_version has
1118      two string formats, "i.j.k" and "i.j" when k is zero.  */
1119 #define GCC_GMP_STRINGIFY_VERSION3(X) #X
1120 #define GCC_GMP_STRINGIFY_VERSION2(X) GCC_GMP_STRINGIFY_VERSION3(X)
1121 #if __GNU_MP_VERSION_PATCHLEVEL == 0
1122 #define GCC_GMP_STRINGIFY_VERSION GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION) "." \
1123   GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_MINOR)
1124 #else
1125 #define GCC_GMP_STRINGIFY_VERSION GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION) "." \
1126   GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_MINOR) "." \
1127   GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_PATCHLEVEL)
1128 #endif
1129   fprintf (file,
1130            file == stderr ? _(fmt2) : fmt2,
1131            GCC_GMP_STRINGIFY_VERSION, MPFR_VERSION_STRING);
1132   if (strcmp (GCC_GMP_STRINGIFY_VERSION, gmp_version))
1133     fprintf (file,
1134              file == stderr ? _(fmt3) : fmt3,
1135              indent, *indent != 0 ? " " : "",
1136              "GMP", GCC_GMP_STRINGIFY_VERSION, gmp_version);
1137   if (strcmp (MPFR_VERSION_STRING, mpfr_get_version ()))
1138     fprintf (file,
1139              file == stderr ? _(fmt3) : fmt3,
1140              indent, *indent != 0 ? " " : "",
1141              "MPFR", MPFR_VERSION_STRING, mpfr_get_version ());
1142   fprintf (file,
1143            file == stderr ? _(fmt4) : fmt4,
1144            indent, *indent != 0 ? " " : "",
1145            PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
1146 }
1147
1148 #ifdef ASM_COMMENT_START
1149 static int
1150 print_to_asm_out_file (print_switch_type type, const char * text)
1151 {
1152   bool prepend_sep = true;
1153
1154   switch (type)
1155     {
1156     case SWITCH_TYPE_LINE_END:
1157       putc ('\n', asm_out_file);
1158       return 1;
1159
1160     case SWITCH_TYPE_LINE_START:
1161       fputs (ASM_COMMENT_START, asm_out_file);
1162       return strlen (ASM_COMMENT_START);
1163
1164     case SWITCH_TYPE_DESCRIPTIVE:
1165       if (ASM_COMMENT_START[0] == 0)
1166         prepend_sep = false;
1167       /* Drop through.  */
1168     case SWITCH_TYPE_PASSED:
1169     case SWITCH_TYPE_ENABLED:
1170       if (prepend_sep)
1171         fputc (' ', asm_out_file);
1172       fprintf (asm_out_file, text);
1173       /* No need to return the length here as
1174          print_single_switch has already done it.  */
1175       return 0;
1176
1177     default:
1178       return -1;
1179     }
1180 }
1181 #endif
1182
1183 static int
1184 print_to_stderr (print_switch_type type, const char * text)
1185 {
1186   switch (type)
1187     {
1188     case SWITCH_TYPE_LINE_END:
1189       putc ('\n', stderr);
1190       return 1;
1191
1192     case SWITCH_TYPE_LINE_START:
1193       return 0;
1194       
1195     case SWITCH_TYPE_PASSED:
1196     case SWITCH_TYPE_ENABLED:
1197       fputc (' ', stderr);
1198       /* Drop through.  */
1199
1200     case SWITCH_TYPE_DESCRIPTIVE:
1201       fprintf (stderr, text);
1202       /* No need to return the length here as
1203          print_single_switch has already done it.  */
1204       return 0;
1205
1206     default:
1207       return -1;
1208     }
1209 }
1210
1211 /* Print an option value and return the adjusted position in the line.
1212    ??? print_fn doesn't handle errors, eg disk full; presumably other
1213    code will catch a disk full though.  */
1214
1215 static int
1216 print_single_switch (print_switch_fn_type print_fn,
1217                      int pos,
1218                      print_switch_type type,
1219                      const char * text)
1220 {
1221   /* The ultrix fprintf returns 0 on success, so compute the result
1222      we want here since we need it for the following test.  The +1
1223      is for the separator character that will probably be emitted.  */
1224   int len = strlen (text) + 1;
1225
1226   if (pos != 0
1227       && pos + len > MAX_LINE)
1228     {
1229       print_fn (SWITCH_TYPE_LINE_END, NULL);
1230       pos = 0;
1231     }
1232
1233   if (pos == 0)
1234     pos += print_fn (SWITCH_TYPE_LINE_START, NULL);
1235
1236   print_fn (type, text);
1237   return pos + len;
1238 }
1239
1240 /* Print active target switches using PRINT_FN.
1241    POS is the current cursor position and MAX is the size of a "line".
1242    Each line begins with INDENT and ends with TERM.
1243    Each switch is separated from the next by SEP.  */
1244
1245 static void
1246 print_switch_values (print_switch_fn_type print_fn)
1247 {
1248   int pos = 0;
1249   size_t j;
1250   const char **p;
1251
1252   /* Fill in the -frandom-seed option, if the user didn't pass it, so
1253      that it can be printed below.  This helps reproducibility.  */
1254   if (!flag_random_seed)
1255     init_random_seed ();
1256
1257   /* Print the options as passed.  */
1258   pos = print_single_switch (print_fn, pos,
1259                              SWITCH_TYPE_DESCRIPTIVE, _("options passed: "));
1260
1261   for (p = &save_argv[1]; *p != NULL; p++)
1262     {
1263       if (**p == '-')
1264         {
1265           /* Ignore these.  */
1266           if (strcmp (*p, "-o") == 0
1267               || strcmp (*p, "-dumpbase") == 0
1268               || strcmp (*p, "-auxbase") == 0)
1269             {
1270               if (p[1] != NULL)
1271                 p++;
1272               continue;
1273             }
1274
1275           if (strcmp (*p, "-quiet") == 0
1276               || strcmp (*p, "-version") == 0)
1277             continue;
1278
1279           if ((*p)[1] == 'd')
1280             continue;
1281         }
1282
1283       pos = print_single_switch (print_fn, pos, SWITCH_TYPE_PASSED, *p);
1284     }
1285
1286   if (pos > 0)
1287     print_fn (SWITCH_TYPE_LINE_END, NULL);
1288
1289   /* Print the -f and -m options that have been enabled.
1290      We don't handle language specific options but printing argv
1291      should suffice.  */
1292   pos = print_single_switch (print_fn, 0,
1293                              SWITCH_TYPE_DESCRIPTIVE, _("options enabled: "));
1294
1295   for (j = 0; j < cl_options_count; j++)
1296     if ((cl_options[j].flags & CL_REPORT)
1297         && option_enabled (j) > 0)
1298       pos = print_single_switch (print_fn, pos,
1299                                  SWITCH_TYPE_ENABLED, cl_options[j].opt_text);
1300
1301   print_fn (SWITCH_TYPE_LINE_END, NULL);
1302 }
1303
1304 /* Open assembly code output file.  Do this even if -fsyntax-only is
1305    on, because then the driver will have provided the name of a
1306    temporary file or bit bucket for us.  NAME is the file specified on
1307    the command line, possibly NULL.  */
1308 static void
1309 init_asm_output (const char *name)
1310 {
1311   if (name == NULL && asm_file_name == 0)
1312     asm_out_file = stdout;
1313   else
1314     {
1315       if (asm_file_name == 0)
1316         {
1317           int len = strlen (dump_base_name);
1318           char *dumpname = XNEWVEC (char, len + 6);
1319
1320           memcpy (dumpname, dump_base_name, len + 1);
1321           strip_off_ending (dumpname, len);
1322           strcat (dumpname, ".s");
1323           asm_file_name = dumpname;
1324         }
1325       if (!strcmp (asm_file_name, "-"))
1326         asm_out_file = stdout;
1327       else
1328         asm_out_file = fopen (asm_file_name, "w+b");
1329       if (asm_out_file == 0)
1330         fatal_error ("can%'t open %s for writing: %m", asm_file_name);
1331     }
1332
1333   if (!flag_syntax_only)
1334     {
1335       targetm.asm_out.file_start ();
1336
1337       if (flag_record_gcc_switches)
1338         {
1339           if (targetm.asm_out.record_gcc_switches)
1340             {
1341               /* Let the target know that we are about to start recording.  */
1342               targetm.asm_out.record_gcc_switches (SWITCH_TYPE_DESCRIPTIVE,
1343                                                    NULL);
1344               /* Now record the switches.  */
1345               print_switch_values (targetm.asm_out.record_gcc_switches);
1346               /* Let the target know that the recording is over.  */
1347               targetm.asm_out.record_gcc_switches (SWITCH_TYPE_DESCRIPTIVE,
1348                                                    NULL);
1349             }
1350           else
1351             inform ("-frecord-gcc-switches is not supported by the current target");
1352         }
1353
1354 #ifdef ASM_COMMENT_START
1355       if (flag_verbose_asm)
1356         {
1357           /* Print the list of switches in effect
1358              into the assembler file as comments.  */
1359           print_version (asm_out_file, ASM_COMMENT_START);
1360           print_switch_values (print_to_asm_out_file);
1361           fprintf (asm_out_file, "\n");
1362         }
1363 #endif
1364     }
1365 }
1366
1367 /* Return true if the state of option OPTION should be stored in PCH files
1368    and checked by default_pch_valid_p.  Store the option's current state
1369    in STATE if so.  */
1370
1371 static inline bool
1372 option_affects_pch_p (int option, struct cl_option_state *state)
1373 {
1374   if ((cl_options[option].flags & CL_TARGET) == 0)
1375     return false;
1376   if (cl_options[option].flag_var == &target_flags)
1377     if (targetm.check_pch_target_flags)
1378       return false;
1379   return get_option_state (option, state);
1380 }
1381
1382 /* Default version of get_pch_validity.
1383    By default, every flag difference is fatal; that will be mostly right for
1384    most targets, but completely right for very few.  */
1385
1386 void *
1387 default_get_pch_validity (size_t *len)
1388 {
1389   struct cl_option_state state;
1390   size_t i;
1391   char *result, *r;
1392
1393   *len = 2;
1394   if (targetm.check_pch_target_flags)
1395     *len += sizeof (target_flags);
1396   for (i = 0; i < cl_options_count; i++)
1397     if (option_affects_pch_p (i, &state))
1398       *len += state.size;
1399
1400   result = r = XNEWVEC (char, *len);
1401   r[0] = flag_pic;
1402   r[1] = flag_pie;
1403   r += 2;
1404   if (targetm.check_pch_target_flags)
1405     {
1406       memcpy (r, &target_flags, sizeof (target_flags));
1407       r += sizeof (target_flags);
1408     }
1409
1410   for (i = 0; i < cl_options_count; i++)
1411     if (option_affects_pch_p (i, &state))
1412       {
1413         memcpy (r, state.data, state.size);
1414         r += state.size;
1415       }
1416
1417   return result;
1418 }
1419
1420 /* Return a message which says that a PCH file was created with a different
1421    setting of OPTION.  */
1422
1423 static const char *
1424 pch_option_mismatch (const char *option)
1425 {
1426   char *r;
1427
1428   asprintf (&r, _("created and used with differing settings of '%s'"), option);
1429   if (r == NULL)
1430     return _("out of memory");
1431   return r;
1432 }
1433
1434 /* Default version of pch_valid_p.  */
1435
1436 const char *
1437 default_pch_valid_p (const void *data_p, size_t len)
1438 {
1439   struct cl_option_state state;
1440   const char *data = (const char *)data_p;
1441   size_t i;
1442
1443   /* -fpic and -fpie also usually make a PCH invalid.  */
1444   if (data[0] != flag_pic)
1445     return _("created and used with different settings of -fpic");
1446   if (data[1] != flag_pie)
1447     return _("created and used with different settings of -fpie");
1448   data += 2;
1449
1450   /* Check target_flags.  */
1451   if (targetm.check_pch_target_flags)
1452     {
1453       int tf;
1454       const char *r;
1455
1456       memcpy (&tf, data, sizeof (target_flags));
1457       data += sizeof (target_flags);
1458       len -= sizeof (target_flags);
1459       r = targetm.check_pch_target_flags (tf);
1460       if (r != NULL)
1461         return r;
1462     }
1463
1464   for (i = 0; i < cl_options_count; i++)
1465     if (option_affects_pch_p (i, &state))
1466       {
1467         if (memcmp (data, state.data, state.size) != 0)
1468           return pch_option_mismatch (cl_options[i].opt_text);
1469         data += state.size;
1470         len -= state.size;
1471       }
1472
1473   return NULL;
1474 }
1475
1476 /* Default tree printer.   Handles declarations only.  */
1477 static bool
1478 default_tree_printer (pretty_printer * pp, text_info *text, const char *spec,
1479                       int precision, bool wide, bool set_locus, bool hash)
1480 {
1481   tree t;
1482
1483   /* FUTURE: %+x should set the locus.  */
1484   if (precision != 0 || wide || hash)
1485     return false;
1486
1487   switch (*spec)
1488     {
1489     case 'D':
1490       t = va_arg (*text->args_ptr, tree);
1491       if (DECL_DEBUG_EXPR_IS_FROM (t) && DECL_DEBUG_EXPR (t))
1492         t = DECL_DEBUG_EXPR (t);
1493       break;
1494
1495     case 'F':
1496     case 'T':
1497       t = va_arg (*text->args_ptr, tree);
1498       break;
1499
1500     default:
1501       return false;
1502     }
1503
1504   if (set_locus && text->locus)
1505     *text->locus = DECL_SOURCE_LOCATION (t);
1506
1507   if (DECL_P (t))
1508     {
1509       const char *n = DECL_NAME (t)
1510         ? lang_hooks.decl_printable_name (t, 2)
1511         : "<anonymous>";
1512       pp_string (pp, n);
1513     }
1514   else
1515     dump_generic_node (pp, t, 0, TDF_DIAGNOSTIC, 0);
1516
1517   return true;
1518 }
1519
1520 /* A helper function; used as the reallocator function for cpp's line
1521    table.  */
1522 static void *
1523 realloc_for_line_map (void *ptr, size_t len)
1524 {
1525   return ggc_realloc (ptr, len);
1526 }
1527
1528 /* Initialization of the front end environment, before command line
1529    options are parsed.  Signal handlers, internationalization etc.
1530    ARGV0 is main's argv[0].  */
1531 static void
1532 general_init (const char *argv0)
1533 {
1534   const char *p;
1535
1536   p = argv0 + strlen (argv0);
1537   while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
1538     --p;
1539   progname = p;
1540
1541   xmalloc_set_program_name (progname);
1542
1543   hex_init ();
1544
1545   /* Unlock the stdio streams.  */
1546   unlock_std_streams ();
1547
1548   gcc_init_libintl ();
1549
1550   /* Initialize the diagnostics reporting machinery, so option parsing
1551      can give warnings and errors.  */
1552   diagnostic_initialize (global_dc);
1553   /* Set a default printer.  Language specific initializations will
1554      override it later.  */
1555   pp_format_decoder (global_dc->printer) = &default_tree_printer;
1556
1557   /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages.  */
1558 #ifdef SIGSEGV
1559   signal (SIGSEGV, crash_signal);
1560 #endif
1561 #ifdef SIGILL
1562   signal (SIGILL, crash_signal);
1563 #endif
1564 #ifdef SIGBUS
1565   signal (SIGBUS, crash_signal);
1566 #endif
1567 #ifdef SIGABRT
1568   signal (SIGABRT, crash_signal);
1569 #endif
1570 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
1571   signal (SIGIOT, crash_signal);
1572 #endif
1573 #ifdef SIGFPE
1574   signal (SIGFPE, crash_signal);
1575 #endif
1576
1577   /* Other host-specific signal setup.  */
1578   (*host_hooks.extra_signals)();
1579
1580   /* Initialize the garbage-collector, string pools and tree type hash
1581      table.  */
1582   init_ggc ();
1583   init_stringpool ();
1584   line_table = GGC_NEW (struct line_maps);
1585   linemap_init (line_table);
1586   line_table->reallocator = realloc_for_line_map;
1587   init_ttree ();
1588
1589   /* Initialize register usage now so switches may override.  */
1590   init_reg_sets ();
1591
1592   /* Register the language-independent parameters.  */
1593   add_params (lang_independent_params, LAST_PARAM);
1594
1595   /* This must be done after add_params but before argument processing.  */
1596   init_ggc_heuristics();
1597   init_optimization_passes ();
1598 }
1599
1600 /* Return true if the current target supports -fsection-anchors.  */
1601
1602 static bool
1603 target_supports_section_anchors_p (void)
1604 {
1605   if (targetm.min_anchor_offset == 0 && targetm.max_anchor_offset == 0)
1606     return false;
1607
1608   if (targetm.asm_out.output_anchor == NULL)
1609     return false;
1610
1611   return true;
1612 }
1613
1614 /* Default the align_* variables to 1 if they're still unset, and
1615    set up the align_*_log variables.  */
1616 static void
1617 init_alignments (void)
1618 {
1619   if (align_loops <= 0)
1620     align_loops = 1;
1621   if (align_loops_max_skip > align_loops)
1622     align_loops_max_skip = align_loops - 1;
1623   align_loops_log = floor_log2 (align_loops * 2 - 1);
1624   if (align_jumps <= 0)
1625     align_jumps = 1;
1626   if (align_jumps_max_skip > align_jumps)
1627     align_jumps_max_skip = align_jumps - 1;
1628   align_jumps_log = floor_log2 (align_jumps * 2 - 1);
1629   if (align_labels <= 0)
1630     align_labels = 1;
1631   align_labels_log = floor_log2 (align_labels * 2 - 1);
1632   if (align_labels_max_skip > align_labels)
1633     align_labels_max_skip = align_labels - 1;
1634   if (align_functions <= 0)
1635     align_functions = 1;
1636   align_functions_log = floor_log2 (align_functions * 2 - 1);
1637 }
1638
1639 /* Process the options that have been parsed.  */
1640 static void
1641 process_options (void)
1642 {
1643   /* Just in case lang_hooks.post_options ends up calling a debug_hook.
1644      This can happen with incorrect pre-processed input. */
1645   debug_hooks = &do_nothing_debug_hooks;
1646
1647   /* Allow the front end to perform consistency checks and do further
1648      initialization based on the command line options.  This hook also
1649      sets the original filename if appropriate (e.g. foo.i -> foo.c)
1650      so we can correctly initialize debug output.  */
1651   no_backend = lang_hooks.post_options (&main_input_filename);
1652
1653 #ifdef OVERRIDE_OPTIONS
1654   /* Some machines may reject certain combinations of options.  */
1655   OVERRIDE_OPTIONS;
1656 #endif
1657
1658   if (flag_section_anchors && !target_supports_section_anchors_p ())
1659     {
1660       warning (OPT_fsection_anchors,
1661                "this target does not support %qs", "-fsection-anchors");
1662       flag_section_anchors = 0;
1663     }
1664
1665   if (flag_short_enums == 2)
1666     flag_short_enums = targetm.default_short_enums ();
1667
1668   /* Set aux_base_name if not already set.  */
1669   if (aux_base_name)
1670     ;
1671   else if (main_input_filename)
1672     {
1673       char *name = xstrdup (lbasename (main_input_filename));
1674
1675       strip_off_ending (name, strlen (name));
1676       aux_base_name = name;
1677     }
1678   else
1679     aux_base_name = "gccaux";
1680
1681   /* Unrolling all loops implies that standard loop unrolling must also
1682      be done.  */
1683   if (flag_unroll_all_loops)
1684     flag_unroll_loops = 1;
1685
1686   /* The loop unrolling code assumes that cse will be run after loop.
1687      web and rename-registers also help when run after loop unrolling.  */
1688
1689   if (flag_rerun_cse_after_loop == AUTODETECT_VALUE)
1690     flag_rerun_cse_after_loop = flag_unroll_loops || flag_peel_loops;
1691   if (flag_web == AUTODETECT_VALUE)
1692     flag_web = flag_unroll_loops || flag_peel_loops;
1693   if (flag_rename_registers == AUTODETECT_VALUE)
1694     flag_rename_registers = flag_unroll_loops || flag_peel_loops;
1695
1696   if (flag_non_call_exceptions)
1697     flag_asynchronous_unwind_tables = 1;
1698   if (flag_asynchronous_unwind_tables)
1699     flag_unwind_tables = 1;
1700
1701   if (!flag_unit_at_a_time)
1702     flag_section_anchors = 0;
1703
1704   if (flag_value_profile_transformations)
1705     flag_profile_values = 1;
1706
1707   /* Warn about options that are not supported on this machine.  */
1708 #ifndef INSN_SCHEDULING
1709   if (flag_schedule_insns || flag_schedule_insns_after_reload)
1710     warning (0, "instruction scheduling not supported on this target machine");
1711 #endif
1712 #ifndef DELAY_SLOTS
1713   if (flag_delayed_branch)
1714     warning (0, "this target machine does not have delayed branches");
1715 #endif
1716
1717   user_label_prefix = USER_LABEL_PREFIX;
1718   if (flag_leading_underscore != -1)
1719     {
1720       /* If the default prefix is more complicated than "" or "_",
1721          issue a warning and ignore this option.  */
1722       if (user_label_prefix[0] == 0 ||
1723           (user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
1724         {
1725           user_label_prefix = flag_leading_underscore ? "_" : "";
1726         }
1727       else
1728         warning (0, "-f%sleading-underscore not supported on this target machine",
1729                  flag_leading_underscore ? "" : "no-");
1730     }
1731
1732   /* If we are in verbose mode, write out the version and maybe all the
1733      option flags in use.  */
1734   if (version_flag)
1735     {
1736       print_version (stderr, "");
1737       if (! quiet_flag)
1738         print_switch_values (print_to_stderr);
1739     }
1740
1741   if (flag_syntax_only)
1742     {
1743       write_symbols = NO_DEBUG;
1744       profile_flag = 0;
1745     }
1746
1747   /* A lot of code assumes write_symbols == NO_DEBUG if the debugging
1748      level is 0.  */
1749   if (debug_info_level == DINFO_LEVEL_NONE)
1750     write_symbols = NO_DEBUG;
1751
1752   /* Now we know write_symbols, set up the debug hooks based on it.
1753      By default we do nothing for debug output.  */
1754   if (PREFERRED_DEBUGGING_TYPE == NO_DEBUG)
1755     default_debug_hooks = &do_nothing_debug_hooks;
1756 #if defined(DBX_DEBUGGING_INFO)
1757   else if (PREFERRED_DEBUGGING_TYPE == DBX_DEBUG)
1758     default_debug_hooks = &dbx_debug_hooks;
1759 #endif
1760 #if defined(XCOFF_DEBUGGING_INFO)
1761   else if (PREFERRED_DEBUGGING_TYPE == XCOFF_DEBUG)
1762     default_debug_hooks = &xcoff_debug_hooks;
1763 #endif
1764 #ifdef SDB_DEBUGGING_INFO
1765   else if (PREFERRED_DEBUGGING_TYPE == SDB_DEBUG)
1766     default_debug_hooks = &sdb_debug_hooks;
1767 #endif
1768 #ifdef DWARF2_DEBUGGING_INFO
1769   else if (PREFERRED_DEBUGGING_TYPE == DWARF2_DEBUG)
1770     default_debug_hooks = &dwarf2_debug_hooks;
1771 #endif
1772 #ifdef VMS_DEBUGGING_INFO
1773   else if (PREFERRED_DEBUGGING_TYPE == VMS_DEBUG
1774            || PREFERRED_DEBUGGING_TYPE == VMS_AND_DWARF2_DEBUG)
1775     default_debug_hooks = &vmsdbg_debug_hooks;
1776 #endif
1777
1778   if (write_symbols == NO_DEBUG)
1779     ;
1780 #if defined(DBX_DEBUGGING_INFO)
1781   else if (write_symbols == DBX_DEBUG)
1782     debug_hooks = &dbx_debug_hooks;
1783 #endif
1784 #if defined(XCOFF_DEBUGGING_INFO)
1785   else if (write_symbols == XCOFF_DEBUG)
1786     debug_hooks = &xcoff_debug_hooks;
1787 #endif
1788 #ifdef SDB_DEBUGGING_INFO
1789   else if (write_symbols == SDB_DEBUG)
1790     debug_hooks = &sdb_debug_hooks;
1791 #endif
1792 #ifdef DWARF2_DEBUGGING_INFO
1793   else if (write_symbols == DWARF2_DEBUG)
1794     debug_hooks = &dwarf2_debug_hooks;
1795 #endif
1796 #ifdef VMS_DEBUGGING_INFO
1797   else if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
1798     debug_hooks = &vmsdbg_debug_hooks;
1799 #endif
1800   else
1801     error ("target system does not support the \"%s\" debug format",
1802            debug_type_names[write_symbols]);
1803
1804   /* Now we know which debug output will be used so we can set
1805      flag_var_tracking, flag_rename_registers if the user has
1806      not specified them.  */
1807   if (debug_info_level < DINFO_LEVEL_NORMAL
1808       || debug_hooks->var_location == do_nothing_debug_hooks.var_location)
1809     {
1810       if (flag_var_tracking == 1
1811           || flag_var_tracking_uninit == 1)
1812         {
1813           if (debug_info_level < DINFO_LEVEL_NORMAL)
1814             warning (0, "variable tracking requested, but useless unless "
1815                      "producing debug info");
1816           else
1817             warning (0, "variable tracking requested, but not supported "
1818                      "by this debug format");
1819         }
1820       flag_var_tracking = 0;
1821       flag_var_tracking_uninit = 0;
1822     }
1823
1824   if (flag_rename_registers == AUTODETECT_VALUE)
1825     flag_rename_registers = default_debug_hooks->var_location
1826                             != do_nothing_debug_hooks.var_location;
1827
1828   if (flag_var_tracking == AUTODETECT_VALUE)
1829     flag_var_tracking = optimize >= 1;
1830
1831   if (flag_tree_cselim == AUTODETECT_VALUE)
1832 #ifdef HAVE_conditional_move
1833     flag_tree_cselim = 1;
1834 #else
1835     flag_tree_cselim = 0;
1836 #endif
1837
1838   /* If the user specifically requested variable tracking with tagging
1839      uninitialized variables, we need to turn on variable tracking.
1840      (We already determined above that variable tracking is feasible.)  */
1841   if (flag_var_tracking_uninit)
1842     flag_var_tracking = 1;
1843
1844   /* If auxiliary info generation is desired, open the output file.
1845      This goes in the same directory as the source file--unlike
1846      all the other output files.  */
1847   if (flag_gen_aux_info)
1848     {
1849       aux_info_file = fopen (aux_info_file_name, "w");
1850       if (aux_info_file == 0)
1851         fatal_error ("can%'t open %s: %m", aux_info_file_name);
1852     }
1853
1854   if (! targetm.have_named_sections)
1855     {
1856       if (flag_function_sections)
1857         {
1858           warning (0, "-ffunction-sections not supported for this target");
1859           flag_function_sections = 0;
1860         }
1861       if (flag_data_sections)
1862         {
1863           warning (0, "-fdata-sections not supported for this target");
1864           flag_data_sections = 0;
1865         }
1866     }
1867
1868   if (flag_function_sections && profile_flag)
1869     {
1870       warning (0, "-ffunction-sections disabled; it makes profiling impossible");
1871       flag_function_sections = 0;
1872     }
1873
1874 #ifndef HAVE_prefetch
1875   if (flag_prefetch_loop_arrays)
1876     {
1877       warning (0, "-fprefetch-loop-arrays not supported for this target");
1878       flag_prefetch_loop_arrays = 0;
1879     }
1880 #else
1881   if (flag_prefetch_loop_arrays && !HAVE_prefetch)
1882     {
1883       warning (0, "-fprefetch-loop-arrays not supported for this target (try -march switches)");
1884       flag_prefetch_loop_arrays = 0;
1885     }
1886 #endif
1887
1888   /* This combination of options isn't handled for i386 targets and doesn't
1889      make much sense anyway, so don't allow it.  */
1890   if (flag_prefetch_loop_arrays && optimize_size)
1891     {
1892       warning (0, "-fprefetch-loop-arrays is not supported with -Os");
1893       flag_prefetch_loop_arrays = 0;
1894     }
1895
1896 #ifndef OBJECT_FORMAT_ELF
1897 #ifndef OBJECT_FORMAT_MACHO
1898   if (flag_function_sections && write_symbols != NO_DEBUG)
1899     warning (0, "-ffunction-sections may affect debugging on some targets");
1900 #endif
1901 #endif
1902
1903   /* The presence of IEEE signaling NaNs, implies all math can trap.  */
1904   if (flag_signaling_nans)
1905     flag_trapping_math = 1;
1906
1907   /* We cannot reassociate if we want traps or signed zeros. Â */
1908   if (flag_associative_math && (flag_trapping_math || flag_signed_zeros))
1909     {
1910       warning (0, "-fassociative-math disabled; other options take precedence");
1911       flag_associative_math = 0;
1912     }
1913
1914   /* With -fcx-limited-range, we do cheap and quick complex arithmetic.  */
1915   if (flag_cx_limited_range)
1916     flag_complex_method = 0;
1917
1918   /* With -fcx-fortran-rules, we do something in-between cheap and C99.  */
1919   if (flag_cx_fortran_rules)
1920     flag_complex_method = 1;
1921
1922   /* Targets must be able to place spill slots at lower addresses.  If the
1923      target already uses a soft frame pointer, the transition is trivial.  */
1924   if (!FRAME_GROWS_DOWNWARD && flag_stack_protect)
1925     {
1926       warning (0, "-fstack-protector not supported for this target");
1927       flag_stack_protect = 0;
1928     }
1929   if (!flag_stack_protect)
1930     warn_stack_protect = 0;
1931
1932   /* ??? Unwind info is not correct around the CFG unless either a frame
1933      pointer is present or A_O_A is set.  Fixing this requires rewriting
1934      unwind info generation to be aware of the CFG and propagating states
1935      around edges.  */
1936   if (flag_unwind_tables && !ACCUMULATE_OUTGOING_ARGS
1937       && flag_omit_frame_pointer)
1938     {
1939       warning (0, "unwind tables currently require a frame pointer "
1940                "for correctness");
1941       flag_omit_frame_pointer = 0;
1942     }
1943 }
1944
1945 /* This function can be called multiple times to reinitialize the compiler
1946    back end when register classes or instruction sets have changed,
1947    before each function.  */
1948 static void
1949 backend_init_target (void)
1950 {
1951   /* Initialize alignment variables.  */
1952   init_alignments ();
1953
1954   /* This reinitializes hard_frame_pointer, and calls init_reg_modes_target()
1955      to initialize reg_raw_mode[].  */
1956   init_emit_regs ();
1957
1958   /* This invokes target hooks to set fixed_reg[] etc, which is
1959      mode-dependent.  */
1960   init_regs ();
1961
1962   /* This depends on stack_pointer_rtx.  */
1963   init_fake_stack_mems ();
1964
1965   /* Sets static_base_value[HARD_FRAME_POINTER_REGNUM], which is
1966      mode-dependent.  */
1967   init_alias_target ();
1968
1969   /* Depends on HARD_FRAME_POINTER_REGNUM.  */
1970   init_reload ();
1971
1972   /* The following initialization functions need to generate rtl, so
1973      provide a dummy function context for them.  */
1974   init_dummy_function_start ();
1975
1976   /* rtx_cost is mode-dependent, so cached values need to be recomputed
1977      on a mode change.  */
1978   init_expmed ();
1979
1980   /* We may need to recompute regno_save_code[] and regno_restore_code[]
1981      after a mode change as well.  */
1982   if (flag_caller_saves)
1983     init_caller_save ();
1984   expand_dummy_function_end ();
1985 }
1986
1987 /* Initialize the compiler back end.  This function is called only once,
1988    when starting the compiler.  */
1989 static void
1990 backend_init (void)
1991 {
1992   init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
1993                   || debug_info_level == DINFO_LEVEL_VERBOSE
1994 #ifdef VMS_DEBUGGING_INFO
1995                     /* Enable line number info for traceback.  */
1996                     || debug_info_level > DINFO_LEVEL_NONE
1997 #endif
1998                     || flag_test_coverage);
1999
2000   init_rtlanal ();
2001   init_inline_once ();
2002   init_varasm_once ();
2003   save_register_info ();
2004
2005   /* Initialize the target-specific back end pieces.  */
2006   backend_init_target ();
2007 }
2008
2009 /* Initialize things that are both lang-dependent and target-dependent.
2010    This function can be called more than once if target parameters change.  */
2011 static void
2012 lang_dependent_init_target (void)
2013 {
2014   /* This creates various _DECL nodes, so needs to be called after the
2015      front end is initialized.  It also depends on the HAVE_xxx macros
2016      generated from the target machine description.  */
2017   init_optabs ();
2018
2019   /* The following initialization functions need to generate rtl, so
2020      provide a dummy function context for them.  */
2021   init_dummy_function_start ();
2022
2023   /* Do the target-specific parts of expr initialization.  */
2024   init_expr_target ();
2025
2026   /* Although the actions of init_set_costs are language-independent,
2027      it uses optabs, so we cannot call it from backend_init.  */
2028   init_set_costs ();
2029
2030   expand_dummy_function_end ();
2031 }
2032
2033 /* Language-dependent initialization.  Returns nonzero on success.  */
2034 static int
2035 lang_dependent_init (const char *name)
2036 {
2037   location_t save_loc = input_location;
2038   if (dump_base_name == 0)
2039     dump_base_name = name && name[0] ? name : "gccdump";
2040
2041   /* Other front-end initialization.  */
2042   input_location = BUILTINS_LOCATION;
2043   if (lang_hooks.init () == 0)
2044     return 0;
2045   input_location = save_loc;
2046
2047   init_asm_output (name);
2048
2049   /* This creates various _DECL nodes, so needs to be called after the
2050      front end is initialized.  */
2051   init_eh ();
2052
2053   /* Do the target-specific parts of the initialization.  */
2054   lang_dependent_init_target ();
2055
2056   /* If dbx symbol table desired, initialize writing it and output the
2057      predefined types.  */
2058   timevar_push (TV_SYMOUT);
2059
2060 #if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
2061   if (dwarf2out_do_frame ())
2062     dwarf2out_frame_init ();
2063 #endif
2064
2065   /* Now we have the correct original filename, we can initialize
2066      debug output.  */
2067   (*debug_hooks->init) (name);
2068
2069   timevar_pop (TV_SYMOUT);
2070
2071   return 1;
2072 }
2073
2074
2075 /* Reinitialize everything when target parameters, such as register usage,
2076    have changed.  */
2077 void
2078 target_reinit (void)
2079 {
2080   /* Reinitialize RTL backend.  */
2081   backend_init_target ();
2082
2083   /* Reinitialize lang-dependent parts.  */
2084   lang_dependent_init_target ();
2085 }
2086
2087 void
2088 dump_memory_report (bool final)
2089 {
2090   ggc_print_statistics ();
2091   stringpool_statistics ();
2092   dump_tree_statistics ();
2093   dump_rtx_statistics ();
2094   dump_varray_statistics ();
2095   dump_alloc_pool_statistics ();
2096   dump_bitmap_statistics ();
2097   dump_ggc_loc_statistics (final);
2098 }
2099
2100 /* Clean up: close opened files, etc.  */
2101
2102 static void
2103 finalize (void)
2104 {
2105   /* Close the dump files.  */
2106   if (flag_gen_aux_info)
2107     {
2108       fclose (aux_info_file);
2109       if (errorcount)
2110         unlink (aux_info_file_name);
2111     }
2112
2113   /* Close non-debugging input and output files.  Take special care to note
2114      whether fclose returns an error, since the pages might still be on the
2115      buffer chain while the file is open.  */
2116
2117   if (asm_out_file)
2118     {
2119       if (ferror (asm_out_file) != 0)
2120         fatal_error ("error writing to %s: %m", asm_file_name);
2121       if (fclose (asm_out_file) != 0)
2122         fatal_error ("error closing %s: %m", asm_file_name);
2123     }
2124
2125   finish_optimization_passes ();
2126
2127   if (mem_report)
2128     dump_memory_report (true);
2129
2130   /* Language-specific end of compilation actions.  */
2131   lang_hooks.finish ();
2132 }
2133
2134 /* Initialize the compiler, and compile the input file.  */
2135 static void
2136 do_compile (void)
2137 {
2138   /* Initialize timing first.  The C front ends read the main file in
2139      the post_options hook, and C++ does file timings.  */
2140   if (time_report || !quiet_flag  || flag_detailed_statistics)
2141     timevar_init ();
2142   timevar_start (TV_TOTAL);
2143
2144   process_options ();
2145
2146   /* Don't do any more if an error has already occurred.  */
2147   if (!errorcount)
2148     {
2149       /* This must be run always, because it is needed to compute the FP
2150          predefined macros, such as __LDBL_MAX__, for targets using non
2151          default FP formats.  */
2152       init_adjust_machine_modes ();
2153
2154       /* Set up the back-end if requested.  */
2155       if (!no_backend)
2156         backend_init ();
2157
2158       /* Language-dependent initialization.  Returns true on success.  */
2159       if (lang_dependent_init (main_input_filename))
2160         compile_file ();
2161
2162       finalize ();
2163     }
2164
2165   /* Stop timing and print the times.  */
2166   timevar_stop (TV_TOTAL);
2167   timevar_print (stderr);
2168 }
2169
2170 /* Entry point of cc1, cc1plus, jc1, f771, etc.
2171    Exit code is FATAL_EXIT_CODE if can't open files or if there were
2172    any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
2173
2174    It is not safe to call this function more than once.  */
2175
2176 int
2177 toplev_main (unsigned int argc, const char **argv)
2178 {
2179   save_argv = argv;
2180
2181   /* Initialization of GCC's environment, and diagnostics.  */
2182   general_init (argv[0]);
2183
2184   /* Parse the options and do minimal processing; basically just
2185      enough to default flags appropriately.  */
2186   decode_options (argc, argv);
2187
2188   init_local_tick ();
2189
2190   /* Exit early if we can (e.g. -help).  */
2191   if (!exit_after_options)
2192     do_compile ();
2193
2194   if (warningcount || errorcount) 
2195     print_ignored_options ();
2196
2197   if (errorcount || sorrycount)
2198     return (FATAL_EXIT_CODE);
2199
2200   return (SUCCESS_EXIT_CODE);
2201 }