public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/31472]  New: gfortran does not detect the illegal use of an access specification in a program, subroutine, or function
@ 2007-04-04 17:04 michael dot a dot richmond at nasa dot gov
  2007-04-04 17:47 ` [Bug fortran/31472] " burnus at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: michael dot a dot richmond at nasa dot gov @ 2007-04-04 17:04 UTC (permalink / raw)
  To: gcc-bugs

gfortran does not detect the illegal use of an access specification in a
program, subroutine, or function:

PROGRAM test211
PRIVATE i
END


-- 
           Summary: gfortran does not detect the illegal use of an access
                    specification in a program, subroutine, or function
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: michael dot a dot richmond at nasa dot gov


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


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

* [Bug fortran/31472] gfortran does not detect the illegal use of an access specification in a program, subroutine, or function
  2007-04-04 17:04 [Bug fortran/31472] New: gfortran does not detect the illegal use of an access specification in a program, subroutine, or function michael dot a dot richmond at nasa dot gov
@ 2007-04-04 17:47 ` burnus at gcc dot gnu dot org
  2007-04-05 13:13 ` burnus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-04-04 17:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2007-04-04 18:47 -------
Accepted. Thanks for the report.

We do check for this but only for the PRIVATE/PUBLIC attribute and not for the
PUBLIC/PRIVATE statement.

Patch:

Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c  (Revision 123494)
+++ gcc/fortran/decl.c  (Arbeitskopie)
@@ -3916,6 +3916,13 @@
   if (gfc_match ("private") != MATCH_YES)
     return MATCH_NO;

+  if (gfc_current_state () != COMP_MODULE)
+    {
+      gfc_error ("PRIVATE statement at %C is not allowed outside of "
+                "a module");
+      return MATCH_ERROR;
+    }
+
   if (gfc_current_state () == COMP_DERIVED)
     {
       if (gfc_match_eos () == MATCH_YES)
@@ -3946,6 +3953,13 @@
   if (gfc_match ("public") != MATCH_YES)
     return MATCH_NO;

+  if (gfc_current_state () != COMP_MODULE)
+    {
+      gfc_error ("PUBLIC statement at %C is not allowed outside of "
+                "a module");
+      return MATCH_ERROR;
+    }
+
   if (gfc_match_eos () == MATCH_YES)
     {
       *st = ST_PUBLIC;


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |burnus at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
           Keywords|                            |accepts-invalid
   Last reconfirmed|0000-00-00 00:00:00         |2007-04-04 18:47:11
               date|                            |


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


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

* [Bug fortran/31472] gfortran does not detect the illegal use of an access specification in a program, subroutine, or function
  2007-04-04 17:04 [Bug fortran/31472] New: gfortran does not detect the illegal use of an access specification in a program, subroutine, or function michael dot a dot richmond at nasa dot gov
  2007-04-04 17:47 ` [Bug fortran/31472] " burnus at gcc dot gnu dot org
@ 2007-04-05 13:13 ` burnus at gcc dot gnu dot org
  2007-04-11  8:44 ` burnus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-04-05 13:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2007-04-05 14:13 -------
The patch is wrong since the PRIVATE/PUBLIC statement is also allowed for type:

module foo
type t
  private
  integer, public :: foo
end type t
end module foo

Actually, currently gfortran also invalidly rejects the "integer, public ::
foo". See NOTE 4.41 in Section 4.5.3.6 of the Fortran 2003 standard for an
example.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid


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


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

* [Bug fortran/31472] gfortran does not detect the illegal use of an access specification in a program, subroutine, or function
  2007-04-04 17:04 [Bug fortran/31472] New: gfortran does not detect the illegal use of an access specification in a program, subroutine, or function michael dot a dot richmond at nasa dot gov
  2007-04-04 17:47 ` [Bug fortran/31472] " burnus at gcc dot gnu dot org
  2007-04-05 13:13 ` burnus at gcc dot gnu dot org
@ 2007-04-11  8:44 ` burnus at gcc dot gnu dot org
  2007-04-11 15:05 ` patchapp at dberlin dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-04-11  8:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from burnus at gcc dot gnu dot org  2007-04-11 09:44 -------
Fortran 95
----------
4.4.1 Derived-type definition
TYPE [ [ , access-spec ] :: ] type-name
   [ private-sequence-stmt ] ! no PUBLIC!

access spec & PRIVATE statement only in specification part of a module.

5.1 Type declaration statements / 5.1.2.2 Accessibility attribute
type-spec, access-spec :: ...

