2010-07-16  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.

2010-07-16  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.

Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c	(revision 162255)
+++ gcc/fortran/trans-decl.c	(working copy)
@@ -1149,11 +1149,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)
     {
Index: gcc/testsuite/gfortran.dg/char_array_structure_constructor.f90
===================================================================
--- gcc/testsuite/gfortran.dg/char_array_structure_constructor.f90	(revision 162255)
+++ gcc/testsuite/gfortran.dg/char_array_structure_constructor.f90	(working copy)
@@ -1,4 +1,9 @@
 ! { dg-do run }
+! { dg-options "-O3 -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.
