public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/54756] New: [OOP] Should reject CLASS, intent(out) in PURE procedures
@ 2012-09-29 18:19 burnus at gcc dot gnu.org
  2012-09-29 18:30 ` [Bug fortran/54756] " burnus at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-09-29 18:19 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 54756
           Summary: [OOP] Should reject CLASS, intent(out) in PURE
                    procedures
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
                CC: janus@gcc.gnu.org


Fortran 2008 no longer allows CLASS(),INTENT(OUT) in PURE procedures, gfortran
accepts those.

(Note: I think one should also reject them for Fortran 2003 as it seems to make
life easier easier for the FINAL implementation.)

See "TECHNICAL CORRIGENDUM 1" to Fortran 2008,
ftp://ftp.nag.co.uk/sc22wg5/N1901-N1950/N1902.pdf in "Subclause 1.6.2"
See also ftp://ftp.nag.co.uk/sc22wg5/N1851-N1900/N1875.txt for f08/0011 and
f08/0033.

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

Side note: That doesn't seem to affect impure (elemental).


type t
end type t
contains
pure subroutine foo(x)
  class(t), intent(out) :: x
end subroutine
end


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

* [Bug fortran/54756] [OOP] Should reject CLASS, intent(out) in PURE procedures
  2012-09-29 18:19 [Bug fortran/54756] New: [OOP] Should reject CLASS, intent(out) in PURE procedures burnus at gcc dot gnu.org
@ 2012-09-29 18:30 ` burnus at gcc dot gnu.org
  2012-09-29 18:33 ` burnus at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-09-29 18:30 UTC (permalink / raw)
  To: gcc-bugs


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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-09-29 18:30:38 UTC ---
The constraint belonging to that note (from the same corrigendum):

"C1278a  An INTENT(OUT) dummy argument of a pure procedure shall not be
polymorphic."


I think the rational is that a FINAL subroutine might be IMPURE and one could
thus invoke an IMPURE procedure through that back door - and it is not
detectable at compile time.

  * * *

Note that there is the related constraint:

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.


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

* [Bug fortran/54756] [OOP] Should reject CLASS, intent(out) in PURE procedures
  2012-09-29 18:19 [Bug fortran/54756] New: [OOP] Should reject CLASS, intent(out) in PURE procedures burnus at gcc dot gnu.org
  2012-09-29 18:30 ` [Bug fortran/54756] " burnus at gcc dot gnu.org
@ 2012-09-29 18:33 ` burnus at gcc dot gnu.org
  2012-11-06 10:10 ` [Bug fortran/54756] [OOP] [F08] " janus at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-09-29 18:33 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-09-29 18:33:32 UTC ---
As follow up - and side note: The following constraint ensures that there is a
compile-time error if one tries this with a nonpolymorphic entries. I am not
sure whether we currently handle it. (From Fortran 2008:)

"C1284  Any procedure referenced in a pure subprogram, including one referenced
via a defined operation, defined assignment, defined input/output, or
finalization, shall be pure."


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

* [Bug fortran/54756] [OOP] [F08] Should reject CLASS, intent(out) in PURE procedures
  2012-09-29 18:19 [Bug fortran/54756] New: [OOP] Should reject CLASS, intent(out) in PURE procedures burnus at gcc dot gnu.org
  2012-09-29 18:30 ` [Bug fortran/54756] " burnus at gcc dot gnu.org
  2012-09-29 18:33 ` burnus at gcc dot gnu.org
@ 2012-11-06 10:10 ` janus at gcc dot gnu.org
  2012-11-06 17:58 ` janus at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2012-11-06 10:10 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from janus at gcc dot gnu.org 2012-11-06 10:10:35 UTC ---
Related test case:


module moda
 implicit none
 type t
  real, pointer :: p => null()
 end type t
contains

 pure subroutine s1(a,b)
  type(t), intent(in) :: b
  class(t), allocatable, intent(out) :: a
   allocate(a,source=b)
 end subroutine

 pure subroutine s2(a,b)
  type(t), intent(in) :: b
  class(t), allocatable, intent(out) :: a
   allocate(t::a)
   a%p => b%p
 end subroutine

end module  



(slightly modified version of the one posted at
https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.fortran/Vj6a0tM5cvs)


Currently only the second case is rejected due to "Bad target in pointer
assignment in PURE procedure". Possibly the same should apply to the first one?

