Bug 42122 - -fdump-tree-original shows wrong static decl for functions with procptr argument
-fdump-tree-original shows wrong static decl for functions with procptr argument
Status: NEW
Product: gcc
Classification: Unclassified
Component: fortran
4.5.0
: P3 normal
: ---
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-11-20 16:07 UTC by janus
Modified: 2009-12-17 11:29 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-12-17 05:41:16


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description janus 2009-11-20 16:07:38 UTC
Follow-up to PR42072. Consider this simple program:


contains

  subroutine setpointer (p)
    procedure(), pointer :: p
  end subroutine

end


Compiling this with -fdump-tree-original shows:


setpointer (void (*<T62>) (void) * p)
{
  (void) 0;
}

MAIN__ ()
{
  static void setpointer (void (*<T62>) (void));

  (void) 0;
}


As one can see, the static declaration inside MAIN__ differs from the actual declaration of 'setpointer'.
Comment 1 Paul Thomas 2009-12-17 05:41:16 UTC
Confirmed.

This is where it comes from:
Index: gcc/fortran/trans-decl.c
===================================================================
*** gcc/fortran/trans-decl.c	(revision 155192)
--- gcc/fortran/trans-decl.c	(working copy)
*************** build_function_decl (gfc_symbol * sym)
*** 1644,1653 ****
    if (DECL_CONTEXT (fndecl) == NULL_TREE
        && !sym->attr.entry_master && !sym->attr.is_main_program)
      TREE_PUBLIC (fndecl) = 1;
! 
    /* TREE_STATIC means the function body is defined here.  */
    TREE_STATIC (fndecl) = 1;
! 
    /* Set attributes for PURE functions. A call to a PURE function in the
       Fortran 95 sense is both pure and without side effects in the C
       sense.  */
--- 1644,1653 ----
    if (DECL_CONTEXT (fndecl) == NULL_TREE
        && !sym->attr.entry_master && !sym->attr.is_main_program)
      TREE_PUBLIC (fndecl) = 1;
! #if 0
    /* TREE_STATIC means the function body is defined here.  */
    TREE_STATIC (fndecl) = 1;
! #endif
    /* Set attributes for PURE functions. A call to a PURE function in the
       Fortran 95 sense is both pure and without side effects in the C
       sense.  */

Paul
Comment 2 Richard Biener 2009-12-17 11:29:09 UTC
Hm?  The TREE_STATIC is ok, the bug is that the actual arguments are
different and maybe that inside the __MAIN BLOCK vars there shouldn't
be a function decl.