OSDN Git Service

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