Anyway, both should be rejected due to the CLASS, INTENT(OUT) argument.


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

* [Bug fortran/54756] [OOP] [F08] Should reject CLASS, intent(out) in PURE procedures
  2012-09-29 18:19 [Bug fortran/54756] New: [OOP] Should reject CLASS, intent(out) in PURE procedures burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-11-06 10:10 ` [Bug fortran/54756] [OOP] [F08] " janus at gcc dot gnu.org
@ 2012-11-06 17:58 ` janus at gcc dot gnu.org
  2012-11-06 21:20 ` janus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2012-11-06 17:58 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from janus at gcc dot gnu.org 2012-11-06 17:58:36 UTC ---
Draft patch:

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c    (revision 193224)
+++ gcc/fortran/resolve.c    (working copy)
@@ -419,6 +419,16 @@ resolve_formal_arglist (gfc_symbol *proc)
                    &sym->declared_at);
         }
         }
+
+      /* F08:C1278a.  */
+      if (sym->ts.type == BT_CLASS && sym->attr.intent == INTENT_OUT
+          && (gfc_option.allow_std & GFC_STD_F2008) != 0)
+        {
+          gfc_error ("INTENT(OUT) argument '%s' of pure procedure '%s' "
+             "at %L may not be polymorphic in Fortran 2008",
+             sym->name, proc->name, &sym->declared_at);
+          continue;
+        }
     }

       if (proc->attr.implicit_pure)


Unfortunately, we cannot use 'gfc_notify_std' here (or we would need to add
something like GFC_STD_F2008_DEL, although this is not officially a 'deleted
feature', I guess).

So, we could just go with the above, or alternatively reject it regardless of
the chosen standard. This 'feature' probably counts as an 'oversight' which was
missed in F03 and added to F08 only in a corrigendum.


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

* [Bug fortran/54756] [OOP] [F08] Should reject CLASS, intent(out) in PURE procedures
  2012-09-29 18:19 [Bug fortran/54756] New: [OOP] Should reject CLASS, intent(out) in PURE procedures burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2012-11-06 17:58 ` janus at gcc dot gnu.org
