static int decode_W_option PARAMS ((const char *));
static int decode_g_option PARAMS ((const char *));
static unsigned int independent_decode_option PARAMS ((int, char **));
+static void set_Wextra PARAMS ((int));
static void print_version PARAMS ((FILE *, const char *));
static int print_single_switch PARAMS ((FILE *, int, int, const char *,
int save_argc;
char **save_argv;
\f
-/* Name of current original source file (what was input to cpp).
- This comes from each #-command in the actual input. */
-
-const char *input_filename;
-
/* Name of top-level original source file (what was input to cpp).
This comes from the #-command at the beginning of the actual input.
If there isn't any there, then this is the cc1 input file name. */
const char *main_input_filename;
-/* Current line number in real source file. */
+/* Current position in real source file. */
-int lineno;
+location_t input_location;
/* Nonzero if it is unsafe to create any new pseudo registers. */
int no_new_pseudos;
DFI_flow2,
DFI_peephole2,
DFI_rnreg,
- DFI_ce3,
DFI_bbro,
+ DFI_ce3,
DFI_sched2,
DFI_stack,
DFI_mach,
{ "flow2", 'w', 1, 0, 0 },
{ "peephole2", 'z', 1, 0, 0 },
{ "rnreg", 'n', 1, 0, 0 },
- { "ce3", 'E', 1, 0, 0 },
{ "bbro", 'B', 1, 0, 0 },
+ { "ce3", 'E', 1, 0, 0 },
{ "sched2", 'R', 1, 0, 0 },
{ "stack", 'k', 1, 0, 0 },
{ "mach", 'M', 1, 0, 0 },
char *asm_file_name;
/* Value of the -G xx switch, and whether it was passed or not. */
-int g_switch_value;
+unsigned HOST_WIDE_INT g_switch_value;
int g_switch_set;
/* Type(s) of debugging information we are producing (if any).
/* Print times taken by the various passes. -ftime-report. */
-int time_report = 0;
+static int time_report = 0;
/* Print memory still in use at end of compilation (which may have little
to do with peak memory consumption). -fmem-report. */
int flag_asynchronous_unwind_tables = 0;
-/* Nonzero means allow for forced unwinding. */
-
-int flag_forced_unwind_exceptions;
-
/* Nonzero means don't place uninitialized global data in common storage
by default. */
{"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
N_("Allow speculative motion of more loads") },
{"sched2-use-superblocks", &flag_sched2_use_superblocks, 1,
- N_("If scheduling post reload, do superblock sheduling") },
+ N_("If scheduling post reload, do superblock scheduling") },
{"sched2-use-traces", &flag_sched2_use_traces, 1,
- N_("If scheduling post reload, do trace sheduling") },
+ N_("If scheduling post reload, do trace scheduling") },
{"branch-count-reg",&flag_branch_on_count_reg, 1,
N_("Replace add,compare,branch with branch on count reg") },
{"pic", &flag_pic, 1,
N_("Generate unwind tables exact at each instruction boundary") },
{"non-call-exceptions", &flag_non_call_exceptions, 1,
N_("Support synchronous non-call exceptions") },
- {"forced-unwind-exceptions", &flag_forced_unwind_exceptions, 1,
- N_("Support forced unwinding, e.g. for thread cancellation") },
{"profile-arcs", &profile_arc_flag, 1,
N_("Insert arc based program profiling code") },
{"test-coverage", &flag_test_coverage, 1,
{"data-sections", &flag_data_sections, 1,
N_("place data items into their own section") },
{"verbose-asm", &flag_verbose_asm, 1,
- N_("Add extra commentry to assembler output") },
+ N_("Add extra commentary to assembler output") },
{"gnu-linker", &flag_gnu_linker, 1,
N_("Output GNU ld formatted global initializers") },
{"regmove", &flag_regmove, 1,
{"align-functions", &align_functions, 0,
N_("Align the start of functions") },
{"merge-constants", &flag_merge_constants, 1,
- N_("Attempt to merge identical constants accross compilation units") },
+ N_("Attempt to merge identical constants across compilation units") },
{"merge-all-constants", &flag_merge_constants, 2,
N_("Attempt to merge identical constants and constant variables") },
{"dump-unnumbered", &flag_dump_unnumbered, 1,
const char *const prefix;
const char **const variable;
const char *const description;
+ const char *const value;
}
target_options[] = TARGET_OPTIONS;
#endif
int warn_unused_variable;
int warn_unused_value;
+/* Used for cooperation between set_Wunused and set_Wextra. */
+static int maybe_warn_unused_parameter;
+
/* Nonzero to warn about code which is never reached. */
int warn_notreached;
N_("Warn when an optimization pass is disabled") },
{"deprecated-declarations", &warn_deprecated_decl, 1,
N_("Warn about uses of __attribute__((deprecated)) declarations") },
- {"extra", &extra_warnings, 1,
- N_("Print extra (possibly unwanted) warnings") },
{"missing-noreturn", &warn_missing_noreturn, 1,
N_("Warn about functions which might be candidates for attribute noreturn") },
{"strict-aliasing", &warn_strict_aliasing, 1,
{
warn_unused_function = setting;
warn_unused_label = setting;
- /* Unused function parameter warnings are reported when either ``-W
- -Wunused'' or ``-Wunused-parameter'' is specified. Differentiate
- -Wunused by setting WARN_UNUSED_PARAMETER to -1. */
- if (!setting)
- warn_unused_parameter = 0;
- else if (!warn_unused_parameter)
- warn_unused_parameter = -1;
+ /* Unused function parameter warnings are reported when either
+ ``-Wextra -Wunused'' or ``-Wunused-parameter'' is specified.
+ Thus, if -Wextra has already been seen, set warn_unused_parameter;
+ otherwise set maybe_warn_extra_parameter, which will be picked up
+ by set_Wextra. */
+ maybe_warn_unused_parameter = setting;
+ warn_unused_parameter = (setting && extra_warnings);
warn_unused_variable = setting;
warn_unused_value = setting;
}
+static void
+set_Wextra (setting)
+ int setting;
+{
+ extra_warnings = setting;
+ warn_unused_value = setting;
+ warn_unused_parameter = (setting && maybe_warn_unused_parameter);
+
+ /* We save the value of warn_uninitialized, since if they put
+ -Wuninitialized on the command line, we need to generate a
+ warning about not using it without also specifying -O. */
+ if (setting == 0)
+ warn_uninitialized = 0;
+ else if (warn_uninitialized != 1)
+ warn_uninitialized = 2;
+}
+
/* The following routines are useful in setting all the flags that
-ffast-math and -fno-fast-math imply. */
if (*endp != 0)
{
if (pname != 0)
- error ("invalid option `%s'", pname);
+ error ("invalid option argument `%s'", pname);
return defval;
}
{
struct rlimit rlim;
if (getrlimit (RLIMIT_CORE, &rlim) != 0)
- fatal_io_error ("getting core file size maximum limit");
+ fatal_error ("getting core file size maximum limit: %m");
rlim.rlim_cur = rlim.rlim_max;
if (setrlimit (RLIMIT_CORE, &rlim) != 0)
- fatal_io_error ("setting core file size limit to maximum");
+ fatal_error ("setting core file size limit to maximum: %m");
}
#endif
diagnostic_abort_on_error (global_dc);
rtl_dump_file = fopen (dump_name, open_arg);
if (rtl_dump_file == NULL)
- fatal_io_error ("can't open %s", dump_name);
+ fatal_error ("can't open %s: %m", dump_name);
free (dump_name);
&& ! TREE_USED (DECL_NAME (decl))
&& ! DECL_EXTERNAL (decl)
&& ! TREE_PUBLIC (decl)
+ /* A volatile variable might be used in some non-obvious way. */
+ && ! TREE_THIS_VOLATILE (decl)
/* Global register variables must be declared to reserve them. */
&& ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
/* Otherwise, ask the language. */
}
}
-/* Save the current INPUT_FILENAME and LINENO on the top entry in the
+/* Save the current INPUT_LOCATION on the top entry in the
INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
- INPUT_FILENAME and LINENO accordingly. */
+ INPUT_LOCATION accordingly. */
void
push_srcloc (file, line)
struct file_stack *fs;
if (input_file_stack)
- {
- input_file_stack->name = input_filename;
- input_file_stack->line = lineno;
- }
+ input_file_stack->location = input_location;
fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
- fs->name = input_filename = file;
- fs->line = lineno = line;
+ input_filename = file;
+ input_line = line;
+ fs->location = input_location;
fs->next = input_file_stack;
input_file_stack = fs;
input_file_stack_tick++;
}
/* Pop the top entry off the stack of presently open source files.
- Restore the INPUT_FILENAME and LINENO from the new topmost entry on
- the stack. */
+ Restore the INPUT_LOCATION from the new topmost entry on the
+ stack. */
void
pop_srcloc ()
input_file_stack_tick++;
if (input_file_stack)
- {
- input_filename = input_file_stack->name;
- lineno = input_file_stack->line;
- }
+ input_location = input_file_stack->location;
else
{
input_filename = NULL;
- lineno = 0;
+ input_line = 0;
}
}
/* Initialize yet another pass. */
init_final (main_input_filename);
- init_branch_prob (aux_base_name);
+ coverage_init (aux_base_name);
timevar_push (TV_PARSE);
(*lang_hooks.decls.final_write_globals)();
- if (profile_arc_flag)
- /* This must occur after the loop to output deferred functions.
- Else the profiler initializer would not be emitted if all the
- functions in this compilation unit were deferred. */
- create_profiler ();
+ /* This must occur after the loop to output deferred functions.
+ Else the coverage initializer would not be emitted if all the
+ functions in this compilation unit were deferred. */
+ coverage_finish ();
/* Write out any pending weak symbol declarations. */
close_dump_file (DFI_cfg, print_rtl_with_bb, insns);
/* Do branch profiling and static profile estimation passes. */
- if (optimize > 0 || cfun->arc_profile || flag_branch_probabilities)
+ if (optimize > 0
+ || profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
{
struct loops loops;
timevar_push (TV_BRANCH_PROB);
open_dump_file (DFI_bp, decl);
- if (cfun->arc_profile || flag_branch_probabilities)
+ if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
branch_prob ();
/* Discover and record the loop depth at the head of each basic
| (flag_thread_jumps ? CLEANUP_THREADING : 0));
timevar_pop (TV_FLOW);
- no_new_pseudos = 1;
-
- if (warn_uninitialized || extra_warnings)
+ if (warn_uninitialized)
{
uninitialized_vars_warning (DECL_INITIAL (decl));
if (extra_warnings)
if (optimize)
{
- clear_bb_flags ();
if (!flag_new_regalloc && initialize_uninitialized_subregs ())
{
- /* Insns were inserted, so things might look a bit different. */
+ /* Insns were inserted, and possibly pseudos created, so
+ things might look a bit different. */
insns = get_insns ();
- update_life_info_in_dirty_blocks (UPDATE_LIFE_GLOBAL_RM_NOTES,
- PROP_LOG_LINKS | PROP_REG_INFO
- | PROP_DEATH_NOTES);
+ allocate_reg_life_data ();
+ update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
+ PROP_LOG_LINKS | PROP_REG_INFO | PROP_DEATH_NOTES);
}
}
+ no_new_pseudos = 1;
+
close_dump_file (DFI_life, print_rtl_with_bb, insns);
ggc_collect ();
free_bb_for_insn ();
/* If a machine dependent reorganization is needed, call it. */
-#ifdef MACHINE_DEPENDENT_REORG
- timevar_push (TV_MACH_DEP);
- open_dump_file (DFI_mach, decl);
+ if (targetm.machine_dependent_reorg != 0)
+ {
+ timevar_push (TV_MACH_DEP);
+ open_dump_file (DFI_mach, decl);
- MACHINE_DEPENDENT_REORG (insns);
+ (*targetm.machine_dependent_reorg) ();
- close_dump_file (DFI_mach, print_rtl, insns);
- timevar_pop (TV_MACH_DEP);
+ close_dump_file (DFI_mach, print_rtl, insns);
+ timevar_pop (TV_MACH_DEP);
- ggc_collect ();
-#endif
+ ggc_collect ();
+ }
purge_line_number_notes (insns);
cleanup_barriers ();
exit_rest_of_compilation:
+ coverage_end_function ();
+
/* In case the function was not output,
don't leave any temporary anonymous types
queued up for sdb output. */
W_options[i].string, _(description));
}
+ printf (_(" -Wextra Print extra (possibly unwanted) warnings\n"));
printf (_(" -Wunused Enable unused warnings\n"));
printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
printf (_(" -p Enable function profiling\n"));
}
else if (!strcmp (arg, "extra"))
{
- /* We save the value of warn_uninitialized, since if they put
- -Wuninitialized on the command line, we need to generate a
- warning about not using it without also specifying -O. */
- if (warn_uninitialized != 1)
- warn_uninitialized = 2;
+ set_Wextra (1);
+ }
+ else if (!strcmp (arg, "no-extra"))
+ {
+ set_Wextra (0);
}
else
return 0;
break;
case 'W':
+ /* For backward compatibility, -W is the same as -Wextra. */
if (arg[1] == 0)
- {
- extra_warnings = 1;
- /* We save the value of warn_uninitialized, since if they put
- -Wuninitialized on the command line, we need to generate a
- warning about not using it without also specifying -O. */
- if (warn_uninitialized != 1)
- warn_uninitialized = 2;
- }
+ set_Wextra (1);
else
return decode_W_option (arg + 1);
break;
for (j = 0; j < ARRAY_SIZE (target_options); j++)
{
int len = strlen (target_options[j].prefix);
- if (!strncmp (target_options[j].prefix, name, len))
+ if (target_options[j].value)
+ {
+ if (!strcmp (target_options[j].prefix, name))
+ {
+ *target_options[j].variable = target_options[j].value;
+ valid_target_option = 1;
+ }
+ }
+ else
{
- *target_options[j].variable = name + len;
- valid_target_option = 1;
+ if (!strncmp (target_options[j].prefix, name, len))
+ {
+ *target_options[j].variable = name + len;
+ valid_target_option = 1;
+ }
}
}
#endif
else
asm_out_file = fopen (asm_file_name, "w+");
if (asm_out_file == 0)
- fatal_io_error ("can't open %s for writing", asm_file_name);
+ fatal_error ("can't open %s for writing: %m", asm_file_name);
}
#ifdef IO_BUFFER_SIZE
print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
}
- if (! quiet_flag || flag_detailed_statistics)
- time_report = 1;
-
if (flag_syntax_only)
{
write_symbols = NO_DEBUG;
{
aux_info_file = fopen (aux_info_file_name, "w");
if (aux_info_file == 0)
- fatal_io_error ("can't open %s", aux_info_file_name);
+ fatal_error ("can't open %s: %m", aux_info_file_name);
}
if (! targetm.have_named_sections)
if (asm_out_file)
{
if (ferror (asm_out_file) != 0)
- fatal_io_error ("error writing to %s", asm_file_name);
+ fatal_error ("error writing to %s: %m", asm_file_name);
if (fclose (asm_out_file) != 0)
- fatal_io_error ("error closing %s", asm_file_name);
+ fatal_error ("error closing %s: %m", asm_file_name);
}
/* Do whatever is necessary to finish printing the graphs. */
static void
do_compile ()
{
- /* We cannot start timing until after options are processed since that
- says if we run timers or not. */
- init_timevar ();
+ /* Initialize timing first. The C front ends read the main file in
+ the post_options hook, and C++ does file timings. */
+ if (time_report || !quiet_flag || flag_detailed_statistics)
+ timevar_init ();
timevar_start (TV_TOTAL);
- /* Set up the back-end if requested. */
- if (!no_backend)
- backend_init ();
+ process_options ();
- /* Language-dependent initialization. Returns true on success. */
- if (lang_dependent_init (filename))
- compile_file ();
+ /* Don't do any more if an error has already occurred. */
+ if (!errorcount)
+ {
+ /* Set up the back-end if requested. */
+ if (!no_backend)
+ backend_init ();
- finalize ();
+ /* Language-dependent initialization. Returns true on success. */
+ if (lang_dependent_init (filename))
+ compile_file ();
+
+ finalize ();
+ }
/* Stop timing and print the times. */
timevar_stop (TV_TOTAL);
/* Exit early if we can (e.g. -help). */
if (!exit_after_options)
- {
- process_options ();
-
- /* Don't do any more if an error has already occurred. */
- if (!errorcount)
- do_compile ();
- }
+ do_compile ();
if (errorcount || sorrycount)
return (FATAL_EXIT_CODE);