summaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-decl.c
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <coudert@clipper.ens.fr>2005-08-11 15:50:13 +0200
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2005-08-11 13:50:13 +0000
commit8b67b708f159a6776a07d6eec9c44d3dc8ab9f6e (patch)
treed2c54ce8afd0ee3ffde950228cb4b59edbde4431 /gcc/fortran/trans-decl.c
parent74b002ba34f1d63cc0130ad44076b462477c631f (diff)
downloadgcc-8b67b708f159a6776a07d6eec9c44d3dc8ab9f6e.tar.gz
re PR libfortran/20006 ($ format extension doesn't work)
PR libfortran/20006 * gfortran.h: Add is_main_program member to symbol_attribute. * trans-decl: Add a gfor_fndecl_set_std tree. (gfc_build_builtin_function_decls): Create it. (gfc_generate_function_code): Add this call at the beginning of the main program. * trans.c (gfc_generate_code): Move main_program and attr. * trans.h: Add declaration for gfor_fndecl_set_std. * Makefile.am: Add file runtime/compile_options.c. * Makefile.in: Regenerate. * libgfortran.h: Create structure compile_options_t. Define the compile_options variable and GFC_STD_ macros. * runtime/compile_options.c: New file. * runtime/error.c (notify_std): New function. * runtime/main.c (init): Call init_compile_options during initialization. * io/format.c: Use the new notify_std function for the $ descriptor extension. * gfortran.dg/runtime_warning_1.f90: New test. Co-Authored-By: Steven Bosscher <stevenb@suse.de> From-SVN: r102990
Diffstat (limited to 'gcc/fortran/trans-decl.c')
-rw-r--r--gcc/fortran/trans-decl.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 49811eb0f98..3488cde9096 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -83,6 +83,7 @@ tree gfor_fndecl_stop_numeric;
tree gfor_fndecl_stop_string;
tree gfor_fndecl_select_string;
tree gfor_fndecl_runtime_error;
+tree gfor_fndecl_set_std;
tree gfor_fndecl_in_pack;
tree gfor_fndecl_in_unpack;
tree gfor_fndecl_associated;
@@ -1941,6 +1942,13 @@ gfc_build_builtin_function_decls (void)
/* The runtime_error function does not return. */
TREE_THIS_VOLATILE (gfor_fndecl_runtime_error) = 1;
+ gfor_fndecl_set_std =
+ gfc_build_library_function_decl (get_identifier (PREFIX("set_std")),
+ void_type_node,
+ 2,
+ gfc_int4_type_node,
+ gfc_int4_type_node);
+
gfor_fndecl_in_pack = gfc_build_library_function_decl (
get_identifier (PREFIX("internal_pack")),
pvoid_type_node, 1, pvoid_type_node);
@@ -2349,6 +2357,24 @@ 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 and we compile with -pedantic, add a call
+ to set_std to set up the runtime library Fortran language standard
+ parameters. */
+ if (sym->attr.is_main_program && pedantic)
+ {
+ tree arglist, gfc_int4_type_node;
+
+ gfc_int4_type_node = gfc_get_int_type (4);
+ arglist = gfc_chainon_list (NULL_TREE,
+ build_int_cst (gfc_int4_type_node,
+ gfc_option.warn_std));
+ arglist = gfc_chainon_list (arglist,
+ build_int_cst (gfc_int4_type_node,
+ gfc_option.allow_std));
+ tmp = gfc_build_function_call (gfor_fndecl_set_std, arglist);
+ gfc_add_expr_to_block (&body, tmp);
+ }
+
if (TREE_TYPE (DECL_RESULT (fndecl)) != void_type_node
&& sym->attr.subroutine)
{