[Bug fortran/31472] gfortran does not detect the illegal use of an access specification in a program, subroutine, or function
--- 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|-00-00 00:00:00 |2007-04-04 18:47:11 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31472
[Bug fortran/31472] gfortran does not detect the illegal use of an access specification in a program, subroutine, or function
--- 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
[Bug fortran/31472] gfortran does not detect the illegal use of an access specification in a program, subroutine, or function
--- 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
[Bug fortran/31472] gfortran does not detect the illegal use of an access specification in a program, subroutine, or function
--- 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
[Bug fortran/31472] gfortran does not detect the illegal use of an access specification in a program, subroutine, or function
--- 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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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
[Bug fortran/31472] gfortran does not detect the illegal use of an access specification in a program, subroutine, or function
--- 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