OSDN Git Service

2007-09-17 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Sep 2007 10:12:06 +0000 (10:12 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Sep 2007 10:12:06 +0000 (10:12 +0000)
* resolve.c (resolve_fl_procedure): Allow private dummies
for Fortran 2003.

2007-09-17  Tobias Burnus  <burnus@net-b.de>

* gfortran.dg/interface_15.f90: Compile with -std=f95.
* gfortran.dg/private_type_1.f90: Ditto
* gfortran.dg/interface_18.f90: New.
* gfortran.dg/private_type_8.f90: New.

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

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/interface_15.f90
gcc/testsuite/gfortran.dg/interface_18.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/private_type_1.f90
gcc/testsuite/gfortran.dg/private_type_8.f90 [new file with mode: 0644]

index 9137da5..8d5bcfa 100644 (file)
@@ -1,3 +1,8 @@
+2007-09-17  Tobias Burnus  <burnus@net-b.de>
+
+       * resolve.c (resolve_fl_procedure): Allow private dummies
+       for Fortran 2003.
+
 2007-09-17  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        * trans-types.c (gfc_get_desc_dim_type): Do not to try
index 55d087f..a2444a3 100644 (file)
@@ -6885,12 +6885,13 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag)
              && arg->sym->ts.type == BT_DERIVED
              && !arg->sym->ts.derived->attr.use_assoc
              && !gfc_check_access (arg->sym->ts.derived->attr.access,
-                                   arg->sym->ts.derived->ns->default_access))
+                                   arg->sym->ts.derived->ns->default_access)
+             && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: '%s' is of a "
+                                "PRIVATE type and cannot be a dummy argument"
+                                " of '%s', which is PUBLIC at %L",
+                                arg->sym->name, sym->name, &sym->declared_at)
+                == FAILURE)
            {
-             gfc_error_now ("'%s' is of a PRIVATE type and cannot be "
-                            "a dummy argument of '%s', which is "
-                            "PUBLIC at %L", arg->sym->name, sym->name,
-                            &sym->declared_at);
              /* Stop this message from recurring.  */
              arg->sym->ts.derived->attr.access = ACCESS_PUBLIC;
              return FAILURE;
@@ -6907,12 +6908,14 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag)
                  && arg->sym->ts.type == BT_DERIVED
                  && !arg->sym->ts.derived->attr.use_assoc
                  && !gfc_check_access (arg->sym->ts.derived->attr.access,
-                                       arg->sym->ts.derived->ns->default_access))
+                                       arg->sym->ts.derived->ns->default_access)
+                 && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: Procedure "
+                                    "'%s' in PUBLIC interface '%s' at %L "
+                                    "takes dummy arguments of '%s' which is "
+                                    "PRIVATE", iface->sym->name, sym->name,
+                                    &iface->sym->declared_at,
+                                    gfc_typename (&arg->sym->ts)) == FAILURE)
                {
-                 gfc_error_now ("Procedure '%s' in PUBLIC interface '%s' at %L takes "
-                                "dummy arguments of '%s' which is PRIVATE",
-                                iface->sym->name, sym->name, &iface->sym->declared_at,
-                                gfc_typename(&arg->sym->ts));
                  /* Stop this message from recurring.  */
                  arg->sym->ts.derived->attr.access = ACCESS_PUBLIC;
                  return FAILURE;
@@ -6930,12 +6933,14 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag)
                  && arg->sym->ts.type == BT_DERIVED
                  && !arg->sym->ts.derived->attr.use_assoc
                  && !gfc_check_access (arg->sym->ts.derived->attr.access,
-                                       arg->sym->ts.derived->ns->default_access))
+                                       arg->sym->ts.derived->ns->default_access)
+                 && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: Procedure "
+                                    "'%s' in PUBLIC interface '%s' at %L "
+                                    "takes dummy arguments of '%s' which is "
+                                    "PRIVATE", iface->sym->name, sym->name,
+                                    &iface->sym->declared_at,
+                                    gfc_typename (&arg->sym->ts)) == FAILURE)
                {
-                 gfc_error_now ("Procedure '%s' in PUBLIC interface '%s' at %L takes "
-                                "dummy arguments of '%s' which is PRIVATE",
-                                iface->sym->name, sym->name, &iface->sym->declared_at,
-                                gfc_typename(&arg->sym->ts));
                  /* Stop this message from recurring.  */
                  arg->sym->ts.derived->attr.access = ACCESS_PUBLIC;
                  return FAILURE;
index 1c5209a..9428557 100644 (file)
@@ -1,3 +1,10 @@
+2007-09-17  Tobias Burnus  <burnus@net-b.de>
+
+       * gfortran.dg/interface_15.f90: Compile with -std=f95.
+       * gfortran.dg/private_type_1.f90: Ditto
+       * gfortran.dg/interface_18.f90: New.
+       * gfortran.dg/private_type_8.f90: New.
+
 2007-09-16  Paolo Carlini  <pcarlini@suse.de>
 
        PR c++/33124
index c9a3add..15f4298 100644 (file)
@@ -1,5 +1,5 @@
 ! { dg-do compile }
-! { dg-options "-c" }
+! { dg-options "-c -std=f95" }
 ! Testcase from PR fortran/25094
 ! Contributed by Joost VandeVondele <jv244@cam.ac.uk>
 
diff --git a/gcc/testsuite/gfortran.dg/interface_18.f90 b/gcc/testsuite/gfortran.dg/interface_18.f90
new file mode 100644 (file)
index 0000000..d0a5475
--- /dev/null
@@ -0,0 +1,21 @@
+! { dg-do compile }
+! { dg-options "-std=f2003" }
+!
+! Public procedures with private types for the dummies
+! is valid F2003, but invalid per Fortran 95, Sect. 5.2.3
+! See interface_15.f90 for the F95 test case.
+!
+   module mytype_application
+     implicit none
+     private
+     public :: mytype_test
+     type :: mytype_type
+       integer :: i=0
+     end type mytype_type
+   contains
+     subroutine mytype_test( mytype )
+       type(mytype_type), intent(in out) :: mytype
+     end subroutine mytype_test
+   end module mytype_application 
+
+! { dg-final { cleanup-modules "mytype_application" } }
index 34bc457..b6e9151 100644 (file)
@@ -1,4 +1,5 @@
 ! { dg-do compile }
+! { dg-options "-std=f95" }
 ! PR21986 - test based on original example.
 ! A public subroutine must not have private-type, dummy arguments.
 ! Contributed by Paul Thomas <pault@gcc.gnu.org>
diff --git a/gcc/testsuite/gfortran.dg/private_type_8.f90 b/gcc/testsuite/gfortran.dg/private_type_8.f90
new file mode 100644 (file)
index 0000000..df16096
--- /dev/null
@@ -0,0 +1,21 @@
+! { dg-do compile }
+! A public subroutine can have private-type, dummy arguments
+! in Fortran 2003 (but not in Fortran 95).
+! See private_type_1.f90 for the F95 test.
+!
+module modboom
+  implicit none
+  private
+  public:: dummysub
+  type:: intwrapper
+    integer n
+  end type intwrapper
+contains
+  subroutine dummysub(size, arg_array)
+   type(intwrapper) :: size
+   real, dimension(size%n) :: arg_array
+   real :: local_array(4)
+  end subroutine dummysub
+end module modboom
+
+! { dg-final { cleanup-modules "modboom" } }