diff options
Diffstat (limited to 'gcc/fortran/trans-decl.c')
-rw-r--r-- | gcc/fortran/trans-decl.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 49811eb..3488cde 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) { |