Bug 59103 - [OOP] Reject deallocate/intent(out) for polymorphic var in PURE procedures (IR F08/0033)
Summary: [OOP] Reject deallocate/intent(out) for polymorphic var in PURE procedures (I...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid, diagnostic
Depends on:
Blocks:
 
Reported: 2013-11-13 07:27 UTC by Tobias Burnus
Modified: 2014-12-27 22:45 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-12-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2013-11-13 07:27:22 UTC
(This PR is also motivated by https://groups.google.com/forum/#!topic/comp.lang.fortran/66iSG-kMZfo and https://groups.google.com/forum/#!topic/comp.lang.fortran/-NaOfgodyYc )


Interpretation request F08/0033, ftp://ftp.nag.co.uk/sc22wg5/N1851-N1900/N1875.txt, added additional restrictions to PURE as polymorphic variables might have IMPURE FINAL subroutines. Thus:

* An INTENT(OUT) argument of a pure procedure should
  not be allowed to be polymorphic
* deallocation of any polymorphic entity should be forbidden in
  a pure procedure.
* Any statement that might result in a deallocation that is
  forbidden should not be allowed in a pure procedure.


Or more formally:


EDITS to 10-007r1:

[24:10] 1.6.2p1 last sentence, "Any"->"Except as identified in this
        subclause, any".
{This edit is also present in interp F08/0032.}

[24:11+] 1.6.2 at end of subclause insert new paragraph:

         "Fortran 2003 permitted an INTENT(OUT) argument of a pure
          subroutine to be polymorphic.  This is not permitted by this
          part of ISO/IEC 1539.".

[312:23+] After C1278, insert new constraint:
  "C1278b An INTENT(OUT) dummy argument of a pure procedure shall not
          be polymorphic."

[313:4+] After C1284, insert new constraint and note:
  "C1284a A statement that might result in the deallocation of a
          polymorphic entity is not permitted in a pure procedure.

   Note 12.48x
   Apart from the DEALLOCATE statement, this includes intrinsic
   assignment if the variable has a polymorphic allocatable component
   at any level of component selection that does not involve a pointer
   component but which might involve one or more allocatable
   components."


Example:
  See interpretation request.
Comment 1 Tobias Burnus 2013-11-13 07:34:42 UTC
Actually, we also have to check whether finalizers are IMPURE for nonpolymorphic TYPE. I think we currently don't do so.
Comment 2 Dominique d'Humieres 2014-12-21 12:14:09 UTC
Isn't this PR related to the patch at https://gcc.gnu.org/ml/fortran/2014-12/msg00098.html?
Comment 3 janus 2014-12-21 13:52:29 UTC
(In reply to Tobias Burnus from comment #0)
> Interpretation request F08/0033,
> ftp://ftp.nag.co.uk/sc22wg5/N1851-N1900/N1875.txt, added additional
> restrictions to PURE as polymorphic variables might have IMPURE FINAL
> subroutines. Thus:
> 
> * An INTENT(OUT) argument of a pure procedure should
>   not be allowed to be polymorphic

Note: This part is already covered by PR 54756 (see also the link to the patch in comment #2).
Comment 4 janus 2014-12-21 13:54:01 UTC
(In reply to Dominique d'Humieres from comment #2)
> Isn't this PR related to the patch at
> https://gcc.gnu.org/ml/fortran/2014-12/msg00098.html?

Yes, but the patch does not cover all cases mentioned in comment 0.
Comment 5 janus 2014-12-27 22:45:41 UTC
(In reply to janus from comment #4)
> (In reply to Dominique d'Humieres from comment #2)
> > Isn't this PR related to the patch at
> > https://gcc.gnu.org/ml/fortran/2014-12/msg00098.html?
> 
> Yes, but the patch does not cover all cases mentioned in comment 0.

This patch has been committed as r219085.