public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/31200]  New: wrong code generated with gfortran
@ 2007-03-16 11:27 jv244 at cam dot ac dot uk
  2007-03-16 14:07 ` [Bug fortran/31200] wrong code: procedure call with pointer-returning-function as argument burnus at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jv244 at cam dot ac dot uk @ 2007-03-16 11:27 UTC (permalink / raw)
  To: gcc-bugs

With a recent gfortran, the following compiles, but generates the wrong
results:

  REAL,TARGET :: x
  CALL s3(f(x))
CONTAINS
  FUNCTION f(a)
    REAL,POINTER :: f
    REAL,TARGET :: a
    f => a
  END FUNCTION
  SUBROUTINE s3(targ)
    REAL,TARGET :: targ
    REAL,POINTER :: p
    p => targ
    IF (.NOT. ASSOCIATED(p,x)) CALL ABORT()
  END SUBROUTINE
END


-- 
           Summary: wrong code generated with gfortran
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jv244 at cam dot ac dot uk


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


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

* [Bug fortran/31200] wrong code: procedure call with pointer-returning-function as argument
  2007-03-16 11:27 [Bug fortran/31200] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
@ 2007-03-16 14:07 ` burnus at gcc dot gnu dot org
  2007-03-16 17:10 ` pault at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-16 14:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2007-03-16 14:07 -------
The problem is:
  s3(f(x))
which is translated as
  {
    real4 D.1254;

    D.1254 = *f (&x);
    s3 (&D.1254);
  }
instead of
  D.1254 = f(&x)


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2007-03-16 14:07:34
               date|                            |
            Summary|wrong code generated with   |wrong code: procedure call
                   |gfortran                    |with pointer-returning-
                   |                            |function as argument


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


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

* [Bug fortran/31200] wrong code: procedure call with pointer-returning-function as argument
  2007-03-16 11:27 [Bug fortran/31200] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
  2007-03-16 14:07 ` [Bug fortran/31200] wrong code: procedure call with pointer-returning-function as argument burnus at gcc dot gnu dot org
@ 2007-03-16 17:10 ` pault at gcc dot gnu dot org
  2007-03-17 15:53 ` pault at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-03-16 17:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pault at gcc dot gnu dot org  2007-03-16 17:10 -------
(In reply to comment #1)

>     real4 D.1254;
>     D.1254 = *f (&x);
>     s3 (&D.1254);
>   }
> instead of
>   D.1254 = f(&x)

Funnily enough, I have been hit by the same problem in implementing procedure
pointers.  I will attempt to come to grips with it.

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-03-16 14:07:34         |2007-03-16 17:10:34
               date|                            |


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


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

* [Bug fortran/31200] wrong code: procedure call with pointer-returning-function as argument
  2007-03-16 11:27 [Bug fortran/31200] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
  2007-03-16 14:07 ` [Bug fortran/31200] wrong code: procedure call with pointer-returning-function as argument burnus at gcc dot gnu dot org
  2007-03-16 17:10 ` pault at gcc dot gnu dot org
@ 2007-03-17 15:53 ` pault at gcc dot gnu dot org
  2007-03-21 17:13 ` burnus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-03-17 15:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pault at gcc dot gnu dot org  2007-03-17 15:52 -------
This fixes the bug (and PR31209) and regtests OK.  Will package it up as a
submission tomorrow morning.

