Commit 9fa52231 by Tobias Burnus Committed by Tobias Burnus

gfortran.h (gfc_option_t): Remove flag_whole_file.

2013-03-18  Tobias Burnus  <burnus@net-b.de>

        * gfortran.h (gfc_option_t): Remove flag_whole_file.
        * invoke.texi (-fno-whole-file): Remove.
        * lang.opt (fwhole-file): Change to Ignore.
        * options.c (gfc_init_options, gfc_post_options,
        gfc_handle_option): Remove !flag_whole_file handling
        * parse.c (resolve_all_program_units,
        * translate_all_program_units,
        gfc_parse_file): Ditto.
        * resolve.c (resolve_global_procedure): Ditto.
        * trans-decl.c (gfc_get_symbol_decl,
        * gfc_get_extern_function_decl,
        gfc_create_module_variable): Ditto.
        * trans-types.c (gfc_get_derived_type): Ditto.

From-SVN: r196773
parent 0d5a1b56
2013-03-18 Tobias Burnus <burnus@net-b.de>
* gfortran.h (gfc_option_t): Remove flag_whole_file.
* invoke.texi (-fno-whole-file): Remove.
* lang.opt (fwhole-file): Change to Ignore.
* options.c (gfc_init_options, gfc_post_options,
gfc_handle_option): Remove !flag_whole_file handling
* parse.c (resolve_all_program_units, translate_all_program_units,
gfc_parse_file): Ditto.
* resolve.c (resolve_global_procedure): Ditto.
* trans-decl.c (gfc_get_symbol_decl, gfc_get_extern_function_decl,
gfc_create_module_variable): Ditto.
* trans-types.c (gfc_get_derived_type): Ditto.
2013-03-15 Tobias Burnus <burnus@net-b.de> 2013-03-15 Tobias Burnus <burnus@net-b.de>
PR fortran/56615 PR fortran/56615
......
...@@ -2297,7 +2297,6 @@ typedef struct ...@@ -2297,7 +2297,6 @@ typedef struct
int flag_init_character; int flag_init_character;
char flag_init_character_value; char flag_init_character_value;
int flag_align_commons; int flag_align_commons;
int flag_whole_file;
int flag_protect_parens; int flag_protect_parens;
int flag_realloc_lhs; int flag_realloc_lhs;
int flag_aggressive_function_elimination; int flag_aggressive_function_elimination;
......
...@@ -180,7 +180,7 @@ and warnings}. ...@@ -180,7 +180,7 @@ and warnings}.
-finit-real=@var{<zero|inf|-inf|nan|snan>} @gol -finit-real=@var{<zero|inf|-inf|nan|snan>} @gol
-fmax-array-constructor=@var{n} -fmax-stack-var-size=@var{n} -fmax-array-constructor=@var{n} -fmax-stack-var-size=@var{n}
-fno-align-commons @gol -fno-align-commons @gol
-fno-automatic -fno-protect-parens -fno-underscoring -fno-whole-file @gol -fno-automatic -fno-protect-parens -fno-underscoring @gol
-fsecond-underscore -fpack-derived -frealloc-lhs -frecursive @gol -fsecond-underscore -fpack-derived -frealloc-lhs -frecursive @gol
-frepack-arrays -fshort-enums -fstack-arrays -frepack-arrays -fshort-enums -fstack-arrays
} }
...@@ -1291,22 +1291,6 @@ in the source, even if the names as seen by the linker are mangled to ...@@ -1291,22 +1291,6 @@ in the source, even if the names as seen by the linker are mangled to
prevent accidental linking between procedures with incompatible prevent accidental linking between procedures with incompatible
interfaces. interfaces.
@item -fno-whole-file
@opindex @code{fno-whole-file}
This flag causes the compiler to resolve and translate each procedure in
a file separately.
By default, the whole file is parsed and placed in a single front-end tree.
During resolution, in addition to all the usual checks and fixups, references
to external procedures that are in the same file effect resolution of
that procedure, if not already done, and a check of the interfaces. The
dependences are resolved by changing the order in which the file is
translated into the backend tree. Thus, a procedure that is referenced
is translated before the reference and the duplication of backend tree
declarations eliminated.
The @option{-fno-whole-file} option is deprecated and may lead to wrong code.
@item -fsecond-underscore @item -fsecond-underscore
@opindex @code{fsecond-underscore} @opindex @code{fsecond-underscore}
@cindex underscore @cindex underscore
......
...@@ -594,8 +594,8 @@ Fortran ...@@ -594,8 +594,8 @@ Fortran
Append underscores to externally visible names Append underscores to externally visible names
fwhole-file fwhole-file
Fortran Fortran Ignore
Compile all program units at once and check all interfaces Does nothing. Preserved for backward compatibility.
fworking-directory fworking-directory
Fortran Fortran
......
...@@ -124,7 +124,6 @@ gfc_init_options (unsigned int decoded_options_count, ...@@ -124,7 +124,6 @@ gfc_init_options (unsigned int decoded_options_count,
gfc_option.flag_real8_kind = 0; gfc_option.flag_real8_kind = 0;
gfc_option.flag_dollar_ok = 0; gfc_option.flag_dollar_ok = 0;
gfc_option.flag_underscoring = 1; gfc_option.flag_underscoring = 1;
gfc_option.flag_whole_file = 1;
gfc_option.flag_f2c = 0; gfc_option.flag_f2c = 0;
gfc_option.flag_second_underscore = -1; gfc_option.flag_second_underscore = -1;
gfc_option.flag_implicit_none = 0; gfc_option.flag_implicit_none = 0;
...@@ -264,14 +263,6 @@ gfc_post_options (const char **pfilename) ...@@ -264,14 +263,6 @@ gfc_post_options (const char **pfilename)
sorry ("-fexcess-precision=standard for Fortran"); sorry ("-fexcess-precision=standard for Fortran");
flag_excess_precision_cmdline = EXCESS_PRECISION_FAST; flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
/* Whole program needs whole file mode. */
if (flag_whole_program)
gfc_option.flag_whole_file = 1;
/* Enable whole-file mode if LTO is in effect. */
if (flag_lto)
gfc_option.flag_whole_file = 1;
/* Fortran allows associative math - but we cannot reassociate if /* Fortran allows associative math - but we cannot reassociate if
we want traps or signed zeros. Cf. also flag_protect_parens. */ we want traps or signed zeros. Cf. also flag_protect_parens. */
if (flag_associative_math == -1) if (flag_associative_math == -1)
...@@ -430,9 +421,6 @@ gfc_post_options (const char **pfilename) ...@@ -430,9 +421,6 @@ gfc_post_options (const char **pfilename)
gfc_option.warn_tabs = 0; gfc_option.warn_tabs = 0;
} }
if (pedantic && gfc_option.flag_whole_file)
gfc_option.flag_whole_file = 2;
/* Optimization implies front end optimization, unless the user /* Optimization implies front end optimization, unless the user
specified it directly. */ specified it directly. */
...@@ -823,10 +811,6 @@ gfc_handle_option (size_t scode, const char *arg, int value, ...@@ -823,10 +811,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
gfc_option.flag_underscoring = value; gfc_option.flag_underscoring = value;
break; break;
case OPT_fwhole_file:
gfc_option.flag_whole_file = value;
break;
case OPT_fsecond_underscore: case OPT_fsecond_underscore:
gfc_option.flag_second_underscore = value; gfc_option.flag_second_underscore = value;
break; break;
......
...@@ -4382,8 +4382,7 @@ add_global_program (void) ...@@ -4382,8 +4382,7 @@ add_global_program (void)
} }
/* Resolve all the program units when whole file scope option /* Resolve all the program units. */
is active. */
static void static void
resolve_all_program_units (gfc_namespace *gfc_global_ns_list) resolve_all_program_units (gfc_namespace *gfc_global_ns_list)
{ {
...@@ -4424,9 +4423,8 @@ clean_up_modules (gfc_gsymbol *gsym) ...@@ -4424,9 +4423,8 @@ clean_up_modules (gfc_gsymbol *gsym)
} }
/* Translate all the program units when whole file scope option /* Translate all the program units. This could be in a different order
is active. This could be in a different order to resolution if to resolution if there are forward references in the file. */
there are forward references in the file. */
static void static void
translate_all_program_units (gfc_namespace *gfc_global_ns_list, translate_all_program_units (gfc_namespace *gfc_global_ns_list,
bool main_in_tu) bool main_in_tu)
...@@ -4551,8 +4549,7 @@ loop: ...@@ -4551,8 +4549,7 @@ loop:
accept_statement (st); accept_statement (st);
add_global_program (); add_global_program ();
parse_progunit (ST_NONE); parse_progunit (ST_NONE);
if (gfc_option.flag_whole_file) goto prog_units;
goto prog_units;
break; break;
case ST_SUBROUTINE: case ST_SUBROUTINE:
...@@ -4560,8 +4557,7 @@ loop: ...@@ -4560,8 +4557,7 @@ loop:
push_state (&s, COMP_SUBROUTINE, gfc_new_block); push_state (&s, COMP_SUBROUTINE, gfc_new_block);
accept_statement (st); accept_statement (st);
parse_progunit (ST_NONE); parse_progunit (ST_NONE);
if (gfc_option.flag_whole_file) goto prog_units;
goto prog_units;
break; break;
case ST_FUNCTION: case ST_FUNCTION:
...@@ -4569,8 +4565,7 @@ loop: ...@@ -4569,8 +4565,7 @@ loop:
push_state (&s, COMP_FUNCTION, gfc_new_block); push_state (&s, COMP_FUNCTION, gfc_new_block);
accept_statement (st); accept_statement (st);
parse_progunit (ST_NONE); parse_progunit (ST_NONE);
if (gfc_option.flag_whole_file) goto prog_units;
goto prog_units;
break; break;
case ST_BLOCK_DATA: case ST_BLOCK_DATA:
...@@ -4597,8 +4592,7 @@ loop: ...@@ -4597,8 +4592,7 @@ loop:
push_state (&s, COMP_PROGRAM, gfc_new_block); push_state (&s, COMP_PROGRAM, gfc_new_block);
main_program_symbol (gfc_current_ns, "MAIN__"); main_program_symbol (gfc_current_ns, "MAIN__");
parse_progunit (st); parse_progunit (st);
if (gfc_option.flag_whole_file) goto prog_units;
goto prog_units;
break; break;
} }
...@@ -4615,19 +4609,9 @@ loop: ...@@ -4615,19 +4609,9 @@ loop:
if (s.state == COMP_MODULE) if (s.state == COMP_MODULE)
{ {
gfc_dump_module (s.sym->name, errors_before == errors); gfc_dump_module (s.sym->name, errors_before == errors);
if (!gfc_option.flag_whole_file) gfc_current_ns->derived_types = gfc_derived_types;
{ gfc_derived_types = NULL;
if (errors == 0) goto prog_units;
gfc_generate_module_code (gfc_current_ns);
pop_state ();
gfc_done_2 ();
}
else
{
gfc_current_ns->derived_types = gfc_derived_types;
gfc_derived_types = NULL;
goto prog_units;
}
} }
else else
{ {
...@@ -4660,9 +4644,6 @@ prog_units: ...@@ -4660,9 +4644,6 @@ prog_units:
done: done:
if (!gfc_option.flag_whole_file)
goto termination;
/* Do the resolution. */ /* Do the resolution. */
resolve_all_program_units (gfc_global_ns_list); resolve_all_program_units (gfc_global_ns_list);
...@@ -4681,8 +4662,6 @@ prog_units: ...@@ -4681,8 +4662,6 @@ prog_units:
/* Do the translation. */ /* Do the translation. */
translate_all_program_units (gfc_global_ns_list, seen_program); translate_all_program_units (gfc_global_ns_list, seen_program);
termination:
gfc_end_source_files (); gfc_end_source_files ();
return SUCCESS; return SUCCESS;
......
...@@ -2145,15 +2145,14 @@ resolve_global_procedure (gfc_symbol *sym, locus *where, ...@@ -2145,15 +2145,14 @@ resolve_global_procedure (gfc_symbol *sym, locus *where,
if ((gsym->type != GSYM_UNKNOWN && gsym->type != type)) if ((gsym->type != GSYM_UNKNOWN && gsym->type != type))
gfc_global_used (gsym, where); gfc_global_used (gsym, where);
if (gfc_option.flag_whole_file if ((sym->attr.if_source == IFSRC_UNKNOWN
&& (sym->attr.if_source == IFSRC_UNKNOWN || sym->attr.if_source == IFSRC_IFBODY)
|| sym->attr.if_source == IFSRC_IFBODY) && gsym->type != GSYM_UNKNOWN
&& gsym->type != GSYM_UNKNOWN && gsym->ns
&& gsym->ns && gsym->ns->resolved != -1
&& gsym->ns->resolved != -1 && gsym->ns->proc_name
&& gsym->ns->proc_name && not_in_recursive (sym, gsym->ns)
&& not_in_recursive (sym, gsym->ns) && not_entry_self_reference (sym, gsym->ns))
&& not_entry_self_reference (sym, gsym->ns))
{ {
gfc_symbol *def_sym; gfc_symbol *def_sym;
...@@ -2364,7 +2363,7 @@ resolve_global_procedure (gfc_symbol *sym, locus *where, ...@@ -2364,7 +2363,7 @@ resolve_global_procedure (gfc_symbol *sym, locus *where,
"an explicit interface", sym->name, &sym->declared_at); "an explicit interface", sym->name, &sym->declared_at);
} }
if (gfc_option.flag_whole_file == 1 if (!pedantic
|| ((gfc_option.warn_std & GFC_STD_LEGACY) || ((gfc_option.warn_std & GFC_STD_LEGACY)
&& !(gfc_option.warn_std & GFC_STD_GNU))) && !(gfc_option.warn_std & GFC_STD_GNU)))
gfc_errors_to_warnings (1); gfc_errors_to_warnings (1);
......
...@@ -1341,15 +1341,14 @@ gfc_get_symbol_decl (gfc_symbol * sym) ...@@ -1341,15 +1341,14 @@ gfc_get_symbol_decl (gfc_symbol * sym)
&& sym->attr.flavor == FL_PARAMETER) && sym->attr.flavor == FL_PARAMETER)
intrinsic_array_parameter = true; intrinsic_array_parameter = true;
/* If use associated and whole file compilation, use the module /* If use associated compilation, use the module
declaration. */ declaration. */
if (gfc_option.flag_whole_file if ((sym->attr.flavor == FL_VARIABLE
&& (sym->attr.flavor == FL_VARIABLE || sym->attr.flavor == FL_PARAMETER)
|| sym->attr.flavor == FL_PARAMETER) && sym->attr.use_assoc
&& sym->attr.use_assoc && !intrinsic_array_parameter
&& !intrinsic_array_parameter && sym->module
&& sym->module && gfc_get_module_backend_decl (sym))
&& gfc_get_module_backend_decl (sym))
{ {
if (sym->ts.type == BT_CLASS && sym->backend_decl) if (sym->ts.type == BT_CLASS && sym->backend_decl)
GFC_DECL_CLASS(sym->backend_decl) = 1; GFC_DECL_CLASS(sym->backend_decl) = 1;
...@@ -1646,12 +1645,11 @@ gfc_get_extern_function_decl (gfc_symbol * sym) ...@@ -1646,12 +1645,11 @@ gfc_get_extern_function_decl (gfc_symbol * sym)
return the backend_decl. */ return the backend_decl. */
gsym = gfc_find_gsymbol (gfc_gsym_root, sym->name); gsym = gfc_find_gsymbol (gfc_gsym_root, sym->name);
if (gfc_option.flag_whole_file if ((!sym->attr.use_assoc || sym->attr.if_source != IFSRC_DECL)
&& (!sym->attr.use_assoc || sym->attr.if_source != IFSRC_DECL) && !sym->backend_decl
&& !sym->backend_decl && gsym && gsym->ns
&& gsym && gsym->ns && ((gsym->type == GSYM_SUBROUTINE) || (gsym->type == GSYM_FUNCTION))
&& ((gsym->type == GSYM_SUBROUTINE) || (gsym->type == GSYM_FUNCTION)) && (gsym->ns->proc_name->backend_decl || !sym->attr.intrinsic))
&& (gsym->ns->proc_name->backend_decl || !sym->attr.intrinsic))
{ {
if (!gsym->ns->proc_name->backend_decl) if (!gsym->ns->proc_name->backend_decl)
{ {
...@@ -1703,9 +1701,7 @@ gfc_get_extern_function_decl (gfc_symbol * sym) ...@@ -1703,9 +1701,7 @@ gfc_get_extern_function_decl (gfc_symbol * sym)
if (sym->module) if (sym->module)
gsym = gfc_find_gsymbol (gfc_gsym_root, sym->module); gsym = gfc_find_gsymbol (gfc_gsym_root, sym->module);
if (gfc_option.flag_whole_file if (gsym && gsym->ns && gsym->type == GSYM_MODULE)
&& gsym && gsym->ns
&& gsym->type == GSYM_MODULE)
{ {
gfc_symbol *s; gfc_symbol *s;
...@@ -4047,8 +4043,7 @@ gfc_create_module_variable (gfc_symbol * sym) ...@@ -4047,8 +4043,7 @@ gfc_create_module_variable (gfc_symbol * sym)
decl = sym->backend_decl; decl = sym->backend_decl;
gcc_assert (sym->ns->proc_name->attr.flavor == FL_MODULE); gcc_assert (sym->ns->proc_name->attr.flavor == FL_MODULE);
/* -fwhole-file mixes up the contexts so these asserts are unnecessary. */ if (!sym->attr.use_assoc)
if (!(gfc_option.flag_whole_file && sym->attr.use_assoc))
{ {
gcc_assert (TYPE_CONTEXT (decl) == NULL_TREE gcc_assert (TYPE_CONTEXT (decl) == NULL_TREE
|| TYPE_CONTEXT (decl) == sym->ns->proc_name->backend_decl); || TYPE_CONTEXT (decl) == sym->ns->proc_name->backend_decl);
......
...@@ -2370,19 +2370,16 @@ gfc_get_derived_type (gfc_symbol * derived) ...@@ -2370,19 +2370,16 @@ gfc_get_derived_type (gfc_symbol * derived)
} }
/* If use associated, use the module type for this one. */ /* If use associated, use the module type for this one. */
if (gfc_option.flag_whole_file if (derived->backend_decl == NULL
&& derived->backend_decl == NULL && derived->attr.use_assoc
&& derived->attr.use_assoc && derived->module
&& derived->module && gfc_get_module_backend_decl (derived))
&& gfc_get_module_backend_decl (derived))
goto copy_derived_types; goto copy_derived_types;
/* If a whole file compilation, the derived types from an earlier /* The derived types from an earlier namespace can be used as the
namespace can be used as the canonical type. */ canonical type. */
if (gfc_option.flag_whole_file if (derived->backend_decl == NULL && !derived->attr.use_assoc
&& derived->backend_decl == NULL && gfc_global_ns_list)
&& !derived->attr.use_assoc
&& gfc_global_ns_list)
{ {
for (ns = gfc_global_ns_list; for (ns = gfc_global_ns_list;
ns->translated && !got_canonical; ns->translated && !got_canonical;
......
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