only in specification part of a module

5.2.3 Accessibility statements
access-spec [ [ :: ] access-id-list ]

only in specification part of a module.


Fortran 2003
------------

4.5.1 Derived-type definition
TYPE access-spec :: type-name
  PRIVATE ! statement; no PUBLIC
  declaration-type-spec [[,component-attr-spec-list]::]component-decl-list
with "component-attr-spec" is [...] or "access-spec".


Difference F95/F2003:
- components of a derived-type may have access-spec attributes
- Note that the PUBLIC statement and and the "PRIVATE [::] access-id-list"
statement (but not "PRIVATE" w/o access-id-list) is not allowed in a
derived-type declaration.


-- 


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


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

* [Bug fortran/31472] gfortran does not detect the illegal use of an access specification in a program, subroutine, or function
  2007-04-04 17:04 [Bug fortran/31472] New: gfortran does not detect the illegal use of an access specification in a program, subroutine, or function michael dot a dot richmond at nasa dot gov
                   ` (2 preceding siblings ...)
  2007-04-11  8:44 ` burnus at gcc dot gnu dot org
@ 2007-04-11 15:05 ` patchapp at dberlin dot org
  2007-04-12  8:46 ` burnus at gcc dot gnu dot org
  2007-04-12  8:58 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: patchapp at dberlin dot org @ 2007-04-11 15:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from patchapp at dberlin dot org  2007-04-11 16:05 -------
Subject: Bug number PR 31472

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-04/msg00558.html


-- 


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


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

* [Bug fortran/31472] gfortran does not detect the illegal use of an access specification in a program, subroutine, or function
  2007-04-04 17:04 [Bug fortran/31472] New: gfortran does not detect the illegal use of an access specification in a program, subroutine, or function michael dot a dot richmond at nasa dot gov
                   ` (3 preceding siblings ...)
  2007-04-11 15:05 ` patchapp at dberlin dot org
@ 2007-04-12  8:46 ` burnus at gcc dot gnu dot org
  2007-04-12  8:58 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-04-12  8:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from burnus at gcc dot gnu dot org  2007-04-12 09:46 -------
Subject: Bug 31472

Author: burnus
Date: Thu Apr 12 09:46:30 2007
New Revision: 123735

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123735
Log:
2007-04-12  Tobias Burnus  <burnus@net-b.de>

        PR fortran/31472
        * decl.c (match_attr_spec): Allow PRIVATE/PUBLIC
        attribute in type definitions.
        (gfc_match_private): Allow PRIVATE statement only
        in specification part of modules.
        (gfc_match_public): Ditto for PUBLIC.
        (gfc_match_derived_decl): Allow PRIVATE/PUBLIC attribute only in
        specificification part of modules.

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

        PR fortran/31472
        * gfortran.dg/access_spec_1.f90: New test.
        * gfortran.dg/access_spec_2.f90: New test.
        * gfortran.dg/non_module_public.f90: Match new error message.


Added:
    trunk/gcc/testsuite/gfortran.dg/access_spec_1.f90
    trunk/gcc/testsuite/gfortran.dg/access_spec_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/non_module_public.f90


-- 


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


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

* [Bug fortran/31472] gfortran does not detect the illegal use of an access specification in a program, subroutine, or function
  2007-04-04 17:04 [Bug fortran/31472] New: gfortran does not detect the illegal use of an access specification in a program, subroutine, or function michael dot a dot richmond at nasa dot gov
                   ` (4 preceding siblings ...)
  2007-04-12  8:46 ` burnus at gcc dot gnu dot org
@ 2007-04-12  8:58 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-04-12  8:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from burnus at gcc dot gnu dot org  2007-04-12 09:58 -------
Fixed in 4.3. No regression and rejects only valid Fortran 2003 code -> no
backporting to 4.2 -> Fixed.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

end of thread, other threads:[~2007-04-12  8:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-04 17:04 [Bug fortran/31472] New: gfortran does not detect the illegal use of an access specification in a program, subroutine, or function michael dot a dot richmond at nasa dot gov
2007-04-04 17:47 ` [Bug fortran/31472] " burnus at gcc dot gnu dot org
2007-04-05 13:13 ` burnus at gcc dot gnu dot org
2007-04-11  8:44 ` burnus at gcc dot gnu dot org
2007-04-11 15:05 ` patchapp at dberlin dot org
2007-04-12  8:46 ` burnus at gcc dot gnu dot org
2007-04-12  8:58 ` 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).