Summary: | private/public confusion with a contained function | ||
---|---|---|---|
Product: | gcc | Reporter: | Norman S. Clerman <norm.clerman> |
Component: | fortran | Assignee: | Tobias Burnus <burnus> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | burnus, gcc-bugs |
Priority: | P3 | Keywords: | rejects-valid |
Version: | 4.4.0 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | 4.4.0 | Last reconfirmed: | 2008-11-11 14:35:00 |
Bug Depends on: | |||
Bug Blocks: | 32834 | ||
Attachments: |
bug5.tgz
bug5a.tgz |
Description
Norman S. Clerman
2008-11-09 14:52:01 UTC
Subject: bug 38065 (my bug5) Attached is the file you will need to reproduce the problem. Thanks again for your assistance. Norm Clerman Created attachment 16640 [details] bug5.tgz (In reply to comment #2) > Created an attachment (id=16640) [edit] > the shell script seems to have a few lines referring to your home, but it looks like most files are there. One missing file is: treetypeT.f90 please check that all files needed to reproduce the error are in the tarball, and that the procedure how to reproduce the error is clear enough. Subject: Re: bug5 Thank you for your prompt reply. I have reassembled all the files to reproduce the problem and they are in the attached file bug5a.tgz. My apologies for any problem this has caused. Norm Clerman ---- jv244 at cam dot ac dot uk <gcc-bugzilla@gcc.gnu.org> wrote: > > > ------- Comment #3 from jv244 at cam dot ac dot uk 2008-11-09 17:22 ------- > (In reply to comment #2) > > Created an attachment (id=16640) > --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16640&action=view) [edit] > > > > the shell script seems to have a few lines referring to your home, but it looks > like most files are there. > > One missing file is: > > treetypeT.f90 > > please check that all files needed to reproduce the error are in the tarball, > and that the procedure how to reproduce the error is clear enough. > > > -- > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38065 > > ------- You are receiving this mail because: ------- > You reported the bug, or are watching the reporter. Created attachment 16642 [details] bug5a.tgz reduced: MODULE M1 IMPLICIT NONE PRIVATE TYPE T1 INTEGER :: I1 END TYPE T1 PUBLIC :: S1 CONTAINS SUBROUTINE S1 CONTAINS TYPE(T1) FUNCTION F1() END FUNCTION F1 END SUBROUTINE S1 END MODULE M1 Subject: Re: private/public confusion with a contained function Hello, As best I can see, your reduction of the problem is not correct; in it subroutine S1 should be private, not public. Yours truly, Norm Clerman ---- jv244 at cam dot ac dot uk <gcc-bugzilla@gcc.gnu.org> wrote: > > > ------- Comment #6 from jv244 at cam dot ac dot uk 2008-11-11 13:28 ------- > reduced: > > MODULE M1 > IMPLICIT NONE > PRIVATE > TYPE T1 > INTEGER :: I1 > END TYPE T1 > PUBLIC :: S1 > CONTAINS > SUBROUTINE S1 > CONTAINS > TYPE(T1) FUNCTION F1() > END FUNCTION F1 > END SUBROUTINE S1 > END MODULE M1 > > > -- > > jv244 at cam dot ac dot uk changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > OtherBugsDependingO| |32834 > nThis| | > Status|UNCONFIRMED |NEW > Ever Confirmed|0 |1 > Keywords| |rejects-valid > Known to fail| |4.4.0 > Last reconfirmed|0000-00-00 00:00:00 |2008-11-11 13:28:28 > date| | > Summary|bug5 |private/public confusion > | |with a contained function > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38065 > > ------- You are receiving this mail because: ------- > You reported the bug, or are watching the reporter. (In reply to comment #7) > As best I can see, your reduction of the problem is not correct; in it > subroutine S1 should be private, not public. I don't think so. See your code, S1 ~ GeomMTF, which is public. The problem is the contained function F1 (your CreateLine), which incorrectly gets a 'public' attribute. Note that the same, incorrect error message is displayed for this testcase. (In reply to comment #6) > reduced: > > SUBROUTINE S1 > CONTAINS > TYPE(T1) FUNCTION F1() > END FUNCTION F1 > END SUBROUTINE S1 Error: PUBLIC function 'f1' at (1) cannot be of PRIVATE type 't1' gfortran has two bugs: a) F1 is an internal function and thus PUBLIC/PRIVATE does not apply b) If one makes F1 a (PUBLIC) *module* function, the program still would be a valid Fortran 2003 program (and an invalid Fortran 95 program). I still need to test whether the original program is fixed or not; there are quite a lot files ... Fix: +++ gcc/fortran/resolve.c (Arbeitskopie) @@ -10181,0 +10182 @@ resolve_fntype (gfc_namespace *ns) + && !sym->attr.contained @@ -10186,2 +10187,3 @@ resolve_fntype (gfc_namespace *ns) - gfc_error ("PUBLIC function '%s' at %L cannot be of PRIVATE type '%s'", - sym->name, &sym->declared_at, sym->ts.derived->name); + gfc_notify_std (GFC_STD_F2003, "Fortran 2003: PUBLIC function '%s' at " + "%L of PRIVATE type '%s'", sym->name, + &sym->declared_at, sym->ts.derived->name); Subject: Re: private/public confusion with a contained function Hello, Thank you for responding so promptly. Yes, I see what's going on now. It wasn't apparent to me that my function CreateLine was incorrectly acquiring the ''public' attribute. This explains why I could not reduce the problem as you have. Norm Clerman ---- jv244 at cam dot ac dot uk <gcc-bugzilla@gcc.gnu.org> wrote: > > > ------- Comment #8 from jv244 at cam dot ac dot uk 2008-11-11 14:14 ------- > (In reply to comment #7) > > As best I can see, your reduction of the problem is not correct; in it > > subroutine S1 should be private, not public. > > I don't think so. See your code, S1 ~ GeomMTF, which is public. The problem is > the contained function F1 (your CreateLine), which incorrectly gets a 'public' > attribute. Note that the same, incorrect error message is displayed for this > testcase. > > > -- > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38065 > > ------- You are receiving this mail because: ------- > You reported the bug, or are watching the reporter. Subject: Bug 38065 Author: burnus Date: Wed Nov 12 06:59:33 2008 New Revision: 141780 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141780 Log: 2008-11-12 Tobias Burnus <burnus@net-b.de> PR fortran/38065 * resolve.c (resolve_fntype): Fix private derived type checking. 2008-11-12 Tobias Burnus <burnus@net-b.de> PR fortran/38065 * gfortran.dg/private_type_11.f90: New test. * gfortran.dg/private_type_12.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/private_type_11.f90 trunk/gcc/testsuite/gfortran.dg/private_type_12.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/resolve.c trunk/gcc/testsuite/ChangeLog FIXED on the trunk (4.4.0). Subject: Bug 38065 Author: burnus Date: Wed Nov 12 18:38:08 2008 New Revision: 141798 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141798 Log: 2008-11-12 Tobias Burnus <burnus@net-b.de> PR fortran/38065 PR fortran/38094 * gfortran.dg/private_type_4.f90: Add -std=f95 option. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/private_type_4.f90 |