misc.c: Move global variables to the top of the file.

* gcc-interface/misc.c: Move global variables to the top of the file.
	(gnat_handle_option): Remove obsolete ATTRIBUTE_UNUSED markers.
	(gnat_init_options): Minor tweak.
	(gnat_post_options): Set -fstrict-overflow if not done by the user.
	(internal_error_function): Minor reformatting.

From-SVN: r230569
This commit is contained in:
Eric Botcazou 2015-11-18 21:17:51 +00:00 committed by Eric Botcazou
parent 21c7259c1c
commit 5f29a394cd
4 changed files with 58 additions and 30 deletions

View File

@ -1,3 +1,11 @@
2015-11-18 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/misc.c: Move global variables to the top of the file.
(gnat_handle_option): Remove obsolete ATTRIBUTE_UNUSED markers.
(gnat_init_options): Minor tweak.
(gnat_post_options): Set -fstrict-overflow if not done by the user.
(internal_error_function): Minor reformatting.
2015-11-18 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Use case #1
@ -269,7 +277,6 @@
2015-11-18 Hristian Kirtchev <kirtchev@adacore.com>
PR ada/66242
* exp_ch3.adb (Default_Initialize_Object): Reimplemented. Abort
defer / undefer pairs are now encapsulated in a block with
an AT END handler. Partial finalization now takes restriction
@ -7919,7 +7926,6 @@
2015-03-01 Arnaud Charlet <charlet@adacore.com>
PR ada/65259
* doc/gnat_ugn/gnat_project_manager.rst,
doc/gnat_ugn/platform_specific_information.rst: Remove reference to
image, too troublesome with texi format.

View File

@ -62,9 +62,28 @@ void *callgraph_info_file = NULL;
unsigned int save_argc;
const char **save_argv;
/* GNAT argc and argv. */
/* GNAT argc and argv generated by the binder for all Ada programs. */
extern int gnat_argc;
extern char **gnat_argv;
extern const char **gnat_argv;
/* Ada code requires variables for these settings rather than elements
of the global_options structure because they are imported. */
int gnat_encodings = 0;
#undef optimize
int optimize;
#undef optimize_size
int optimize_size;
#undef flag_compare_debug
int flag_compare_debug;
#undef flag_short_enums
int flag_short_enums;
#undef flag_stack_check
enum stack_check_type flag_stack_check = NO_STACK_CHECK;
#ifdef __cplusplus
extern "C" {
@ -118,9 +137,8 @@ gnat_option_lang_mask (void)
are marked as Ada-specific. Return true on success or false on failure. */
static bool
gnat_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, int value,
int kind ATTRIBUTE_UNUSED, location_t loc ATTRIBUTE_UNUSED,
const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
gnat_handle_option (size_t scode, const char *arg, int value, int kind,
location_t loc, const struct cl_option_handlers *handlers)
{
enum opt_code code = (enum opt_code) scode;
@ -164,8 +182,8 @@ gnat_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, int value,
Ada_handle_option_auto (&global_options, &global_options_set,
scode, arg, value,
gnat_option_lang_mask (), kind,
loc, handlers, global_dc);
gnat_option_lang_mask (), kind, loc,
handlers, global_dc);
return true;
}
@ -194,11 +212,9 @@ gnat_init_options (unsigned int decoded_options_count,
??? back_end.adb should not rely on this; instead, it should work with
decoded options without such reparsing, to ensure consistency in how
options are decoded. */
unsigned int i;
save_argv = XNEWVEC (const char *, 2 * decoded_options_count + 1);
save_argc = 0;
for (i = 0; i < decoded_options_count; i++)
for (unsigned int i = 0; i < decoded_options_count; i++)
{
size_t num_elements = decoded_options[i].canonical_option_num_elements;
@ -223,25 +239,12 @@ gnat_init_options (unsigned int decoded_options_count,
}
save_argv[save_argc] = NULL;
gnat_argv = (char **) xmalloc (sizeof (save_argv[0]));
gnat_argv[0] = xstrdup (save_argv[0]); /* name of the command */
/* Pass just the name of the command through the regular channel. */
gnat_argv = (const char **) xmalloc (sizeof (char *));
gnat_argv[0] = xstrdup (save_argv[0]);
gnat_argc = 1;
}
/* Ada code requires variables for these settings rather than elements
of the global_options structure. */
#undef optimize
#undef optimize_size
#undef flag_compare_debug
#undef flag_short_enums
#undef flag_stack_check
int gnat_encodings = 0;
int optimize;
int optimize_size;
int flag_compare_debug;
int flag_short_enums;
enum stack_check_type flag_stack_check = NO_STACK_CHECK;
/* Settings adjustments after switches processing by the back-end.
Note that the front-end switches processing (Scan_Compiler_Arguments)
has not been done yet at this point! */
@ -262,6 +265,10 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
if (!global_options_set.x_flag_diagnostics_show_caret)
global_dc->show_caret = false;
/* Set strict overflow by default for Ada. */
if (!global_options_set.x_flag_strict_overflow)
global_options.x_flag_strict_overflow = true;
/* Warn only if STABS is not the default: we don't want to emit a warning if
the user did not use a -gstabs option. */
if (PREFERRED_DEBUGGING_TYPE != DBX_DEBUG && write_symbols == DBX_DEBUG)
@ -287,8 +294,8 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
/* Here is the function to handle the compiler error processing in GCC. */
static void
internal_error_function (diagnostic_context *context,
const char *msgid, va_list *ap)
internal_error_function (diagnostic_context *context, const char *msgid,
va_list *ap)
{
text_info tinfo;
char *buffer, *p, *loc;

View File

@ -1,3 +1,7 @@
2015-11-18 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/opt52.adb: New test.
2015-11-18 Nathan Sidwell <nathan@codesourcery.com>
* gcc.dg/goacc/nvptx-sese-1.c: New.

View File

@ -0,0 +1,11 @@
-- { dg-do compile }
-- { dg-options "-O -fdump-tree-optimized" }
procedure Opt52 (I : Integer) is
begin
if I + 1 < I then
raise Program_Error;
end if;
end;
-- { dg-final { scan-tree-dump-not "check_PE_Explicit_Raise" "optimized" } }