/* Top level of GCC compilers (cc1, cc1plus, etc.)
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
This file is part of GCC.
/* Incremented on each change to input_file_stack. */
int input_file_stack_tick;
+/* Record of input_file_stack at each tick. */
+typedef struct file_stack *fs_p;
+DEF_VEC_P(fs_p);
+DEF_VEC_ALLOC_P(fs_p,heap);
+static VEC(fs_p,heap) *input_file_stack_history;
+
+/* Whether input_file_stack has been restored to a previous state (in
+ which case there should be no more pushing). */
+static bool input_file_stack_restored;
+
/* Name to use as base of names for dump output files. */
const char *dump_base_name;
static const param_info lang_independent_params[] = {
#define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \
- { OPTION, DEFAULT, MIN, MAX, HELP },
+ { OPTION, DEFAULT, false, MIN, MAX, HELP },
#include "params.def"
#undef DEFPARAM
- { NULL, 0, 0, 0, NULL }
+ { NULL, 0, false, 0, 0, NULL }
};
/* Output files for assembler code (real compiler output)
return atoi (p);
}
+/* When compiling with a recent enough GCC, we use the GNU C "extern inline"
+ for floor_log2 and exact_log2; see toplev.h. That construct, however,
+ conflicts with the ISO C++ One Definition Rule. */
+
+#if GCC_VERSION < 3004 || !defined (__cplusplus)
+
/* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
If X is 0, return -1. */
#endif
}
+#endif /* GCC_VERSION < 3004 || !defined (__cplusplus) */
+
/* Handler for fatal signals, such as SIGSEGV. These are transformed
into ICE messages, which is much more user friendly. In case the
error printer crashes, reset the signal to prevent infinite recursion. */
&& ! TREE_USED (decl)
/* The TREE_USED bit for file-scope decls is kept in the identifier,
to handle multiple external decls in different scopes. */
- && ! TREE_USED (DECL_NAME (decl))
+ && ! (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl)))
&& ! DECL_EXTERNAL (decl)
&& ! TREE_PUBLIC (decl)
/* A volatile variable might be used in some non-obvious way. */
{
struct file_stack *fs;
- fs = xmalloc (sizeof (struct file_stack));
+ gcc_assert (!input_file_stack_restored);
+ if (input_file_stack_tick == (int) ((1U << INPUT_FILE_STACK_BITS) - 1))
+ sorry ("GCC supports only %d input file changes", input_file_stack_tick);
+
+ fs = XNEW (struct file_stack);
fs->location = input_location;
fs->next = input_file_stack;
#ifdef USE_MAPPED_LOCATION
#endif
input_file_stack = fs;
input_file_stack_tick++;
+ VEC_safe_push (fs_p, heap, input_file_stack_history, input_file_stack);
}
/* Pop the top entry off the stack of presently open source files.
{
struct file_stack *fs;
+ gcc_assert (!input_file_stack_restored);
+ if (input_file_stack_tick == (int) ((1U << INPUT_FILE_STACK_BITS) - 1))
+ sorry ("GCC supports only %d input file changes", input_file_stack_tick);
+
fs = input_file_stack;
input_location = fs->location;
input_file_stack = fs->next;
- free (fs);
input_file_stack_tick++;
+ VEC_safe_push (fs_p, heap, input_file_stack_history, input_file_stack);
+}
+
+/* Restore the input file stack to its state as of TICK, for the sake
+ of diagnostics after processing the whole input. Once this has
+ been called, push_srcloc and pop_srcloc may no longer be
+ called. */
+void
+restore_input_file_stack (int tick)
+{
+ if (tick == 0)
+ input_file_stack = NULL;
+ else
+ input_file_stack = VEC_index (fs_p, input_file_stack_history, tick - 1);
+ input_file_stack_tick = tick;
+ input_file_stack_restored = true;
}
/* Compile an entire translation unit. Write a file of assembly
return;
lang_hooks.decls.final_write_globals ();
+
+ if (errorcount || sorrycount)
+ return;
+
cgraph_varpool_assemble_pending_decls ();
finish_aliases_2 ();
if (flag_mudflap)
mudflap_finish_file ();
+ output_shared_constant_pool ();
+ output_object_blocks ();
+
/* Write out any pending weak symbol declarations. */
weak_finish ();
/* Do dbx symbols. */
timevar_push (TV_SYMOUT);
-#ifdef DWARF2_UNWIND_INFO
+#if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
if (dwarf2out_do_frame ())
dwarf2out_frame_finish ();
#endif
if (asm_file_name == 0)
{
int len = strlen (dump_base_name);
- char *dumpname = xmalloc (len + 6);
+ char *dumpname = XNEWVEC (char, len + 6);
memcpy (dumpname, dump_base_name, len + 1);
strip_off_ending (dumpname, len);
strcat (dumpname, ".s");
if (option_affects_pch_p (i, &state))
*len += state.size;
- result = r = xmalloc (*len);
+ result = r = XNEWVEC (char, *len);
r[0] = flag_pic;
r[1] = flag_pie;
r += 2;
init_optimization_passes ();
}
+/* Return true if the current target supports -fsection-anchors. */
+
+static bool
+target_supports_section_anchors_p (void)
+{
+ if (targetm.min_anchor_offset == 0 && targetm.max_anchor_offset == 0)
+ return false;
+
+ if (targetm.asm_out.output_anchor == NULL)
+ return false;
+
+ return true;
+}
+
/* Process the options that have been parsed. */
static void
process_options (void)
{
+ /* Just in case lang_hooks.post_options ends up calling a debug_hook.
+ This can happen with incorrect pre-processed input. */
+ debug_hooks = &do_nothing_debug_hooks;
+
/* Allow the front end to perform consistency checks and do further
initialization based on the command line options. This hook also
sets the original filename if appropriate (e.g. foo.i -> foo.c)
OVERRIDE_OPTIONS;
#endif
+ if (flag_section_anchors && !target_supports_section_anchors_p ())
+ {
+ warning (OPT_fsection_anchors,
+ "this target does not support %qs", "-fsection-anchors");
+ flag_section_anchors = 0;
+ }
+
if (flag_short_enums == 2)
flag_short_enums = targetm.default_short_enums ();
if (flag_rename_registers == AUTODETECT_VALUE)
flag_rename_registers = flag_unroll_loops || flag_peel_loops;
- /* If explicitly asked to run new loop optimizer, switch off the old
- one. */
- if (flag_loop_optimize2)
- flag_loop_optimize = 0;
-
- /* Enable new loop optimizer pass if any of its optimizations is called. */
- if (flag_move_loop_invariants
- || flag_unswitch_loops
- || flag_peel_loops
- || flag_unroll_loops
- || flag_branch_on_count_reg)
- flag_loop_optimize2 = 1;
-
if (flag_non_call_exceptions)
flag_asynchronous_unwind_tables = 1;
if (flag_asynchronous_unwind_tables)
if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
flag_unit_at_a_time = 0;
+ if (!flag_unit_at_a_time)
+ flag_section_anchors = 0;
+
if (flag_value_profile_transformations)
flag_profile_values = 1;
default_debug_hooks = &vmsdbg_debug_hooks;
#endif
- debug_hooks = &do_nothing_debug_hooks;
if (write_symbols == NO_DEBUG)
;
#if defined(DBX_DEBUGGING_INFO)
}
#ifndef OBJECT_FORMAT_ELF
+#ifndef OBJECT_FORMAT_MACHO
if (flag_function_sections && write_symbols != NO_DEBUG)
warning (0, "-ffunction-sections may affect debugging on some targets");
#endif
+#endif
/* The presence of IEEE signaling NaNs, implies all math can trap. */
if (flag_signaling_nans)
}
if (!flag_stack_protect)
warn_stack_protect = 0;
+
+ /* ??? Unwind info is not correct around the CFG unless either a frame
+ pointer is present or A_O_A is set. Fixing this requires rewriting
+ unwind info generation to be aware of the CFG and propagating states
+ around edges. */
+ if (flag_unwind_tables && !ACCUMULATE_OUTGOING_ARGS
+ && flag_omit_frame_pointer)
+ {
+ warning (0, "unwind tables currently requires a frame pointer "
+ "for correctness");
+ flag_omit_frame_pointer = 0;
+ }
}
/* Initialize the compiler back end. */
init_regs ();
init_fake_stack_mems ();
init_alias_once ();
- init_loop ();
init_reload ();
init_varasm_once ();
predefined types. */
timevar_push (TV_SYMOUT);
-#ifdef DWARF2_UNWIND_INFO
+#if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
if (dwarf2out_do_frame ())
dwarf2out_frame_init ();
#endif