public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/97245] New: ASSOCIATE intrinsic does not recognize a ponter variable the second time it is used
@ 2020-09-29 16:23 aluaces at udc dot es
  2020-10-02 13:52 ` [Bug fortran/97245] " dominiq at lps dot ens.fr
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: aluaces at udc dot es @ 2020-09-29 16:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97245
           Summary: ASSOCIATE intrinsic does not recognize a ponter
                    variable the second time it is used
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: aluaces at udc dot es
  Target Milestone: ---

Created attachment 49289
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49289&action=edit
Minimal working example

In the attached example, the second call to associate() makes the compiler
error with "Error: ‘pointer’ argument of ‘associated’ intrinsic at (1) must be
a POINTER", although it is correct and the first use passes:

MODULE formulaciones
  IMPLICIT NONE

  ABSTRACT INTERFACE
     SUBROUTINE proc_void()
       IMPLICIT NONE
     END SUBROUTINE proc_void
  end INTERFACE

  PROCEDURE(proc_void), POINTER:: pADJSensib

CONTAINS
  subroutine calculo()
    implicit none
    LOGICAL step

    IF(associated(pADJSensib)) THEN
       CALL pADJSensib
    ENDIF

    IF(associated(pADJSensib)) THEN
       CALL pADJSensib
    END IF
  end subroutine calculo

END MODULE formulaciones

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

* [Bug fortran/97245] ASSOCIATE intrinsic does not recognize a ponter variable the second time it is used
  2020-09-29 16:23 [Bug fortran/97245] New: ASSOCIATE intrinsic does not recognize a ponter variable the second time it is used aluaces at udc dot es
@ 2020-10-02 13:52 ` dominiq at lps dot ens.fr
  2023-11-02 21:46 ` [Bug fortran/97245] ASSOCIATED intrinsic does not recognize a pointer " anlauf at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2020-10-02 13:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-10-02
     Ever confirmed|0                           |1
           Priority|P3                          |P4

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed since at least GCC7.

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

* [Bug fortran/97245] ASSOCIATED intrinsic does not recognize a pointer variable the second time it is used
  2020-09-29 16:23 [Bug fortran/97245] New: ASSOCIATE intrinsic does not recognize a ponter variable the second time it is used aluaces at udc dot es
  2020-10-02 13:52 ` [Bug fortran/97245] " dominiq at lps dot ens.fr
@ 2023-11-02 21:46 ` anlauf at gcc dot gnu.org
  2023-11-03 17:55 ` anlauf at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-11-02 21:46 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ASSOCIATE intrinsic does    |ASSOCIATED intrinsic does
                   |not recognize a ponter      |not recognize a pointer
                   |variable the second time it |variable the second time it
                   |is used                     |is used
           Keywords|                            |rejects-valid
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #2 from anlauf at gcc dot gnu.org ---
Interesting bug.

The code is accepted if the declaration

  PROCEDURE(proc_void), POINTER:: pADJSensib

is moved into the subroutine.  In the original form, -fdump-fortran-original
shows the following:

    code:
    IF _gfortran_associated[[((formulaciones:padjsensib) ((arg not-present)))]]
      CALL padjsensib ()
    ENDIF
    IF associated[((calculo:padjsensib))]
      CALL padjsensib ()
    ENDIF

This is weird.

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

* [Bug fortran/97245] ASSOCIATED intrinsic does not recognize a pointer variable the second time it is used
  2020-09-29 16:23 [Bug fortran/97245] New: ASSOCIATE intrinsic does not recognize a ponter variable the second time it is used aluaces at udc dot es
  2020-10-02 13:52 ` [Bug fortran/97245] " dominiq at lps dot ens.fr
  2023-11-02 21:46 ` [Bug fortran/97245] ASSOCIATED intrinsic does not recognize a pointer " anlauf at gcc dot gnu.org
@ 2023-11-03 17:55 ` anlauf at gcc dot gnu.org
  2023-11-03 18:57 ` anlauf at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-11-03 17:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from anlauf at gcc dot gnu.org ---
Potential fix:

diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc
index f848e52be4c..9e3571d3dbe 100644
--- a/gcc/fortran/match.cc
+++ b/gcc/fortran/match.cc
@@ -5064,6 +5064,7 @@ gfc_match_call (void)
      right association is made.  They are thrown out in resolution.)
      ...  */
   if (!sym->attr.generic
+       && !sym->attr.proc_pointer
        && !sym->attr.subroutine
        && !sym->attr.function)
     {

Regtests OK.

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

* [Bug fortran/97245] ASSOCIATED intrinsic does not recognize a pointer variable the second time it is used
  2020-09-29 16:23 [Bug fortran/97245] New: ASSOCIATE intrinsic does not recognize a ponter variable the second time it is used aluaces at udc dot es
                   ` (2 preceding siblings ...)
  2023-11-03 17:55 ` anlauf at gcc dot gnu.org
@ 2023-11-03 18:57 ` anlauf at gcc dot gnu.org
  2023-11-03 21:11 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-11-03 18:57 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #4 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2023-November/059892.html

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

* [Bug fortran/97245] ASSOCIATED intrinsic does not recognize a pointer variable the second time it is used
  2020-09-29 16:23 [Bug fortran/97245] New: ASSOCIATE intrinsic does not recognize a ponter variable the second time it is used aluaces at udc dot es
                   ` (3 preceding siblings ...)
  2023-11-03 18:57 ` anlauf at gcc dot gnu.org
@ 2023-11-03 21:11 ` cvs-commit at gcc dot gnu.org
  2023-11-04 14:50 ` cvs-commit at gcc dot gnu.org
  2023-11-04 14:53 ` anlauf at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-03 21:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 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:5340f48b7639fcc874f64aac214f9ef9ae43d43e

commit r14-5114-g5340f48b7639fcc874f64aac214f9ef9ae43d43e
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Fri Nov 3 19:41:54 2023 +0100

    Fortran: fix issue with multiple references of a procedure pointer
[PR97245]

    gcc/fortran/ChangeLog:

            PR fortran/97245
            * match.cc (gfc_match_call): If a procedure pointer has already
been
            resolved, do not create a new symbol in a procedure reference of
            the same name shadowing the first one if it is host-associated.

    gcc/testsuite/ChangeLog:

            PR fortran/97245
            * gfortran.dg/proc_ptr_53.f90: New test.

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

* [Bug fortran/97245] ASSOCIATED intrinsic does not recognize a pointer variable the second time it is used
  2020-09-29 16:23 [Bug fortran/97245] New: ASSOCIATE intrinsic does not recognize a ponter variable the second time it is used aluaces at udc dot es
                   ` (4 preceding siblings ...)
  2023-11-03 21:11 ` cvs-commit at gcc dot gnu.org
@ 2023-11-04 14:50 ` cvs-commit at gcc dot gnu.org
  2023-11-04 14:53 ` anlauf at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-04 14:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:e6ea74b68c5904446da6050751fde97d02549d1f

commit r13-8002-ge6ea74b68c5904446da6050751fde97d02549d1f
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Fri Nov 3 19:41:54 2023 +0100

    Fortran: fix issue with multiple references of a procedure pointer
[PR97245]

    gcc/fortran/ChangeLog:

            PR fortran/97245
            * match.cc (gfc_match_call): If a procedure pointer has already
been
            resolved, do not create a new symbol in a procedure reference of
            the same name shadowing the first one if it is host-associated.

    gcc/testsuite/ChangeLog:

            PR fortran/97245
            * gfortran.dg/proc_ptr_53.f90: New test.

    (cherry picked from commit 5340f48b7639fcc874f64aac214f9ef9ae43d43e)

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

* [Bug fortran/97245] ASSOCIATED intrinsic does not recognize a pointer variable the second time it is used
  2020-09-29 16:23 [Bug fortran/97245] New: ASSOCIATE intrinsic does not recognize a ponter variable the second time it is used aluaces at udc dot es
                   ` (5 preceding siblings ...)
  2023-11-04 14:50 ` cvs-commit at gcc dot gnu.org
@ 2023-11-04 14:53 ` anlauf at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-11-04 14:53 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.3
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #7 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-14, and backported to 13-branch.  Closing.

Thanks for the report!

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

end of thread, other threads:[~2023-11-04 14:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29 16:23 [Bug fortran/97245] New: ASSOCIATE intrinsic does not recognize a ponter variable the second time it is used aluaces at udc dot es
2020-10-02 13:52 ` [Bug fortran/97245] " dominiq at lps dot ens.fr
2023-11-02 21:46 ` [Bug fortran/97245] ASSOCIATED intrinsic does not recognize a pointer " anlauf at gcc dot gnu.org
2023-11-03 17:55 ` anlauf at gcc dot gnu.org
2023-11-03 18:57 ` anlauf at gcc dot gnu.org
2023-11-03 21:11 ` cvs-commit at gcc dot gnu.org
2023-11-04 14:50 ` cvs-commit at gcc dot gnu.org
2023-11-04 14:53 ` 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).