Index: gcc/fortran/trans-expr.c
===================================================================
*** gcc/fortran/trans-expr.c    (revision 122943)
--- gcc/fortran/trans-expr.c    (working copy)
*************** gfc_conv_function_call (gfc_se * se, gfc
*** 2074,2083 ****
--- 2074,2091 ----
                /* Argument list functions %VAL, %LOC and %REF are signalled
                   through arg->name.  */
                conv_arglist_function (&parmse, arg->expr, arg->name);
+             else if ((e->expr_type == EXPR_FUNCTION)
+                         && e->symtree->n.sym->attr.pointer
+                         && fsym && fsym->attr.target)
+               {
+                 gfc_conv_expr (&parmse, e);
+                 parmse.expr = build_fold_addr_expr (parmse.expr);
+               }
              else
                {
                  gfc_conv_expr_reference (&parmse, e);
                  if (fsym && fsym->attr.pointer
+                       && fsym->attr.flavor != FL_PROCEDURE
                        && e->expr_type != EXPR_NULL)
                    {
                      /* Scalar pointer dummy args require an extra level of

Paul


-- 


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


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

* [Bug fortran/31200] wrong code: procedure call with pointer-returning-function as argument
  2007-03-16 11:27 [Bug fortran/31200] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
                   ` (2 preceding siblings ...)
  2007-03-17 15:53 ` pault at gcc dot gnu dot org
@ 2007-03-21 17:13 ` burnus at gcc dot gnu dot org
  2007-03-24  8:10 ` patchapp at dberlin dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-21 17:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from burnus at gcc dot gnu dot org  2007-03-21 17:13 -------
*** Bug 31211 has been marked as a duplicate of this bug. ***


-- 


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


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

* [Bug fortran/31200] wrong code: procedure call with pointer-returning-function as argument
  2007-03-16 11:27 [Bug fortran/31200] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
                   ` (3 preceding siblings ...)
  2007-03-21 17:13 ` burnus at gcc dot gnu dot org
@ 2007-03-24  8:10 ` patchapp at dberlin dot org
  2007-03-24 12:31 ` pault at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: patchapp at dberlin dot org @ 2007-03-24  8:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from patchapp at dberlin dot org  2007-03-24 08:10 -------
Subject: Bug number PR31200

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-03/msg01595.html


-- 


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


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

* [Bug fortran/31200] wrong code: procedure call with pointer-returning-function as argument
  2007-03-16 11:27 [Bug fortran/31200] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
                   ` (4 preceding siblings ...)
  2007-03-24  8:10 ` patchapp at dberlin dot org
@ 2007-03-24 12:31 ` pault at gcc dot gnu dot org
  2007-03-24 13:58 ` pault at gcc dot gnu dot org
  2007-03-24 14:18 ` pault at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-03-24 12:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pault at gcc dot gnu dot org  2007-03-24 12:31 -------
Subject: Bug 31200

Author: pault
Date: Sat Mar 24 12:30:58 2007
New Revision: 123183

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123183
Log:
2007-03-24  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/31215
        * trans-expr.c (gfc_apply_interface_mapping_to_expr): Return
        int result that is non-zero if the expression is the function
        result.  Only the characteristics of the result expression
        can be used in a procedure interface, so simplify LEN in situ
        using its character length.

        PR fortran/31219
        PR fortran/31200
        * trans-expr.c (gfc_conv_function_call): Do not use
        gfc_conv_expr_reference for actual pointer function with formal
        target because a temporary is created that does not transfer
        the reference correctly.  Do not indirect formal pointer
        functions since it is the function reference that is needed.

2007-03-24  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/31219
        * gfortran.dg/pointer_function_actual_1.f90: New test.

        PR fortran/31200
        * gfortran.dg/pointer_function_actual_2.f90: New test.

        PR fortran/31215
        * gfortran.dg/result_in_spec_1.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pointer_function_actual_1.f90
    trunk/gcc/testsuite/gfortran.dg/pointer_function_actual_2.f90
    trunk/gcc/testsuite/gfortran.dg/result_in_spec_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/31200] wrong code: procedure call with pointer-returning-function as argument
  2007-03-16 11:27 [Bug fortran/31200] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
                   ` (5 preceding siblings ...)
  2007-03-24 12:31 ` pault at gcc dot gnu dot org
@ 2007-03-24 13:58 ` pault at gcc dot gnu dot org
  2007-03-24 14:18 ` pault at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-03-24 13:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pault at gcc dot gnu dot org  2007-03-24 13:58 -------
Fixed on trunk

Paul


-- 

pault at gcc dot gnu dot org changed:

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


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


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

* [Bug fortran/31200] wrong code: procedure call with pointer-returning-function as argument
  2007-03-16 11:27 [Bug fortran/31200] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
                   ` (6 preceding siblings ...)
  2007-03-24 13:58 ` pault at gcc dot gnu dot org
@ 2007-03-24 14:18 ` pault at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-03-24 14:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pault at gcc dot gnu dot org  2007-03-24 14:17 -------
Subject: Bug 31200

Author: pault
Date: Sat Mar 24 14:17:34 2007
New Revision: 123184

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123184
Log:
2007-03-24  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/31215
        * trans-expr.c (gfc_apply_interface_mapping_to_expr): Return
        int result that is non-zero if the expression is the function
        result.  Only the characteristics of the result expression
        can be used in a procedure interface, so simplify LEN in situ
        using its character length.

        PR fortran/31219
        PR fortran/31200
        * trans-expr.c (gfc_conv_function_call): Do not use
        gfc_conv_expr_reference for actual pointer function with formal
        target because a temporary is created that does not transfer
        the reference correctly.  Do not indirect formal pointer
        functions since it is the function reference that is needed.

2007-03-24  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/31219
        * gfortran.dg/pointer_function_actual_1.f90: New test.

        PR fortran/31200
        * gfortran.dg/pointer_function_actual_2.f90: New test.

        PR fortran/31215
        * gfortran.dg/result_in_spec_1.f90: New test.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/pointer_function_actual_1.f90


-- 


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


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

end of thread, other threads:[~2007-03-24 14:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-16 11:27 [Bug fortran/31200] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
2007-03-16 14:07 ` [Bug fortran/31200] wrong code: procedure call with pointer-returning-function as argument burnus at gcc dot gnu dot org
2007-03-16 17:10 ` pault at gcc dot gnu dot org
2007-03-17 15:53 ` pault at gcc dot gnu dot org
2007-03-21 17:13 ` burnus at gcc dot gnu dot org
2007-03-24  8:10 ` patchapp at dberlin dot org
2007-03-24 12:31 ` pault at gcc dot gnu dot org
2007-03-24 13:58 ` pault at gcc dot gnu dot org
2007-03-24 14:18 ` pault at gcc dot gnu dot 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).