2005-12-29 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Dec 2005 06:11:21 +0000 (06:11 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Dec 2005 06:11:21 +0000 (06:11 +0000)
PR fortran/25532
* trans-types.c (copy_dt_decls_ifequal): Copy declarations for
components of derived type components by recursing into
gfc_get_derived_type.

2005-12-29  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/25532
*gfortran.dg/host_used_types_1.f90: Check that host associated
derived type components of derived types are properly declared
in contained procedures.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109138 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/trans-types.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/host_used_types_1.f90 [new file with mode: 0644]

index ae69322..73b11ea 100644 (file)
@@ -1,3 +1,10 @@
+2005-12-29  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/25532
+       * trans-types.c (copy_dt_decls_ifequal): Copy declarations for
+       components of derived type components by recursing into
+       gfc_get_derived_type.
+
 2005-12-28  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR fortran/25587
index 4e6b74e..b41940c 100644 (file)
@@ -1414,8 +1414,17 @@ copy_dt_decls_ifequal (gfc_symbol *from, gfc_symbol *to)
   to_cm = to->components;
   from_cm = from->components;
 
+  /* Copy the component declarations.  If a component is itself
+     a derived type, we need a copy of its component declarations.
+     This is done by recursing into gfc_get_derived_type and
+     ensures that the component's component declarations have
+     been built.  */
   for (; to_cm; to_cm = to_cm->next, from_cm = from_cm->next)
-    to_cm->backend_decl = from_cm->backend_decl;
+    {
+      to_cm->backend_decl = from_cm->backend_decl;
+      if (from_cm->ts.type == BT_DERIVED)
+       gfc_get_derived_type (to_cm->ts.derived);
+    }
 
   return 1;
 }
index d3fc200..c92d878 100644 (file)
@@ -1,3 +1,10 @@
+2005-12-29  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/25532
+       *gfortran.dg/host_used_types_1.f90: New test. Check that host
+       associated derived type components of derived types are
+       properly declared in contained procedures.
+
 2005-12-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR libgfortran/25139
diff --git a/gcc/testsuite/gfortran.dg/host_used_types_1.f90 b/gcc/testsuite/gfortran.dg/host_used_types_1.f90
new file mode 100644 (file)
index 0000000..89da583
--- /dev/null
@@ -0,0 +1,40 @@
+! { dg-do compile }
+! Tests the fix for PR25532, which was a regression introduced by
+! the fix for PR20244.
+!
+! Contributed by Erik Edelmann  <eedelman@gcc.gnu.org>
+module ModelParams
+        implicit none
+
+        type ReionizationParams
+             real   :: fraction
+        end type ReionizationParams
+
+        type CAMBparams
+             type(ReionizationParams) :: Reion
+         end type CAMBparams
+
+        type(CAMBparams) CP
+end module ModelParams
+
+
+module ThermoData
+    use ModelParams
+    implicit none
+
+contains
+
+    subroutine inithermo()
+        use ModelParams
+        if (0 < CP%Reion%fraction) then
+        end if
+    end subroutine inithermo
+
+! The bug expressed itself in this subroutine because the component type
+! information was not being copied from the parent namespace.
+    subroutine SetTimeSteps
+        if (0 < CP%Reion%fraction) then
+        end if
+    end subroutine SetTimeSteps
+
+end module ThermoData
\ No newline at end of file