public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/33106]  New: Access of components of public entities of private types wrongly allowed
@ 2007-08-18 12:01 burnus at gcc dot gnu dot org
  2007-08-19 17:06 ` [Bug fortran/33106] " dfranke at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-18 12:01 UTC (permalink / raw)
  To: gcc-bugs

Example found in the NAG f95 release notes.

The "print" statements are wrong(?); additionally for -std=f95 there should be
already an error for the compilation of the module.

NAG f95 prints:

Error: b.f90, line 14: Derived type HIDDEN_TYPE in io-list has PRIVATE
components
Interestingly, line 15 is accepted (omission or valid?).

With -std=f95, NAG f95 prints:

Error: b.f90, line 9: PARAMETER CODE_YELLOW exposes PRIVATE type HIDDEN_TYPE
           detected at M@<end-of-statement>
[...]
Which is in line with ifort:
fortcom: Error: b.f90, line 6: This entity cannot be PUBLIC since its derived
type is PRIVATE.   [CODE_GREEN]
  type(hidden_type), public, parameter :: code_green = hidden_type('green')


module m
  implicit none
  type, private :: hidden_type
    character(6) :: code
  end type
  type(hidden_type), public, parameter :: code_green = hidden_type('green')
  type(hidden_type), public, parameter :: code_yellow = hidden_type('yellow')
  type(hidden_type), public, parameter :: code_red = hidden_type('red')
end module m

program test
  use m, only: code_yellow
  implicit none
  print *, code_yellow
  print *, code_yellow%code
end program test


-- 
           Summary: Access of components of public entities of private types
                    wrongly allowed
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/33106] Access of components of public entities of private types wrongly allowed
  2007-08-18 12:01 [Bug fortran/33106] New: Access of components of public entities of private types wrongly allowed burnus at gcc dot gnu dot org
@ 2007-08-19 17:06 ` dfranke at gcc dot gnu dot org
  2007-08-19 17:41 ` dfranke at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2007-08-19 17:06 UTC (permalink / raw)
  To: gcc-bugs



------- 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|0000-00-00 00:00:00         |2007-08-19 17:05:50
               date|                            |


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/33106] Access of components of public entities of private types wrongly allowed
  2007-08-18 12:01 [Bug fortran/33106] New: Access of components of public entities of private types wrongly allowed burnus at gcc dot gnu dot org
  2007-08-19 17:06 ` [Bug fortran/33106] " dfranke at gcc dot gnu dot org
@ 2007-08-19 17:41 ` dfranke at gcc dot gnu dot org
  2007-08-19 17:50 ` burnus at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2007-08-19 17:41 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/33106] Access of components of public entities of private types wrongly allowed
  2007-08-18 12:01 [Bug fortran/33106] New: Access of components of public entities of private types wrongly allowed burnus at gcc dot gnu dot org
  2007-08-19 17:06 ` [Bug fortran/33106] " dfranke at gcc dot gnu dot org
  2007-08-19 17:41 ` dfranke at gcc dot gnu dot org
@ 2007-08-19 17:50 ` burnus at gcc dot gnu dot org
  2007-08-19 18:55 ` burnus at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-19 17:50 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/33106] Access of components of public entities of private types wrongly allowed
  2007-08-18 12:01 [Bug fortran/33106] New: Access of components of public entities of private types wrongly allowed burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-08-19 17:50 ` burnus at gcc dot gnu dot org
@ 2007-08-19 18:55 ` burnus at gcc dot gnu dot org
  2007-08-20  6:21 ` burnus at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-19 18:55 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/33106] Access of components of public entities of private types wrongly allowed
  2007-08-18 12:01 [Bug fortran/33106] New: Access of components of public entities of private types wrongly allowed burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-08-19 18:55 ` burnus at gcc dot gnu dot org
@ 2007-08-20  6:21 ` burnus at gcc dot gnu dot org
  2007-09-12 16:36 ` burnus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-20  6:21 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/33106] Access of components of public entities of private types wrongly allowed
  2007-08-18 12:01 [Bug fortran/33106] New: Access of components of public entities of private types wrongly allowed burnus at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2007-08-20  6:21 ` burnus at gcc dot gnu dot org
@ 2007-09-12 16:36 ` burnus at gcc dot gnu dot org
  2007-09-12 19:53 ` burnus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-12 16:36 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/33106] Access of components of public entities of private types wrongly allowed
  2007-08-18 12:01 [Bug fortran/33106] New: Access of components of public entities of private types wrongly allowed burnus at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2007-09-12 16:36 ` burnus at gcc dot gnu dot org
@ 2007-09-12 19:53 ` burnus at gcc dot gnu dot org
  2007-09-13  5:10 ` patchapp at dberlin dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-12 19:53 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/33106] Access of components of public entities of private types wrongly allowed
  2007-08-18 12:01 [Bug fortran/33106] New: Access of components of public entities of private types wrongly allowed burnus at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2007-09-12 19:53 ` burnus at gcc dot gnu dot org
@ 2007-09-13  5:10 ` patchapp at dberlin dot org
  2007-09-17 15:55 ` burnus at gcc dot gnu dot org
  2007-09-17 15:56 ` burnus at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: patchapp at dberlin dot org @ 2007-09-13  5:10 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/33106] Access of components of public entities of private types wrongly allowed
  2007-08-18 12:01 [Bug fortran/33106] New: Access of components of public entities of private types wrongly allowed burnus at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2007-09-13  5:10 ` patchapp at dberlin dot org
@ 2007-09-17 15:55 ` burnus at gcc dot gnu dot org
  2007-09-17 15:56 ` burnus at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-17 15:55 UTC (permalink / raw)
  To: gcc-bugs



------- 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=gcc&view=rev&rev=128550
Log:
2007-09-17  Tobias Burnus  <burnus@net-b.de>

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

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

        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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/33106] Access of components of public entities of private types wrongly allowed
  2007-08-18 12:01 [Bug fortran/33106] New: Access of components of public entities of private types wrongly allowed burnus at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2007-09-17 15:55 ` burnus at gcc dot gnu dot org
@ 2007-09-17 15:56 ` burnus at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-17 15:56 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-09-17 15:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-18 12:01 [Bug fortran/33106] New: Access of components of public entities of private types wrongly allowed burnus at gcc dot gnu dot org
2007-08-19 17:06 ` [Bug fortran/33106] " dfranke at gcc dot gnu dot org
2007-08-19 17:41 ` dfranke at gcc dot gnu dot org
2007-08-19 17:50 ` burnus at gcc dot gnu dot org
2007-08-19 18:55 ` burnus at gcc dot gnu dot org
2007-08-20  6:21 ` burnus at gcc dot gnu dot org
2007-09-12 16:36 ` burnus at gcc dot gnu dot org
2007-09-12 19:53 ` burnus at gcc dot gnu dot org
2007-09-13  5:10 ` patchapp at dberlin dot org
2007-09-17 15:55 ` burnus at gcc dot gnu dot org
2007-09-17 15:56 ` burnus at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).