[Patch, fortran] PR40011 - Problems with -fwhole-file

Richard Guenther richard.guenther@gmail.com
Mon Jul 27 08:31:00 GMT 2009


On Sun, Jul 26, 2009 at 6:44 PM, Paul Richard
Thomas<paul.richard.thomas@gmail.com> wrote:
> Here is the latest version of the whole file patch.  I have checked it
> out reasobalythoroughly for the logic around the clean-up.
>
> Richi might be relieved that the necessity for this chunk is no longer
> evident to me:
>
> Index: gcc/fortran/trans-decl.c
> ===================================================================
> --- gcc/fortran/trans-decl.c    (revision 149952)
> +++ gcc/fortran/trans-decl.c    (working copy)
> @@ -578,6 +578,10 @@
>   if (sym->attr.threadprivate
>       && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
>     DECL_TLS_MODEL (decl) = decl_default_tls_model (decl);
> +
> +  /* Code with static variables must not be inlined.  */
> +  if (TREE_STATIC (decl) && DECL_CONTEXT (decl))
> +    DECL_UNINLINABLE(DECL_CONTEXT (decl)) = 1;
>  }
>

Heh, nice.

> The final wrinkle that I need to sort out is in gfc_get_derived_type,
> where I am not entirely convinced that module derived types need be
> copied, rather than adorned with a TYPE_CANONICAL.  I also have to
> change the documentation to reflect these changes.

Do you mean this hunk?

+  /* If use associated and whole file compilation, use the module
+     declaration.  This is only needed for intrinsic types because
+     they are substituted for one another during optimization.  */
+  if (gfc_option.flag_whole_file
+       && sym->attr.flavor == FL_VARIABLE
+       && sym->ts.type != BT_DERIVED
+       && sym->attr.use_assoc
+       && sym->module)

why do you think this is not necessary for derived types?  How would
a testcase look like that has derived tyoes?

+      if (ts.type == BT_DERIVED)
+       TYPE_MAIN_VARIANT (TREE_TYPE (rse->expr))
+               = TYPE_MAIN_VARIANT (TREE_TYPE (lse->expr));

hm, this looks odd (or rather wrong).  Care to explain?

It looks like derived types are somehow special - what are they?

> Bootstrapped and regtested on x86_64/FC9 - OK for trunk?

Certainly progress - I'd like to see this in trunk regardless of my above
questions.

Thanks for this work!
Richard.

> Paul
>
> 2009-07-26  Paul Thomas  <pault@gcc.gnu.org>
>
>        PR fortran/40011
>        * error.c : Add static flag 'warnings_not_errors'.
>        (gfc_error): If 'warnings_not_errors' is set, branch to code
>        from gfc_warning.
>        (gfc_clear_error): Reset 'warnings_not_errors'.
>        (gfc_errors_to_warnings): New function.
>        * options.c (gfc_post_options): If pedantic and flag_whole_file
>        change the latter to a value of 2.
>        * parse.c (parse_module): Add module namespace to gsymbol.
>        (resolve_all_program_units): New function.
>        (clean_up_modules): New function.
>        (translate_all_program_units): New function.
>        (gfc_parse_file): If whole_file, do not clean up module right
>        away and add derived types to namespace derived types. In
>        addition, call the three new functions above.
>        * resolve.c (not_in_recursive): New function.
>        (not_entry_self_reference): New function.
>        (resolve_global_procedure): Symbol must not be IFSRC_UNKNOWN,
>        procedure must not be in the course of being resolved and
>        must return false for the two new functions. Pack away the
>        current derived type list before calling gfc_resolve for the
>        gsymbol namespace.  It is unconditionally an error if the ranks
>        of the reference and ther procedure do not match. Convert
>        errors to warnings during call to gfc_procedure_use if not
>        pedantic or legacy.
>        (gfc_resolve): Set namespace resolved flag to -1 during
>        resolution and store current cs_base.
>        * trans-decl.c (gfc_get_symbol_decl): If whole_file compilation
>        substitute a use associated variable, if it is available in a
>        gsymbolnamespace.
>        (gfc_get_extern_function_decl): If the procedure is use assoc,
>        do not attempt to find it in a gsymbol because it could be an
>        interface. If the symbol exists in a modulnamespace, return
>        its backend_decl.
>        * trans-expr.c (gfc_trans_scalar_assign): If a derived type
>        assignment, set the rhs TYPE_MAIN_VARIANT to that of the rhs.
>        * trans-types.c (copy_dt_decls_ifequal): Add 'from_gsym' as a
>        boolean argument. Copy component backend_decls directly if the
>        components are derived types and from_gsym is true.
>        (gfc_get_derived_type): If whole_file copy the derived type from
>        the module if it is use associated, otherwise, if can be found
>        in another gsymbol namespace, use the existing derived type as
>        the TYPE_CANONICAL and build normally.
>        * gfortran.h : Add derived_types and resolved fields to
>        gfc_namespace. Include prototype for gfc_errors_to_warnings.
>
> 2009-07-26  Paul Thomas  <pault@gcc.gnu.org>
>
>        PR fortran/40011
>        * gfortran.dg/whole_file_7.f90: New test.
>        * gfortran.dg/whole_file_8.f90: New test.
>        * gfortran.dg/whole_file_9.f90: New test.
>        * gfortran.dg/whole_file_10.f90: New test.
>        * gfortran.dg/whole_file_11.f90: New test.
>        * gfortran.dg/whole_file_12.f90: New test.
>        * gfortran.dg/whole_file_13.f90: New test.
>        * gfortran.dg/whole_file_14.f90: New test.
>



More information about the Gcc-patches mailing list