From 34022d2b2e55c34e2a86af04d9bfe5548e71f63e Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Tue, 6 Dec 2016 17:13:31 +0000 Subject: [PATCH] re PR fortran/78659 ([F03] Spurious "requires DTIO" reported against namelist statement) 2016-12-06 Jerry DeLisle PR fortran/78659 * resolve.c (resolve_fl_namelist): Remove unneeded error. PR fortran/78659 * gfortran.dg/alloc_comp_constraint_1.f90: Update test. * gfortran.dg/alloc_comp_constraint_7.f90: New test. * gfortran.dg/namelist_34.f90: Update test. * gfortran.dg/namelist_63.f90: Update test. From-SVN: r243308 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/resolve.c | 10 +--------- gcc/testsuite/ChangeLog | 8 ++++++++ .../gfortran.dg/alloc_comp_constraint_1.f90 | 7 ++++--- .../gfortran.dg/alloc_comp_constraint_7.f90 | 19 +++++++++++++++++++ gcc/testsuite/gfortran.dg/namelist_34.f90 | 10 +++++----- gcc/testsuite/gfortran.dg/namelist_63.f90 | 7 ++++--- 7 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/alloc_comp_constraint_7.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index baef2d3ce47..14bf4f9619e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2016-12-06 Jerry DeLisle + + PR fortran/78659 + * resolve.c (resolve_fl_namelist): Remove unneeded error. + 2016-12-06 Andre Vehreschild PR fortran/78226 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 7bc9f5f5b6f..e4ea10f27bc 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -13900,15 +13900,7 @@ resolve_fl_namelist (gfc_symbol *sym) "or POINTER components", nl->sym->name, sym->name, &sym->declared_at)) return false; - - if (!dtio) - { - gfc_error ("NAMELIST object %qs in namelist %qs at %L has " - "ALLOCATABLE or POINTER components and thus requires " - "a defined input/output procedure", nl->sym->name, - sym->name, &sym->declared_at); - return false; - } + return true; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c7664e8b8f0..b293dcf9518 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2016-12-06 Jerry DeLisle + + PR fortran/78659 + * gfortran.dg/alloc_comp_constraint_1.f90: Update test. + * gfortran.dg/alloc_comp_constraint_7.f90: New test. + * gfortran.dg/namelist_34.f90: Update test. + * gfortran.dg/namelist_63.f90: Update test. + 2016-12-06 Robert Suchanek * gcc.target/mips/msa-builtins-err.c: New test. diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_constraint_1.f90 b/gcc/testsuite/gfortran.dg/alloc_comp_constraint_1.f90 index eb1b1058713..e1715256f4f 100644 --- a/gcc/testsuite/gfortran.dg/alloc_comp_constraint_1.f90 +++ b/gcc/testsuite/gfortran.dg/alloc_comp_constraint_1.f90 @@ -1,5 +1,6 @@ ! { dg-do compile } -! Check that we don't allow IO or NAMELISTs with types with allocatable +! { dg-options -std=f2003 } +! Check that we don't allow IO of NAMELISTs with types with allocatable ! components (PR 20541) program main @@ -13,8 +14,8 @@ program main type(foo) :: a type(bar) :: b - namelist /blah/ a ! { dg-error "has ALLOCATABLE or POINTER components and thus requires a defined input/output" } - + namelist /blah/ a ! This is allowed under F2003, but not F95 + ! The following require User Defined Derived Type I/O procedures. write (*, *) a ! { dg-error "cannot have ALLOCATABLE components" } read (*, *) b ! { dg-error "cannot have ALLOCATABLE components" } diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_constraint_7.f90 b/gcc/testsuite/gfortran.dg/alloc_comp_constraint_7.f90 new file mode 100644 index 00000000000..35b8e1f029f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/alloc_comp_constraint_7.f90 @@ -0,0 +1,19 @@ +! { dg-do compile } +! { dg-options -std=f95 } +! Check that we don't allow types with allocatable +program main + + type :: foo + integer :: k + integer, allocatable :: x(:) ! { dg-error "Fortran 2003: ALLOCATABLE" } + end type foo + + type :: bar + type(foo) :: x + end type bar + + type(foo) :: a + type(bar) :: b + namelist /blah/ a + +end program main diff --git a/gcc/testsuite/gfortran.dg/namelist_34.f90 b/gcc/testsuite/gfortran.dg/namelist_34.f90 index 94327710d38..be8f49f71e4 100644 --- a/gcc/testsuite/gfortran.dg/namelist_34.f90 +++ b/gcc/testsuite/gfortran.dg/namelist_34.f90 @@ -1,7 +1,7 @@ ! { dg-do compile } -! +! { dg-options -std=f95 } ! PR fortran/32905 - accepts types with ultimate POINTER components -! +! updated for PR78659 MODULE types type :: tp3 real :: x @@ -22,7 +22,7 @@ MODULE nml USE types type(tp1) :: t1 type(tp3) :: t3 - - namelist /a/ t1 ! { dg-error "has ALLOCATABLE or POINTER components and thus requires a defined input/output" } - namelist /b/ t3 ! { dg-error "has ALLOCATABLE or POINTER components and thus requires a defined input/output" } +! The following are allowed under f2003. + namelist /a/ t1 ! { dg-error "with ALLOCATABLE or POINTER components" } + namelist /b/ t3 ! { dg-error "with ALLOCATABLE or POINTER components" } END MODULE diff --git a/gcc/testsuite/gfortran.dg/namelist_63.f90 b/gcc/testsuite/gfortran.dg/namelist_63.f90 index 0210174031f..de27b82d52f 100644 --- a/gcc/testsuite/gfortran.dg/namelist_63.f90 +++ b/gcc/testsuite/gfortran.dg/namelist_63.f90 @@ -1,6 +1,6 @@ ! { dg-do compile } -! -! PR fortran/45530 +! { dg-options -std=f95 } +! PR fortran/45530, updated for PR78659 ! ! Contributed by david.sagan@gmail.com ! @@ -24,5 +24,6 @@ type region_struct end type type (c_struct) curve(10) -namelist / params / curve ! { dg-error "ALLOCATABLE or POINTER components and thus requires a defined input/output" } +! The following is allowed with f2003. +namelist / params / curve ! { dg-error "ALLOCATABLE or POINTER components" } end program -- 2.30.2