[Bug fortran/33106] Access of components of public entities of private types wrongly allowed

2007-09-17 Thread burnus at gcc dot gnu dot org


--- Comment #9 from burnus at gcc dot gnu dot org  2007-09-17 15:55 ---
Subject: Bug 33106

Author: burnus
Date: Mon Sep 17 15:55:22 2007
New Revision: 128550

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=128550
Log:
2007-09-17  Tobias Burnus  [EMAIL PROTECTED]

PR fortran/33106
* resolve.c (resolve_symbol): Reject public variable of
private derived-types for Fortran 95.

2007-09-17  Tobias Burnus  [EMAIL PROTECTED]

PR fortran/33106
* gfortran.dg/private_type_9.f90: New.


Added:
trunk/gcc/testsuite/gfortran.dg/private_type_9.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/resolve.c
trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33106



[Bug fortran/33106] Access of components of public entities of private types wrongly allowed

2007-09-17 Thread burnus at gcc dot gnu dot org


--- Comment #10 from burnus at gcc dot gnu dot org  2007-09-17 15:56 ---
FIXED on the trunk (4.3.0).


-- 

burnus at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33106



[Bug fortran/33106] Access of components of public entities of private types wrongly allowed

2007-09-12 Thread burnus at gcc dot gnu dot org


--- Comment #6 from burnus at gcc dot gnu dot org  2007-09-12 16:36 ---
See also http://groups.google.com/group/comp.lang.fortran/msg/362cea390359d128


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33106



[Bug fortran/33106] Access of components of public entities of private types wrongly allowed

2007-09-12 Thread burnus at gcc dot gnu dot org


--- Comment #7 from burnus at gcc dot gnu dot org  2007-09-12 19:53 ---
Mine


-- 

burnus at gcc dot gnu dot org changed:

   What|Removed |Added

 AssignedTo|dfranke at gcc dot gnu dot  |burnus at gcc dot gnu dot
   |org |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33106



[Bug fortran/33106] Access of components of public entities of private types wrongly allowed

2007-09-12 Thread patchapp at dberlin dot org


--- Comment #8 from patchapp at dberlin dot org  2007-09-13 05:10 ---
Subject: Bug number PR33106

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-09/msg01118.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33106



[Bug fortran/33106] Access of components of public entities of private types wrongly allowed

2007-08-20 Thread burnus at gcc dot gnu dot org


--- Comment #5 from burnus at gcc dot gnu dot org  2007-08-20 06:21 ---
Richard Maine claims that also
  print *, code_gree
is valid. Thus there needs to be only a Fortran 95 check in module.

http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/6f683312292e2865/

Note: The following is an example which is valid Fortran 2003, invalid F95 and
rejected by gfortran ('a' is of a PRIVATE type and cannot be a dummy argument
of 'sub'):

module a
  implicit none
  type, private :: t
 integer :: i
  end type t
  type(t), parameter :: one = t(1)
  type(t), parameter :: two = t(2)
contains
  subroutine sub(a)
type(t) :: a
  end subroutine sub
end module a

use a, only: sub
end


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33106



[Bug fortran/33106] Access of components of public entities of private types wrongly allowed

2007-08-19 Thread dfranke at gcc dot gnu dot org


--- Comment #1 from dfranke at gcc dot gnu dot org  2007-08-19 17:05 ---
Confirmed and taken.


-- 

dfranke at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||dfranke at gcc dot gnu dot
   ||org
 AssignedTo|unassigned at gcc dot gnu   |dfranke at gcc dot gnu dot
   |dot org |org
 Status|UNCONFIRMED |ASSIGNED
 Ever Confirmed|0   |1
   Last reconfirmed|-00-00 00:00:00 |2007-08-19 17:05:50
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33106



[Bug fortran/33106] Access of components of public entities of private types wrongly allowed

2007-08-19 Thread dfranke at gcc dot gnu dot org


--- Comment #2 from dfranke at gcc dot gnu dot org  2007-08-19 17:40 ---
 The print statements are wrong(?); additionally for -std=f95 there 
 should be already an error for the compilation of the module.

Tobias,

does any other standard but F95 allow the usage of private derived type outside
their defining module? I'd think that an error is called for, regardless of the
version of the standard?!


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33106



[Bug fortran/33106] Access of components of public entities of private types wrongly allowed

2007-08-19 Thread burnus at gcc dot gnu dot org


--- Comment #3 from burnus at gcc dot gnu dot org  2007-08-19 17:50 ---
 does any other standard but F95 allow the usage of private derived type 
 outside their defining module? I'd think that an error is called for, 
 regardless of the version of the standard?!

Believing NAG the following is allowed in Fortran 2003 but not in Fortran 95:

module m
  type, private :: hidden_type; character(6) :: code; end type
  type(hidden_type), public, parameter :: code_green = hidden_type('green')
end module
use m, only: code_green, module_procedure_of_m
call module_procedure_of_m(code_green)

use m, only: hidden_type is definitely invalid. I would expect that also
print *, code_green and print *, code_green%code is invalid.

According to NAG is for Fortran 95 type(hidden_type), public already wrong.

I will try to find the relevant part in the Fortran 95 and 2003 standard (is
probably a bit hidden).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33106



[Bug fortran/33106] Access of components of public entities of private types wrongly allowed

2007-08-19 Thread burnus at gcc dot gnu dot org


--- Comment #4 from burnus at gcc dot gnu dot org  2007-08-19 18:54 ---
Fortran 2003:
---
4.5.1.1   Accessibility
Types that are defined in a module or accessible in that module by use
association have either the PUBLIC or PRIVATE attribute. Types for which an
access-spec is not explicitly specified in that module have the default
accessibility attribute for that module. The default accessibility attribute
for a module is PUBLIC unless it has been changed by a PRIVATE statement
(5.2.1). Only types that have the PUBLIC attribute in that module are available
to be accessed from that module by use association.
The accessibility of a type does not affect, and is not affected by, the
accessibility of its components and bindings.
If a type definition is private, then the type name, and thus the structure
constructor (4.5.9) for the type, are accessible only within the module
containing the definition.
---

Fortran 95:
---
4.4.1 Derived-type definition
[...]
The accessibility of a derived type may be declared explicitly by an
access-spec in its derived-type-stmt or in an access-stmt (5.2.3). The
accessibility is the default if it is not declared explicitly. If a type
definition is private, then the type name, the structure constructor (4.4.4)
for the type, any entity that is of the type, and any procedure that has a
dummy argument or function result that is of the type are accessible only
within the module containing the definition.
If a type definition contains a PRIVATE statement, the component names for the
type are accessible only within the module containing the definition, even if
the type itself is public (5.1.2.2). The component names and hence the internal
structure of the type are inaccessible in any scoping unit accessing the module
via a USE statement. Similarly, the structure constructor for such a type shall
be employed only within the defining module.
---

Fortran 95 prohibits: If a type definition is private, then [...] any entity
that is of the type, and any procedure that has a dummy argument or function
result that is of the type are accessible only within the module.

But Fortran 2003 only prohibits the type name and structure constructor. Thus
entities and procedures with dummy arguments of this type are allowed.

I would also argue that in Fortran 2003:
 print *, code_green%code
is allowed as The accessibility of a type does not affect, and is not affected
by, the accessibility of its components. Which agrees with NAG f95.

For
  print *, code_green
I am not fully sure, but one may argue that the type definition of a PRIVATE
type (name) is PRIVATE and thus also the type spec of code_green. This seems to
be the line NAG f95 follows.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33106