Commit 68d2e027 by Jerry DeLisle

re PR libfortran/32611 (Print sign of negative zero)

2007-07-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
	    Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

	PR fortran/32611
	* gfortran.h (gfc_option_t): Add flag_sign_zero field.
	* lang.opt (-fsign-zero): New option.
	* trans.h: Rename gfor_fndecl_set_std into gfor_fndecl_set_options.
	* trans-decl.c (gfc_build_builtin_function_decls): Build the function
	declaration to pass an array containing the options to be used by the
	runtime library. (gfc_generate_function_code): Build an array that
	contains option values to be passed to the runtime library and the call
	to the function. 
	* options.c (gfc_init_options): Initialize the flag_sign_zero field.
	(gfc_handle_option): Handle the -fsign-zero option.

Co-Authored-By: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>

From-SVN: r126655
parent 2bb6de3a
2007-07-15 Jerry DeLisle <jvdelisle@gcc.gnu.org>
Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/32611
* gfortran.h (gfc_option_t): Add flag_sign_zero field.
* lang.opt (-fsign-zero): New option.
* trans.h: Rename gfor_fndecl_set_std into gfor_fndecl_set_options.
* trans-decl.c (gfc_build_builtin_function_decls): Build the function
declaration to pass an array containing the options to be used by the
runtime library. (gfc_generate_function_code): Build an array that
contains option values to be passed to the runtime library and the call
to the function.
* options.c (gfc_init_options): Initialize the flag_sign_zero field.
(gfc_handle_option): Handle the -fsign-zero option.
2007-07-15 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> 2007-07-15 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/32036 PR fortran/32036
......
...@@ -1861,6 +1861,7 @@ typedef struct ...@@ -1861,6 +1861,7 @@ typedef struct
int flag_cray_pointer; int flag_cray_pointer;
int flag_d_lines; int flag_d_lines;
int flag_openmp; int flag_openmp;
int flag_sign_zero;
int fpe; int fpe;
......
...@@ -249,6 +249,10 @@ fshort-enums ...@@ -249,6 +249,10 @@ fshort-enums
Fortran Fortran
Use the narrowest integer type possible for enumeration types Use the narrowest integer type possible for enumeration types
fsign-zero
Fortran
Apply negative sign to zero values
funderscoring funderscoring
Fortran Fortran
Append underscores to externally visible names Append underscores to externally visible names
......
...@@ -102,6 +102,7 @@ gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED, ...@@ -102,6 +102,7 @@ gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED,
gfc_option.flag_cray_pointer = 0; gfc_option.flag_cray_pointer = 0;
gfc_option.flag_d_lines = -1; gfc_option.flag_d_lines = -1;
gfc_option.flag_openmp = 0; gfc_option.flag_openmp = 0;
gfc_option.flag_sign_zero = 1;
gfc_option.fpe = 0; gfc_option.fpe = 0;
...@@ -619,6 +620,10 @@ gfc_handle_option (size_t scode, const char *arg, int value) ...@@ -619,6 +620,10 @@ gfc_handle_option (size_t scode, const char *arg, int value)
gfc_handle_module_path_options (arg); gfc_handle_module_path_options (arg);
break; break;
case OPT_fsign_zero:
gfc_option.flag_sign_zero = value;
break;
case OPT_ffpe_trap_: case OPT_ffpe_trap_:
gfc_handle_fpe_trap_option (arg); gfc_handle_fpe_trap_option (arg);
break; break;
......
...@@ -88,7 +88,7 @@ tree gfor_fndecl_runtime_error_at; ...@@ -88,7 +88,7 @@ tree gfor_fndecl_runtime_error_at;
tree gfor_fndecl_os_error; tree gfor_fndecl_os_error;
tree gfor_fndecl_generate_error; tree gfor_fndecl_generate_error;
tree gfor_fndecl_set_fpe; tree gfor_fndecl_set_fpe;
tree gfor_fndecl_set_std; tree gfor_fndecl_set_options;
tree gfor_fndecl_set_convert; tree gfor_fndecl_set_convert;
tree gfor_fndecl_set_record_marker; tree gfor_fndecl_set_record_marker;
tree gfor_fndecl_set_max_subrecord_length; tree gfor_fndecl_set_max_subrecord_length;
...@@ -2364,15 +2364,11 @@ gfc_build_builtin_function_decls (void) ...@@ -2364,15 +2364,11 @@ gfc_build_builtin_function_decls (void)
gfc_build_library_function_decl (get_identifier (PREFIX("set_fpe")), gfc_build_library_function_decl (get_identifier (PREFIX("set_fpe")),
void_type_node, 1, gfc_c_int_type_node); void_type_node, 1, gfc_c_int_type_node);
gfor_fndecl_set_std = /* Keep the array dimension in sync with the call, later in this file. */
gfc_build_library_function_decl (get_identifier (PREFIX("set_std")), gfor_fndecl_set_options =
void_type_node, gfc_build_library_function_decl (get_identifier (PREFIX("set_options")),
5, void_type_node, 2, gfc_c_int_type_node,
gfc_int4_type_node, pvoid_type_node);
gfc_int4_type_node,
gfc_int4_type_node,
gfc_int4_type_node,
gfc_int4_type_node);
gfor_fndecl_set_convert = gfor_fndecl_set_convert =
gfc_build_library_function_decl (get_identifier (PREFIX("set_convert")), gfc_build_library_function_decl (get_identifier (PREFIX("set_convert")),
...@@ -3152,23 +3148,56 @@ gfc_generate_function_code (gfc_namespace * ns) ...@@ -3152,23 +3148,56 @@ gfc_generate_function_code (gfc_namespace * ns)
/* Now generate the code for the body of this function. */ /* Now generate the code for the body of this function. */
gfc_init_block (&body); gfc_init_block (&body);
/* If this is the main program, add a call to set_std to set up the /* If this is the main program, add a call to set_options to set up the
runtime library Fortran language standard parameters. */ runtime library Fortran language standard parameters. */
if (sym->attr.is_main_program) if (sym->attr.is_main_program)
{ {
tree gfc_int4_type_node = gfc_get_int_type (4); tree gfc_c_int_type_node = gfc_get_int_type (gfc_c_int_kind);
tmp = build_call_expr (gfor_fndecl_set_std, 5, tree array_type, array, var;
build_int_cst (gfc_int4_type_node,
gfc_option.warn_std), /* Passing a new option to the library requires four modifications:
build_int_cst (gfc_int4_type_node, + add it to the tree_cons list below
gfc_option.allow_std), + change the array size in the call to build_array_type
build_int_cst (gfc_int4_type_node, + change the first argument to the library call
pedantic), gfor_fndecl_set_options
build_int_cst (gfc_int4_type_node, + modify the library (runtime/compile_options.c)! */
gfc_option.flag_dump_core), array = tree_cons (NULL_TREE,
build_int_cst (gfc_int4_type_node, build_int_cst (gfc_c_int_type_node,
gfc_option.flag_backtrace)); gfc_option.warn_std), NULL_TREE);
array = tree_cons (NULL_TREE,
build_int_cst (gfc_c_int_type_node,
gfc_option.allow_std), array);
array = tree_cons (NULL_TREE,
build_int_cst (gfc_c_int_type_node, pedantic), array);
array = tree_cons (NULL_TREE,
build_int_cst (gfc_c_int_type_node,
gfc_option.flag_dump_core), array);
array = tree_cons (NULL_TREE,
build_int_cst (gfc_c_int_type_node,
gfc_option.flag_backtrace), array);
array = tree_cons (NULL_TREE,
build_int_cst (gfc_c_int_type_node,
gfc_option.flag_sign_zero), array);
array_type = build_array_type (gfc_c_int_type_node,
build_index_type (build_int_cst (NULL_TREE,
5)));
array = build_constructor_from_list (array_type, nreverse (array));
TREE_CONSTANT (array) = 1;
TREE_INVARIANT (array) = 1;
TREE_STATIC (array) = 1;
/* Create a static variable to hold the jump table. */
var = gfc_create_var (array_type, "options");
TREE_CONSTANT (var) = 1;
TREE_INVARIANT (var) = 1;
TREE_STATIC (var) = 1;
TREE_READONLY (var) = 1;
DECL_INITIAL (var) = array;
var = gfc_build_addr_expr (pvoid_type_node, var);
tmp = build_call_expr (gfor_fndecl_set_options, 2,
build_int_cst (gfc_c_int_type_node, 6), var);
gfc_add_expr_to_block (&body, tmp); gfc_add_expr_to_block (&body, tmp);
} }
......
...@@ -495,7 +495,7 @@ extern GTY(()) tree gfor_fndecl_runtime_error_at; ...@@ -495,7 +495,7 @@ extern GTY(()) tree gfor_fndecl_runtime_error_at;
extern GTY(()) tree gfor_fndecl_os_error; extern GTY(()) tree gfor_fndecl_os_error;
extern GTY(()) tree gfor_fndecl_generate_error; extern GTY(()) tree gfor_fndecl_generate_error;
extern GTY(()) tree gfor_fndecl_set_fpe; extern GTY(()) tree gfor_fndecl_set_fpe;
extern GTY(()) tree gfor_fndecl_set_std; extern GTY(()) tree gfor_fndecl_set_options;
extern GTY(()) tree gfor_fndecl_ttynam; extern GTY(()) tree gfor_fndecl_ttynam;
extern GTY(()) tree gfor_fndecl_ctime; extern GTY(()) tree gfor_fndecl_ctime;
extern GTY(()) tree gfor_fndecl_fdate; extern GTY(()) tree gfor_fndecl_fdate;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment