summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/resolve.c3
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/der_pointer_2.f9020
4 files changed, 33 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index ca4a80d83e9..0863e275ef2 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2005-09-18 Erik Edelmann <erik.edelmann@iki.fi>
+
+ PR fortran/15975
+ * resolve.c (resolve_symbol): Don't assign default
+ initializer to pointers.
+
2005-09-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/16861
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index f9413336f53..e342a1e8d57 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -4328,7 +4328,8 @@ resolve_symbol (gfc_symbol * sym)
}
/* Assign default initializer. */
- if (sym->ts.type == BT_DERIVED && !(sym->value || whynot))
+ if (sym->ts.type == BT_DERIVED && !(sym->value || whynot)
+ && !sym->attr.pointer)
sym->value = gfc_default_initializer (&sym->ts);
break;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c60cb5587aa..4424bd8ec92 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2005-09-18 Erik Edelmann <erik.edelmann@iki.fi>
+
+ PR fortran/15975
+ * gfortran.dg/der_pointer_2.f90: New test.
+
2005-09-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/16861
diff --git a/gcc/testsuite/gfortran.dg/der_pointer_2.f90 b/gcc/testsuite/gfortran.dg/der_pointer_2.f90
new file mode 100644
index 00000000000..3749fc24ff8
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/der_pointer_2.f90
@@ -0,0 +1,20 @@
+! { dg-do compile }
+! PR 15975, PR 16606
+! Pointers to derived types with initialized components
+!
+! Contributed by Erik Edelmann <erik.edelmann@iki.fi>
+!
+SUBROUTINE N
+ TYPE T
+ INTEGER :: I = 99
+ END TYPE T
+ TYPE(T), POINTER :: P
+ TYPE(T), TARGET :: Q
+ P => Q
+ if (P%I.ne.99) call abort ()
+END SUBROUTINE N
+
+program test_pr15975
+ call n ()
+end program test_pr15975
+