OSDN Git Service

PR fortran/10220
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 4 Nov 2007 14:43:45 +0000 (14:43 +0000)
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 4 Nov 2007 14:43:45 +0000 (14:43 +0000)
* dwarf2out.c (add_calling_convention_attribute): Change
second argument. Set calling convention to DW_CC_program for
Fortran main program.
(gen_subprogram_die): Adjust to new prototype for
add_calling_convention_attribute.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@129882 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/dwarf2out.c

index 81c4241..300e929 100644 (file)
@@ -1,3 +1,12 @@
+2007-11-04  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/10220
+       * dwarf2out.c (add_calling_convention_attribute): Change
+       second argument. Set calling convention to DW_CC_program for
+       Fortran main program.
+       (gen_subprogram_die): Adjust to new prototype for
+       add_calling_convention_attribute.
+
 2007-11-03  Dorit Nuzman  <dorit@il.ibm.com>
 
        PR tree-optimization/33987
index a9510eb..f725a87 100644 (file)
@@ -11356,7 +11356,8 @@ add_name_and_src_coords_attributes (dw_die_ref die, tree decl)
          && TREE_PUBLIC (decl)
          && DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl)
          && !DECL_ABSTRACT (decl)
-         && !(TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl)))
+         && !(TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
+         && !is_fortran ())
        add_AT_string (die, DW_AT_MIPS_linkage_name,
                       IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
     }
@@ -11513,11 +11514,20 @@ add_type_attribute (dw_die_ref object_die, tree type, int decl_const,
 /* Given an object die, add the calling convention attribute for the
    function call type.  */
 static void
-add_calling_convention_attribute (dw_die_ref subr_die, tree type)
+add_calling_convention_attribute (dw_die_ref subr_die, tree decl)
 {
   enum dwarf_calling_convention value = DW_CC_normal;
 
-  value = targetm.dwarf_calling_convention (type);
+  value = targetm.dwarf_calling_convention (TREE_TYPE (decl));
+
+  /* DWARF doesn't provide a way to identify a program's source-level
+     entry point.  DW_AT_calling_convention attributes are only meant
+     to describe functions' calling conventions.  However, lacking a
+     better way to signal the Fortran main program, we use this for the
+     time being, following existing custom.  */
+  if (is_fortran ()
+      && !strcmp (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), "MAIN__"))
+    value = DW_CC_program;
 
   /* Only add the attribute if the backend requests it, and
      is not DW_CC_normal.  */
@@ -12370,7 +12380,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
 #endif
     }
   /* Add the calling convention attribute if requested.  */
-  add_calling_convention_attribute (subr_die, TREE_TYPE (decl));
+  add_calling_convention_attribute (subr_die, decl);
 
 }