]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/44945 (Wrong decl for module vars / FAIL: gfortran.dg/char_array_struct...
authorTobias Burnus <burnus@net-b.de>
Fri, 23 Jul 2010 20:13:07 +0000 (22:13 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Fri, 23 Jul 2010 20:13:07 +0000 (22:13 +0200)
2010-07-23  Tobias Burnus  <burnus@net-b.de>

        PR fortran/44945
        * trans-decl.c (gfc_get_symbol_decl): Use module decl with
        -fwhole-file also for derived types.
        * trans-types.c (copy_dt_decls_ifequal): Remove static and
        rename to gfc_copy_dt_decls_ifequal.
        (gfc_get_derived_type): Update call.
        * trans-types.h (gfc_copy_dt_decls_ifequal): Add prototype.

2010-07-23  Tobias Burnus  <burnus@net-b.de>

        PR fortran/44945
        * gfortran.dg/char_array_structure_constructor.f90: Add
        -fwhole-file as dg-option as it otherwise fails on some
        systems.

From-SVN: r162487

gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c
gcc/fortran/trans-types.c
gcc/fortran/trans-types.h
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/char_array_structure_constructor.f90

index 0fac55c00024f076892e3e4fd42164cb54b68b70..e485e726a9782fb7d67163ba313e1fdd05ff2816 100644 (file)
@@ -1,3 +1,13 @@
+2010-07-23  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/44945
+       * trans-decl.c (gfc_get_symbol_decl): Use module decl with
+       -fwhole-file also for derived types.
+       * trans-types.c (copy_dt_decls_ifequal): Remove static and
+       rename to gfc_copy_dt_decls_ifequal.
+       (gfc_get_derived_type): Update call.
+       * trans-types.h (gfc_copy_dt_decls_ifequal): Add prototype.
+
 2010-07-23  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/45030
index 2b030110231277ad2981f2512805444c579b08ba..a1789ea74589f4cb3155d48d330d8224302f6fb0 100644 (file)
@@ -1129,11 +1129,9 @@ gfc_get_symbol_decl (gfc_symbol * sym)
     return sym->backend_decl;
 
   /* 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.  */
+     declaration.  */
   if (gfc_option.flag_whole_file
        && sym->attr.flavor == FL_VARIABLE
-       && sym->ts.type != BT_DERIVED
        && sym->attr.use_assoc
        && sym->module)
     {
@@ -1147,6 +1145,9 @@ gfc_get_symbol_decl (gfc_symbol * sym)
          gfc_find_symbol (sym->name, gsym->ns, 0, &s);
          if (s && s->backend_decl)
            {
+             if (sym->ts.type == BT_DERIVED)
+               gfc_copy_dt_decls_ifequal (s->ts.u.derived, sym->ts.u.derived,
+                                          true);
              if (sym->ts.type == BT_CHARACTER)
                sym->ts.u.cl->backend_decl = s->ts.u.cl->backend_decl;
              return s->backend_decl;
index 34efa9ad82c935a9818b3e2923705e6ae63e18f0..62b298c213b98137717a0eb49dc9e9f61a1e8906 100644 (file)
@@ -1884,8 +1884,8 @@ gfc_add_field_to_struct (tree context, tree name, tree type, tree **chain)
    the two derived type symbols are "equal", as described
    in 4.4.2 and resolved by gfc_compare_derived_types.  */
 
-static int
-copy_dt_decls_ifequal (gfc_symbol *from, gfc_symbol *to,
+int
+gfc_copy_dt_decls_ifequal (gfc_symbol *from, gfc_symbol *to,
                       bool from_gsym)
 {
   gfc_component *to_cm;
@@ -1996,7 +1996,7 @@ gfc_get_derived_type (gfc_symbol * derived)
          gfc_find_symbol (derived->name, gsym->ns, 0, &s);
          if (s && s->backend_decl)
            {
-             copy_dt_decls_ifequal (s, derived, true);
+             gfc_copy_dt_decls_ifequal (s, derived, true);
              goto copy_derived_types;
            }
        }
@@ -2016,7 +2016,7 @@ gfc_get_derived_type (gfc_symbol * derived)
          dt = ns->derived_types;
          for (; dt && !canonical; dt = dt->next)
            {
-             copy_dt_decls_ifequal (dt->derived, derived, true);
+             gfc_copy_dt_decls_ifequal (dt->derived, derived, true);
              if (derived->backend_decl)
                got_canonical = true;
            }
@@ -2183,7 +2183,7 @@ gfc_get_derived_type (gfc_symbol * derived)
 copy_derived_types:
 
   for (dt = gfc_derived_types; dt; dt = dt->next)
-    copy_dt_decls_ifequal (derived, dt->derived, false);
+    gfc_copy_dt_decls_ifequal (derived, dt->derived, false);
 
   return derived->backend_decl;
 }
index 7e79480c4388d2d98f134f5ed275c0367716165e..63427f394e9fa38c28c2af32a9a2135bf10e970e 100644 (file)
@@ -64,6 +64,7 @@ tree gfc_get_character_type_len_for_eltype (tree, tree);
 
 tree gfc_sym_type (gfc_symbol *);
 tree gfc_typenode_for_spec (gfc_typespec *);
+int gfc_copy_dt_decls_ifequal (gfc_symbol *, gfc_symbol *, bool);
 
 tree gfc_get_function_type (gfc_symbol *);
 
index bdc2660cbbec71858f6961590f2be0fd669d81ae..4083476e2549b40f04a97f55c6296edb69c73929 100644 (file)
@@ -1,3 +1,10 @@
+2010-07-23  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/44945
+       * gfortran.dg/char_array_structure_constructor.f90: Add
+       -fwhole-file as dg-option as it otherwise fails on some
+       systems.
+
 2010-07-23  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/aggr16.ad[sb]: New test.
index 9d058748855a348c4e719aec5d7127c7a81d713c..22669363e0fc671e10d490cf4f1ef69398a51227 100644 (file)
@@ -1,4 +1,9 @@
 ! { dg-do run }
+! { dg-options "-fwhole-file" }
+!
+! PR fortran/19107
+! -fwhole-file flag added for PR fortran/44945
+!
 ! This test the fix of PR19107, where character array actual
 ! arguments in derived type constructors caused an ICE.
 ! It also checks that the scalar counterparts are OK.