2009-03-28 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 28 Mar 2009 16:55:40 +0000 (16:55 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 28 Mar 2009 16:55:40 +0000 (16:55 +0000)
PR fortran/38765
* parse.c (parse_derived): Do not break on finding pointer,
allocatable or private components.

2009-03-28  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/38765
* gfortran.dg/alloc_comp_assign_9.f90: New test.

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

gcc/fortran/ChangeLog
gcc/fortran/parse.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/alloc_comp_assign_9.f90 [new file with mode: 0644]

index 5373c9d..633775f 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-28  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/38765
+       * parse.c (parse_derived): Do not break on finding pointer,
+       allocatable or private components.
+
 2009-03-28  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/32626
index 3e86a43..1bf13e2 100644 (file)
@@ -1,5 +1,6 @@
 /* Main parser.
-   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+   2009
    Free Software Foundation, Inc.
    Contributed by Andy Vaught
 
@@ -1978,27 +1979,18 @@ endType:
       /* Look for allocatable components.  */
       if (c->attr.allocatable
          || (c->ts.type == BT_DERIVED && c->ts.derived->attr.alloc_comp))
-       {
-         sym->attr.alloc_comp = 1;
-         break;
-       }
+       sym->attr.alloc_comp = 1;
 
       /* Look for pointer components.  */
       if (c->attr.pointer
          || (c->ts.type == BT_DERIVED && c->ts.derived->attr.pointer_comp))
-       {
-         sym->attr.pointer_comp = 1;
-         break;
-       }
+       sym->attr.pointer_comp = 1;
 
       /* Look for private components.  */
       if (sym->component_access == ACCESS_PRIVATE
          || c->attr.access == ACCESS_PRIVATE
          || (c->ts.type == BT_DERIVED && c->ts.derived->attr.private_comp))
-       {
-         sym->attr.private_comp = 1;
-         break;
-       }
+       sym->attr.private_comp = 1;
     }
 
   if (!seen_component)
index bbc57f7..c5018d7 100644 (file)
@@ -1,3 +1,8 @@
+2009-03-28  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/38765
+       * gfortran.dg/alloc_comp_assign_9.f90: New test.
+
 2009-03-28  Daniel Kraft  <d@domob.eu>
 
        * gfortran.dg/trim_1.f90: New test.
diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_assign_9.f90 b/gcc/testsuite/gfortran.dg/alloc_comp_assign_9.f90
new file mode 100644 (file)
index 0000000..9051baf
--- /dev/null
@@ -0,0 +1,20 @@
+! { dg-do run }
+! Test the fix for PR39519, where the presence of the pointer
+! as the first component was preventing the second from passing
+! the "alloc_comp" attribute to the derived type.
+!
+! Contributed by Gilbert Scott <gilbert.scott@easynet.co.uk>
+!
+PROGRAM X
+  TYPE T
+    INTEGER, POINTER :: P
+    INTEGER, ALLOCATABLE :: A(:)
+  END TYPE T
+  TYPE(T) :: T1,T2
+  ALLOCATE ( T1%A(1) )
+  ALLOCATE ( T2%A(1) )
+  T1%A = 23
+  T2 = T1
+  T1%A = 42
+  if (T2%A(1) .NE. 23) CALL ABORT
+END PROGRAM X