From eaa90d25da32a3329c9e434f8117c9122de1fa80 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Mon, 6 Feb 2006 20:12:44 +0000 Subject: re PR fortran/23815 (Add -byteswapio flag) 2005-02-06 Thomas Koenig PR libfortran/23815 * gfortran.texi: Document the GFORTRAN_CONVERT_UNIT environment variable. * invoke.texi: Mention the "Runtime" chapter. Document the -fconvert= option. * gfortran.h: Add options_convert. * lang.opt: Add fconvert=little-endian, fconvert=big-endian, fconvert=native and fconvert=swap. * trans-decl.c (top level): Add gfor_fndecl_set_convert. (gfc_build_builtin_function_decls): Set gfor_fndecl_set_convert. (gfc_generate_function_code): If -fconvert was specified, and this is the main program, add a call to set_convert(). * options.c: Handle the -fconvert options. 2005-02-06 Thomas Koenig PR libfortran/23815 * runtime/environ.c (init_unformatted): Add GFORTRAN_CONVERT_UNIT environment variable. (top level): Add defines, type and static variables for GFORTRAN_CONVERT_UNIT handling. (search_unit): New function. (match_word): New function. (match_integer): New function. (next_token): New function. (push_token): New function. (mark_single): New function. (mark_range): New funciton. (do_parse): New function. (init_unformatted): New function. (get_unformatted_convert): New function. * runtime/compile_options.c: Add set_convert(). * libgfortran.h: Add convert to compile_options_t. * io/open.c (st_open): Call get_unformatted_convert to get unit default; if CONVERT_NONE is returned, check for the presence of a CONVERT specifier and use it. As default, use compile_options.convert. * io/io.h (top level): Add CONVERT_NONE to unit_convert, to signal "nothing has been set". (top level): Add prototype for get_unformatted_convert. 2005-02-06 Thomas Koenig PR libfortran/23815 * unf_io_convert_4.f90: New test. From-SVN: r110664 --- gcc/fortran/trans-decl.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'gcc/fortran/trans-decl.c') diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index cdbb999..4811b7a 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -88,6 +88,7 @@ tree gfor_fndecl_select_string; tree gfor_fndecl_runtime_error; tree gfor_fndecl_set_fpe; tree gfor_fndecl_set_std; +tree gfor_fndecl_set_convert; tree gfor_fndecl_ctime; tree gfor_fndecl_fdate; tree gfor_fndecl_ttynam; @@ -2229,6 +2230,10 @@ gfc_build_builtin_function_decls (void) gfc_int4_type_node, gfc_int4_type_node); + gfor_fndecl_set_convert = + gfc_build_library_function_decl (get_identifier (PREFIX("set_convert")), + void_type_node, 1, gfc_c_int_type_node); + gfor_fndecl_in_pack = gfc_build_library_function_decl ( get_identifier (PREFIX("internal_pack")), pvoid_type_node, 1, pvoid_type_node); @@ -2845,6 +2850,22 @@ gfc_generate_function_code (gfc_namespace * ns) gfc_add_expr_to_block (&body, tmp); } + /* If this is the main program and an -fconvert option was provided, + add a call to set_convert. */ + + if (sym->attr.is_main_program && gfc_option.convert != CONVERT_NATIVE) + { + tree arglist, gfc_c_int_type_node; + + gfc_c_int_type_node = gfc_get_int_type (gfc_c_int_kind); + arglist = gfc_chainon_list (NULL_TREE, + build_int_cst (gfc_c_int_type_node, + gfc_option.convert)); + tmp = build_function_call_expr (gfor_fndecl_set_convert, arglist); + gfc_add_expr_to_block (&body, tmp); + } + + if (TREE_TYPE (DECL_RESULT (fndecl)) != void_type_node && sym->attr.subroutine) { -- cgit v1.1