This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/25818] Problem with handling optional and entry master arguments



------- Comment #7 from paul dot richard dot thomas at cea dot fr  2006-09-18 15:33 -------
I mixed up my types above; using a gfc_array_index_type seems to
cover every circumstance where missing arguments can be addressed
with legal code.

Regtests on FC5/Athlon.

Index: gcc/fortran/trans-decl.c
===================================================================
*** gcc/fortran/trans-decl.c    (revision 116268)
--- gcc/fortran/trans-decl.c    (working copy)
*************** build_entry_thunks (gfc_namespace * ns)
*** 1561,1566 ****
--- 1561,1568 ----
    tree args;
    tree string_args;
    tree tmp;
+   tree zero;
+   bool zero_flag;
    locus old_loc;

    /* This should always be a toplevel function.  */
*************** build_entry_thunks (gfc_namespace * ns)
*** 1580,1585 ****
--- 1582,1590 ----

        gfc_start_block (&body);

+       zero_flag = false;
+       zero = NULL_TREE;
+
        /* Pass extra parameter identifying this entry point.  */
        tmp = build_int_cst (gfc_array_index_type, el->id);
        args = tree_cons (NULL_TREE, tmp, NULL_TREE);
*************** build_entry_thunks (gfc_namespace * ns)
*** 1616,1621 ****
--- 1621,1627 ----
          if (thunk_formal)
            {
              /* Pass the argument.  */
+             /* TODO - missing optional arguments.  */
              DECL_ARTIFICIAL (thunk_formal->sym->backend_decl) = 1;
              args = tree_cons (NULL_TREE, thunk_formal->sym->backend_decl,
                                args);
*************** build_entry_thunks (gfc_namespace * ns)
*** 1627,1634 ****
            }
          else
            {
!             /* Pass NULL for a missing argument.  */
!             args = tree_cons (NULL_TREE, null_pointer_node, args);
              if (formal->sym->ts.type == BT_CHARACTER)
                {
                  tmp = build_int_cst (gfc_charlen_type_node, 0);
--- 1633,1651 ----
            }
          else
            {
!             /* Pass the address of a long zero for any argument that
!                is not used in this thunk.  */
!             if (!zero_flag)
!               {
!                 tmp = build_int_cst (intQI_type_node, 0);
!                 zero = gfc_create_var (intQI_type_node, NULL);
!                 gfc_add_modify_expr (&body, zero, tmp);
!                 zero = fold_convert (pvoid_type_node,
!                                      build_fold_addr_expr (zero));
!                 zero_flag = true;
!               }
!             args = tree_cons (NULL_TREE, zero, args);
!
              if (formal->sym->ts.type == BT_CHARACTER)
                {
                  tmp = build_int_cst (gfc_charlen_type_node, 0);


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]