From 9adfa70e26a8f0ef44b7b5cf8a3b691eee6c675c Mon Sep 17 00:00:00 2001 From: Francois-Xavier Coudert Date: Sun, 4 Nov 2007 14:43:45 +0000 Subject: [PATCH] re PR fortran/10220 (attribute DW_AT_calling_convention not correct for fortran) 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. From-SVN: r129882 --- gcc/ChangeLog | 9 +++++++++ gcc/dwarf2out.c | 18 ++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 81c4241a6cd0..300e929baa78 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2007-11-04 Francois-Xavier Coudert + + 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 PR tree-optimization/33987 diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index a9510ebba2ca..f725a877377a 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -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); }