OSDN Git Service

2007-12-14 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 14 Dec 2007 15:14:29 +0000 (15:14 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 14 Dec 2007 15:14:29 +0000 (15:14 +0000)
        PR fortran/34438
        * resolve.c (resolve_symbol): Do not emit public-variable-
        of-private-derived-type error for non-module variables.

2007-12-14  Tobias Burnus  <burnus@net-b.de>

        PR fortran/34438
        * gfortran.dg/private_type_10.f90: New.

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

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/private_type_10.f90 [new file with mode: 0644]

index 40bbc53..200f38c 100644 (file)
@@ -1,5 +1,11 @@
 2007-12-14  Tobias Burnus  <burnus@net-b.de>
 
+       PR fortran/34438
+       * resolve.c (resolve_symbol): Do not emit public-variable-
+       of-private-derived-type error for non-module variables.
+
+2007-12-14  Tobias Burnus  <burnus@net-b.de>
+
        PR fortran/34398
        * expr.c (gfc_check_assign): Add range checks for assignments of BOZs.
        * resolve.c (resolve_ordinary_assign): Ditto.
index bee74e5..16543bc 100644 (file)
@@ -7848,10 +7848,11 @@ resolve_symbol (gfc_symbol *sym)
      See 4.4.1 (F95) and 4.5.1.1 (F2003); and related interpretation
      161 in 95-006r3.  */
   if (sym->ts.type == BT_DERIVED
+      && sym->ns->proc_name && sym->ns->proc_name->attr.flavor == FL_MODULE
+      && !sym->ts.derived->attr.use_assoc
       && gfc_check_access (sym->attr.access, sym->ns->default_access)
       && !gfc_check_access (sym->ts.derived->attr.access,
                            sym->ts.derived->ns->default_access)
-      && !sym->ts.derived->attr.use_assoc
       && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: PUBLIC %s '%s' at %L "
                         "of PRIVATE derived type '%s'",
                         (sym->attr.flavor == FL_PARAMETER) ? "parameter"
index d021240..faf00e1 100644 (file)
@@ -1,5 +1,10 @@
 2007-12-14  Tobias Burnus  <burnus@net-b.de>
 
+       PR fortran/34438
+       * gfortran.dg/private_type_10.f90: New.
+
+2007-12-14  Tobias Burnus  <burnus@net-b.de>
+
        PR fortran/34398
        * gfortran.dg/nan_4.f90: New.
 
diff --git a/gcc/testsuite/gfortran.dg/private_type_10.f90 b/gcc/testsuite/gfortran.dg/private_type_10.f90
new file mode 100644 (file)
index 0000000..561cfb7
--- /dev/null
@@ -0,0 +1,34 @@
+! { dg-do compile }
+! { dg-options "-std=f95" }
+!
+! PR fortran/34438
+!
+! Check that error is not issued for local, non-module
+! variables.
+!
+! Contributed by Sven Buijssen
+!
+module demo
+  implicit none
+  private
+  type myint
+    integer :: bar = 42
+  end type myint
+  public :: func
+contains
+  subroutine func()
+    type(myint) :: foo
+  end subroutine func
+end module demo
+
+module demo2
+  implicit none
+  private
+  type myint
+    integer :: bar = 42
+  end type myint
+  type(myint), save :: foo2 ! { dg-error "of PRIVATE derived type" }
+  public :: foo2
+end module demo2
+
+! { dg-final { cleanup-modules "demo" } }