OSDN Git Service

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