From: Paul Thomas Date: Fri, 17 Jul 2015 17:25:55 +0000 (+0000) Subject: re PR fortran/52846 ([F2008] Support submodules) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0240a6db7136efe5cbe4a47f905f30d80a43dfd1;p=gcc.git re PR fortran/52846 ([F2008] Support submodules) 2015-07-17 Paul Thomas PR fortran/52846 * decl.c (gfc_match_end): Pick out declared submodule name from the composite identifier. * gfortran.h : Add 'submodule_name' to gfc_use_list structure. * module.c (gfc_match_submodule): Define submodule_name and add static 'submodule_name'. (gfc_match_submodule): Build up submodule filenames, using '@' as a delimiter. Store the output filename in 'submodule_name'. Similarly, the submodule identifier is built using '.' as an identifier. (gfc_dump_module): If current state is COMP_SUBMODULE, write to file 'submodule_name', using SUBMODULE_EXTENSION. (gfc_use_module): Similarly, use the 'submodule_name' field in the gfc_use_list structure and SUBMODULE_EXTENSION to read the implicitly used submodule files. 2015-07-17 Paul Thomas PR fortran/52846 * lib/fortran-modules.exp (proc cleanup-submodules): New procedure. * gfortran.dg/submodule_1.f08: Change extension and clean up the submodule files. * gfortran.dg/submodule_2.f08: ditto * gfortran.dg/submodule_6.f08: ditto * gfortran.dg/submodule_7.f08: ditto * gfortran.dg/submodule_8.f08: New test * gfortran.dg/submodule_9.f08: New test From-SVN: r225953 --- diff --git a/gcc/testsuite/gfortran.dg/submodule_5.f08 b/gcc/testsuite/gfortran.dg/submodule_5.f08 new file mode 100644 index 00000000000..3141c4c4c99 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/submodule_5.f08 @@ -0,0 +1,51 @@ +! { dg-do compile } +! +! Checks that PRIVATE/PUBLIC not allowed in submodules. Also, IMPORT +! is not allowed in a module procedure interface body. +! +! Contributed by Paul Thomas +! +module foo_interface + implicit none + type foo + character(len=16), private :: byebye = "adieu, world! " + end type foo +end module + +module foo_interface_brother + use foo_interface + implicit none + interface + module subroutine array3(this, that) + import ! { dg-error "not permitted in a module procedure interface body" } + type(foo), intent(in), dimension(:) :: this + type(foo), intent(inOUT), allocatable, dimension(:) :: that + end subroutine + end interface +end module + +SUBMODULE (foo_interface) foo_interface_son + private ! { dg-error "PRIVATE statement" } + public ! { dg-error "PUBLIC statement" } + integer, public :: i ! { dg-error "PUBLIC attribute" } + integer, private :: j ! { dg-error "PRIVATE attribute" } + type :: bar + private ! { dg-error "PRIVATE statement" } + public ! { dg-error "PUBLIC statement" } + integer, private :: i ! { dg-error "PRIVATE attribute" } + integer, public :: j ! { dg-error "PUBLIC attribute" } + end type bar +contains +! +end submodule foo_interface_son + +SUBMODULE (foo_interface) foo_interface_daughter +! +contains + subroutine foobar (arg) + type(foo) :: arg + arg%byebye = "hello, world! " ! Access to private component is OK + end subroutine +end SUBMODULE foo_interface_daughter + +end diff --git a/gcc/testsuite/gfortran.dg/submodule_5.f90 b/gcc/testsuite/gfortran.dg/submodule_5.f90 deleted file mode 100644 index 3141c4c4c99..00000000000 --- a/gcc/testsuite/gfortran.dg/submodule_5.f90 +++ /dev/null @@ -1,51 +0,0 @@ -! { dg-do compile } -! -! Checks that PRIVATE/PUBLIC not allowed in submodules. Also, IMPORT -! is not allowed in a module procedure interface body. -! -! Contributed by Paul Thomas -! -module foo_interface - implicit none - type foo - character(len=16), private :: byebye = "adieu, world! " - end type foo -end module - -module foo_interface_brother - use foo_interface - implicit none - interface - module subroutine array3(this, that) - import ! { dg-error "not permitted in a module procedure interface body" } - type(foo), intent(in), dimension(:) :: this - type(foo), intent(inOUT), allocatable, dimension(:) :: that - end subroutine - end interface -end module - -SUBMODULE (foo_interface) foo_interface_son - private ! { dg-error "PRIVATE statement" } - public ! { dg-error "PUBLIC statement" } - integer, public :: i ! { dg-error "PUBLIC attribute" } - integer, private :: j ! { dg-error "PRIVATE attribute" } - type :: bar - private ! { dg-error "PRIVATE statement" } - public ! { dg-error "PUBLIC statement" } - integer, private :: i ! { dg-error "PRIVATE attribute" } - integer, public :: j ! { dg-error "PUBLIC attribute" } - end type bar -contains -! -end submodule foo_interface_son - -SUBMODULE (foo_interface) foo_interface_daughter -! -contains - subroutine foobar (arg) - type(foo) :: arg - arg%byebye = "hello, world! " ! Access to private component is OK - end subroutine -end SUBMODULE foo_interface_daughter - -end