diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 21c615483ed..4fd3ff03a0a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2009-12-11 Janus Weil + + PR fortran/42257 + * module.c (write_dt_extensions): Check for accessibility. + 2009-12-11 Daniel Franke PR fortran/40290 diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index d732b66da58..81a26130168 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -4670,6 +4670,10 @@ write_equiv (void) static void write_dt_extensions (gfc_symtree *st) { + if (!gfc_check_access (st->n.sym->attr.access, + st->n.sym->ns->default_access)) + return; + mio_lparen (); mio_pool_string (&st->n.sym->name); if (st->n.sym->module != NULL) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 92163b3200c..e2696adef0a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-12-11 Janus Weil + + PR fortran/42257 + * gfortran.dg/extends_9.f03: New test. + 2009-12-11 Jason Merrill PR c++/42219 diff --git a/gcc/testsuite/gfortran.dg/extends_9.f03 b/gcc/testsuite/gfortran.dg/extends_9.f03 new file mode 100644 index 00000000000..f59b97396b3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/extends_9.f03 @@ -0,0 +1,36 @@ +! { dg-do compile } +! +! PR42257: [OOP] Compiler segmentation fault due missing public statement +! +! Contributed by Oystein Olsen + +MODULE run_example_fortran03 + IMPLICIT NONE + PRIVATE + PUBLIC :: epoch + + INTEGER, PARAMETER :: I4B = SELECTED_INT_KIND(9) + INTEGER, PARAMETER :: DP = SELECTED_REAL_KIND(15,307) + + TYPE epoch + INTEGER(I4B) :: i = 2451545 + REAL(DP) :: f = 0.5_DP + END TYPE + + TYPE, EXTENDS(epoch) :: time + REAL(DP) :: t = 0.0_DP + END TYPE +END MODULE + + + USE run_example_fortran03 + IMPLICIT NONE + + CLASS(epoch), ALLOCATABLE :: e4 + + ALLOCATE(epoch::e4) + WRITE(*,*) e4%i, e4%f + +END + +! { dg-final { cleanup-modules "run_example_fortran03" } }