public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/100218] New: Allow target of the pointer resulting from the evaluation of function-reference in a variable definition context
@ 2021-04-22 19:09 anlauf at gcc dot gnu.org
  2021-04-22 20:26 ` [Bug fortran/100218] " anlauf at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-04-22 19:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100218
           Summary: Allow target of the pointer resulting from the
                    evaluation of function-reference in a variable
                    definition context
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

While analyzing PR100154, Tobias pointed me to the following:

F2018:R902: function-reference shall have a data pointer result

A variable is either the data object denoted by designator or the target of the
pointer resulting from the evaluation of function-reference; this pointer shall
be associated.

He also gave an example in that other PR, for which I have a fix.  In my
interpretation the following code should thus also be valid and is accepted
by two other compilers I tested (Intel, Nvidia) and gives the right result.

program p
  implicit none
  integer, target :: z = 0
  call g (f ())
  print *, z
contains
  function f () result (r)
    integer, pointer :: r
    r => z
  end function f
  subroutine g (x)
    integer, intent(out) :: x
    x = 1
  end subroutine g
end program p


The following patch seems to help:

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 92a6700568d..696b9f1daac 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -6121,7 +6132,9 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool
alloc_obj,
     }
   if (!pointer && sym->attr.flavor != FL_VARIABLE
       && !(sym->attr.flavor == FL_PROCEDURE && sym == sym->result)
-      && !(sym->attr.flavor == FL_PROCEDURE && sym->attr.proc_pointer))
+      && !(sym->attr.flavor == FL_PROCEDURE && sym->attr.proc_pointer)
+      && !(sym->attr.flavor == FL_PROCEDURE
+          && sym->attr.function && sym->attr.pointer))
     {
       if (context)
        gfc_error ("%qs in variable definition context (%s) at %L is not"

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

* [Bug fortran/100218] Allow target of the pointer resulting from the evaluation of function-reference in a variable definition context
  2021-04-22 19:09 [Bug fortran/100218] New: Allow target of the pointer resulting from the evaluation of function-reference in a variable definition context anlauf at gcc dot gnu.org
@ 2021-04-22 20:26 ` anlauf at gcc dot gnu.org
  2021-04-24 11:24 ` dominiq at lps dot ens.fr
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-04-22 20:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2021-April/055976.html

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

* [Bug fortran/100218] Allow target of the pointer resulting from the evaluation of function-reference in a variable definition context
  2021-04-22 19:09 [Bug fortran/100218] New: Allow target of the pointer resulting from the evaluation of function-reference in a variable definition context anlauf at gcc dot gnu.org
  2021-04-22 20:26 ` [Bug fortran/100218] " anlauf at gcc dot gnu.org
@ 2021-04-24 11:24 ` dominiq at lps dot ens.fr
  2021-04-24 18:39 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2021-04-24 11:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-04-24

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

* [Bug fortran/100218] Allow target of the pointer resulting from the evaluation of function-reference in a variable definition context
  2021-04-22 19:09 [Bug fortran/100218] New: Allow target of the pointer resulting from the evaluation of function-reference in a variable definition context anlauf at gcc dot gnu.org
  2021-04-22 20:26 ` [Bug fortran/100218] " anlauf at gcc dot gnu.org
  2021-04-24 11:24 ` dominiq at lps dot ens.fr
@ 2021-04-24 18:39 ` cvs-commit at gcc dot gnu.org
  2021-04-24 19:48 ` anlauf at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-24 18:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:32c4d970ea3a9fc330d6aa8fd83f9dae0b9afc64

commit r12-106-g32c4d970ea3a9fc330d6aa8fd83f9dae0b9afc64
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sat Apr 24 20:38:06 2021 +0200

    Fortran - allow target of pointer from evaluation of function-reference

    Fortran allows the target of a pointer from the evaluation of a
    function-reference in a variable definition context (e.g. F2018:R902).

    gcc/fortran/ChangeLog:

            PR fortran/100218
            * expr.c (gfc_check_vardef_context): Extend check to allow pointer
            from a function reference.

    gcc/testsuite/ChangeLog:

            PR fortran/100218
            * gfortran.dg/ptr-func-4.f90: New test.

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

* [Bug fortran/100218] Allow target of the pointer resulting from the evaluation of function-reference in a variable definition context
  2021-04-22 19:09 [Bug fortran/100218] New: Allow target of the pointer resulting from the evaluation of function-reference in a variable definition context anlauf at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-04-24 18:39 ` cvs-commit at gcc dot gnu.org
@ 2021-04-24 19:48 ` anlauf at gcc dot gnu.org
  2021-04-27 21:13 ` cvs-commit at gcc dot gnu.org
  2021-04-27 21:23 ` anlauf at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-04-24 19:48 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

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

* [Bug fortran/100218] Allow target of the pointer resulting from the evaluation of function-reference in a variable definition context
  2021-04-22 19:09 [Bug fortran/100218] New: Allow target of the pointer resulting from the evaluation of function-reference in a variable definition context anlauf at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-04-24 19:48 ` anlauf at gcc dot gnu.org
@ 2021-04-27 21:13 ` cvs-commit at gcc dot gnu.org
  2021-04-27 21:23 ` anlauf at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-27 21:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:5aee8c2a33ae0d3f375ed0ca6e03718b284d2574

commit r11-8308-g5aee8c2a33ae0d3f375ed0ca6e03718b284d2574
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sat Apr 24 20:38:06 2021 +0200

    Fortran - allow target of pointer from evaluation of function-reference

    Fortran allows the target of a pointer from the evaluation of a
    function-reference in a variable definition context (e.g. F2018:R902).

    gcc/fortran/ChangeLog:

            PR fortran/100218
            * expr.c (gfc_check_vardef_context): Extend check to allow pointer
            from a function reference.

    gcc/testsuite/ChangeLog:

            PR fortran/100218
            * gfortran.dg/ptr-func-4.f90: New test.

    (cherry picked from commit 32c4d970ea3a9fc330d6aa8fd83f9dae0b9afc64)

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

* [Bug fortran/100218] Allow target of the pointer resulting from the evaluation of function-reference in a variable definition context
  2021-04-22 19:09 [Bug fortran/100218] New: Allow target of the pointer resulting from the evaluation of function-reference in a variable definition context anlauf at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-04-27 21:13 ` cvs-commit at gcc dot gnu.org
@ 2021-04-27 21:23 ` anlauf at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-04-27 21:23 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #4 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-12, and on 11-branch.  Closing.

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

end of thread, other threads:[~2021-04-27 21:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 19:09 [Bug fortran/100218] New: Allow target of the pointer resulting from the evaluation of function-reference in a variable definition context anlauf at gcc dot gnu.org
2021-04-22 20:26 ` [Bug fortran/100218] " anlauf at gcc dot gnu.org
2021-04-24 11:24 ` dominiq at lps dot ens.fr
2021-04-24 18:39 ` cvs-commit at gcc dot gnu.org
2021-04-24 19:48 ` anlauf at gcc dot gnu.org
2021-04-27 21:13 ` cvs-commit at gcc dot gnu.org
2021-04-27 21:23 ` anlauf 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).