@ 2012-11-06 21:20 ` janus at gcc dot gnu.org
  2014-12-21 12:19 ` dominiq at lps dot ens.fr
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2012-11-06 21:20 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #5 from janus at gcc dot gnu.org 2012-11-06 21:19:54 UTC ---
(In reply to comment #4)
> Draft patch:

In fact this causes a number of testsuite failures:

FAIL: gfortran.dg/class_array_3.f03  -O0  (test for excess errors)
FAIL: gfortran.dg/class_array_7.f03  -O0  (test for excess errors)
FAIL: gfortran.dg/class_dummy_4.f03  -O  (test for excess errors)
FAIL: gfortran.dg/typebound_operator_4.f03  -O  (test for excess errors)
FAIL: gfortran.dg/typebound_proc_16.f03  -O  (test for excess errors)

I think that all of the errors are correct (meaning the test cases are
invalid).


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

* [Bug fortran/54756] [OOP] [F08] Should reject CLASS, intent(out) in PURE procedures
  2012-09-29 18:19 [Bug fortran/54756] New: [OOP] Should reject CLASS, intent(out) in PURE procedures burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2012-11-06 21:20 ` janus at gcc dot gnu.org
@ 2014-12-21 12:19 ` dominiq at lps dot ens.fr
  2014-12-22 15:50 ` janus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-12-21 12:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54756

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-12-21
     Ever confirmed|0                           |1

--- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Patch at https://gcc.gnu.org/ml/fortran/2014-12/msg00098.html.


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

* [Bug fortran/54756] [OOP] [F08] Should reject CLASS, intent(out) in PURE procedures
  2012-09-29 18:19 [Bug fortran/54756] New: [OOP] Should reject CLASS, intent(out) in PURE procedures burnus at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2014-12-21 12:19 ` dominiq at lps dot ens.fr
@ 2014-12-22 15:50 ` janus at gcc dot gnu.org
  2014-12-22 15:56 ` janus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2014-12-22 15:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54756

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |janus at gcc dot gnu.org


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

* [Bug fortran/54756] [OOP] [F08] Should reject CLASS, intent(out) in PURE procedures
  2012-09-29 18:19 [Bug fortran/54756] New: [OOP] Should reject CLASS, intent(out) in PURE procedures burnus at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2014-12-22 15:50 ` janus at gcc dot gnu.org
@ 2014-12-22 15:56 ` janus at gcc dot gnu.org
  2014-12-27 22:41 ` janus at gcc dot gnu.org
  2014-12-27 22:43 ` janus at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2014-12-22 15:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54756

--- Comment #7 from janus at gcc dot gnu.org ---
Closely related: PR 59103.


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

* [Bug fortran/54756] [OOP] [F08] Should reject CLASS, intent(out) in PURE procedures
  2012-09-29 18:19 [Bug fortran/54756] New: [OOP] Should reject CLASS, intent(out) in PURE procedures burnus at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2014-12-22 15:56 ` janus at gcc dot gnu.org
@ 2014-12-27 22:41 ` janus at gcc dot gnu.org
  2014-12-27 22:43 ` janus at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2014-12-27 22:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54756

--- Comment #8 from janus at gcc dot gnu.org ---
Author: janus
Date: Sat Dec 27 22:40:21 2014
New Revision: 219085

URL: https://gcc.gnu.org/viewcvs?rev=219085&root=gcc&view=rev
Log:
2014-12-27  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/54756
    * resolve.c (resolve_formal_arglist): Reject polymorphic INTENT(OUT)
    arguments of pure procedures.

2014-12-27  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/54756
    * gfortran.dg/class_array_3.f03: Fixed invalid test case.
    * gfortran.dg/class_array_7.f03: Ditto.
    * gfortran.dg/class_dummy_4.f03: Ditto.
    * gfortran.dg/defined_assignment_3.f90: Ditto.
    * gfortran.dg/defined_assignment_5.f90: Ditto.
    * gfortran.dg/elemental_subroutine_10.f90: Ditto.
    * gfortran.dg/typebound_operator_4.f03: Ditto.
    * gfortran.dg/typebound_proc_16.f03: Ditto.
    * gfortran.dg/unlimited_polymorphic_19.f90: Ditto.
    * gfortran.dg/class_dummy_5.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/class_dummy_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/class_array_3.f03
    trunk/gcc/testsuite/gfortran.dg/class_array_7.f03
    trunk/gcc/testsuite/gfortran.dg/class_dummy_4.f03
    trunk/gcc/testsuite/gfortran.dg/defined_assignment_3.f90
    trunk/gcc/testsuite/gfortran.dg/defined_assignment_5.f90
    trunk/gcc/testsuite/gfortran.dg/elemental_subroutine_10.f90
    trunk/gcc/testsuite/gfortran.dg/typebound_operator_4.f03
    trunk/gcc/testsuite/gfortran.dg/typebound_proc_16.f03
    trunk/gcc/testsuite/gfortran.dg/unlimited_polymorphic_19.f90


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

* [Bug fortran/54756] [OOP] [F08] Should reject CLASS, intent(out) in PURE procedures
  2012-09-29 18:19 [Bug fortran/54756] New: [OOP] Should reject CLASS, intent(out) in PURE procedures burnus at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2014-12-27 22:41 ` janus at gcc dot gnu.org
@ 2014-12-27 22:43 ` janus at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2014-12-27 22:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54756

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from janus at gcc dot gnu.org ---
Fixed with r219085. Closing.


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

end of thread, other threads:[~2014-12-27 22:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-29 18:19 [Bug fortran/54756] New: [OOP] Should reject CLASS, intent(out) in PURE procedures burnus at gcc dot gnu.org
2012-09-29 18:30 ` [Bug fortran/54756] " burnus at gcc dot gnu.org
2012-09-29 18:33 ` burnus at gcc dot gnu.org
2012-11-06 10:10 ` [Bug fortran/54756] [OOP] [F08] " janus at gcc dot gnu.org
2012-11-06 17:58 ` janus at gcc dot gnu.org
2012-11-06 21:20 ` janus at gcc dot gnu.org
2014-12-21 12:19 ` dominiq at lps dot ens.fr
2014-12-22 15:50 ` janus at gcc dot gnu.org
2014-12-22 15:56 ` janus at gcc dot gnu.org
2014-12-27 22:41 ` janus at gcc dot gnu.org
2014-12-27 22:43 ` janus at gcc dot gnu.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).