aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry DeLisle <jvdelisle@gcc.gnu.org>2007-07-15 16:29:19 +0000
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2007-07-15 16:29:19 +0000
commitb189aaa7111007cb29d7ebe701378106d67a0f10 (patch)
treeb304f4c7c4a642c3aa3b7788e5ba9d05dae4bc02
parentb3be7c90ac9eb3f4d6486fee69891c2eacb16c83 (diff)
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. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@126655 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog15
-rw-r--r--gcc/fortran/gfortran.h1
-rw-r--r--gcc/fortran/lang.opt4
-rw-r--r--gcc/fortran/options.c5
-rw-r--r--gcc/fortran/trans-decl.c77
-rw-r--r--gcc/fortran/trans.h2
6 files changed, 79 insertions, 25 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 9f8a27cfc10..c71a360dfc5 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,18 @@
+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>
PR fortran/32036
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 42edcd1468e..8bd80ce4c7a 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -1861,6 +1861,7 @@ typedef struct
int flag_cray_pointer;
int flag_d_lines;
int flag_openmp;
+ int flag_sign_zero;
int fpe;
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
index f5385a16599..2deb636c643 100644
--- a/gcc/fortran/lang.opt
+++ b/gcc/fortran/lang.opt
@@ -249,6 +249,10 @@ fshort-enums
Fortran
Use the narrowest integer type possible for enumeration types
+fsign-zero
+Fortran
+Apply negative sign to zero values
+
funderscoring
Fortran
Append underscores to externally visible names
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index 50f5e9400ac..4f3ec2ce8f9 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -102,6 +102,7 @@ gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED,
gfc_option.flag_cray_pointer = 0;
gfc_option.flag_d_lines = -1;
gfc_option.flag_openmp = 0;
+ gfc_option.flag_sign_zero = 1;
gfc_option.fpe = 0;
@@ -619,6 +620,10 @@ gfc_handle_option (size_t scode, const char *arg, int value)
gfc_handle_module_path_options (arg);
break;
+ case OPT_fsign_zero:
+ gfc_option.flag_sign_zero = value;
+ break;
+
case OPT_ffpe_trap_:
gfc_handle_fpe_trap_option (arg);
break;
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 49aaaf0e476..ddd80257192 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -88,7 +88,7 @@ tree gfor_fndecl_runtime_error_at;
tree gfor_fndecl_os_error;
tree gfor_fndecl_generate_error;
tree gfor_fndecl_set_fpe;
-tree gfor_fndecl_set_std;
+tree gfor_fndecl_set_options;
tree gfor_fndecl_set_convert;
tree gfor_fndecl_set_record_marker;
tree gfor_fndecl_set_max_subrecord_length;
@@ -2364,15 +2364,11 @@ gfc_build_builtin_function_decls (void)
gfc_build_library_function_decl (get_identifier (PREFIX("set_fpe")),
void_type_node, 1, gfc_c_int_type_node);
- gfor_fndecl_set_std =
- gfc_build_library_function_decl (get_identifier (PREFIX("set_std")),
- void_type_node,
- 5,
- gfc_int4_type_node,
- gfc_int4_type_node,
- gfc_int4_type_node,
- gfc_int4_type_node,
- gfc_int4_type_node);
+ /* Keep the array dimension in sync with the call, later in this file. */
+ gfor_fndecl_set_options =
+ gfc_build_library_function_decl (get_identifier (PREFIX("set_options")),
+ void_type_node, 2, gfc_c_int_type_node,
+ pvoid_type_node);
gfor_fndecl_set_convert =
gfc_build_library_function_decl (get_identifier (PREFIX("set_convert")),
@@ -3152,23 +3148,56 @@ gfc_generate_function_code (gfc_namespace * ns)
/* Now generate the code for the body of this function. */
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. */
-
if (sym->attr.is_main_program)
{
- tree gfc_int4_type_node = gfc_get_int_type (4);
- tmp = build_call_expr (gfor_fndecl_set_std, 5,
- build_int_cst (gfc_int4_type_node,
- gfc_option.warn_std),
- build_int_cst (gfc_int4_type_node,
- gfc_option.allow_std),
- build_int_cst (gfc_int4_type_node,
- pedantic),
- build_int_cst (gfc_int4_type_node,
- gfc_option.flag_dump_core),
- build_int_cst (gfc_int4_type_node,
- gfc_option.flag_backtrace));
+ tree gfc_c_int_type_node = gfc_get_int_type (gfc_c_int_kind);
+ tree array_type, array, var;
+
+ /* Passing a new option to the library requires four modifications:
+ + add it to the tree_cons list below
+ + change the array size in the call to build_array_type
+ + change the first argument to the library call
+ gfor_fndecl_set_options
+ + modify the library (runtime/compile_options.c)! */
+ array = tree_cons (NULL_TREE,
+ build_int_cst (gfc_c_int_type_node,
+ 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);
}
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
index 02fe413be03..b9fb1d28600 100644
--- a/gcc/fortran/trans.h
+++ b/gcc/fortran/trans.h
@@ -495,7 +495,7 @@ extern GTY(()) tree gfor_fndecl_runtime_error_at;
extern GTY(()) tree gfor_fndecl_os_error;
extern GTY(()) tree gfor_fndecl_generate_error;
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_ctime;
extern GTY(()) tree gfor_fndecl_fdate;