From 51d9479b52f25a120cfcd3245c3c08c08d36b154 Mon Sep 17 00:00:00 2001 From: jakub Date: Fri, 29 Aug 2008 18:50:30 +0000 Subject: [PATCH] * gfortran.h (gfc_use_list): Add where field. * module.c (use_locus): New static variable. (gfc_match_use): Set it. (gfc_use_module): Copy it to gfc_use_list's where field. * trans-decl.c (gfc_generate_module_vars): Call gfc_trans_use_stmts. (gfc_trans_use_stmts): Set backend locus before calling the debug hook. Allow non-VAR_DECLs to be created even for non-external module. Don't emit anything so far for renames from different modules. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139780 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 10 +++++++++ gcc/fortran/gfortran.h | 1 + gcc/fortran/module.c | 5 +++++ gcc/fortran/trans-decl.c | 56 +++++++++++++++++++++++++++++------------------- 4 files changed, 50 insertions(+), 22 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 671ef07..aee3339 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,15 @@ 2008-08-29 Jakub Jelinek + * gfortran.h (gfc_use_list): Add where field. + * module.c (use_locus): New static variable. + (gfc_match_use): Set it. + (gfc_use_module): Copy it to gfc_use_list's where field. + * trans-decl.c (gfc_generate_module_vars): Call gfc_trans_use_stmts. + (gfc_trans_use_stmts): Set backend locus before calling the debug + hook. Allow non-VAR_DECLs to be created even for non-external + module. Don't emit anything so far for renames from different + modules. + PR fortran/24790 * trans-decl.c (create_function_arglist): Set DECL_BY_REFERENCE on PARM_DECLs with pointer or reference type. diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 81e48b7..d644351 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -1153,6 +1153,7 @@ typedef struct gfc_use_list const char *module_name; int only_flag; struct gfc_use_rename *rename; + locus where; /* Next USE statement. */ struct gfc_use_list *next; } diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index b67b878..0f504ef 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -188,6 +188,8 @@ static int symbol_number; /* Counter for assigning symbol numbers */ /* Tells mio_expr_ref to make symbols for unused equivalence members. */ static bool in_load_equiv; +static locus use_locus; + /*****************************************************************/ @@ -546,6 +548,8 @@ gfc_match_use (void) } } + use_locus = gfc_current_locus; + m = gfc_match_name (module_name); if (m != MATCH_YES) return m; @@ -5142,6 +5146,7 @@ gfc_use_module (void) use_stmt->module_name = gfc_get_string (module_name); use_stmt->only_flag = only_flag; use_stmt->rename = gfc_rename_list; + use_stmt->where = use_locus; gfc_rename_list = NULL; use_stmt->next = gfc_current_ns->use_stmts; gfc_current_ns->use_stmts = use_stmt; diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index bf038f7..042821d 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -3151,26 +3151,7 @@ gfc_create_module_variable (gfc_symbol * sym) } } - -/* Generate all the required code for module variables. */ - -void -gfc_generate_module_vars (gfc_namespace * ns) -{ - module_namespace = ns; - cur_module = gfc_find_module (ns->proc_name->name); - - /* Check if the frontend left the namespace in a reasonable state. */ - gcc_assert (ns->proc_name && !ns->proc_name->tlink); - - /* Generate COMMON blocks. */ - gfc_trans_common (ns); - - /* Create decls for all the module variables. */ - gfc_traverse_ns (ns, gfc_create_module_variable); - - cur_module = NULL; -} +/* Emit debug information for USE statements. */ static void gfc_trans_use_stmts (gfc_namespace * ns) @@ -3190,6 +3171,7 @@ gfc_trans_use_stmts (gfc_namespace * ns) void_type_node); DECL_EXTERNAL (entry->namespace_decl) = 1; } + gfc_set_backend_locus (&use_stmt->where); if (!use_stmt->only_flag) (*debug_hooks->imported_module_or_decl) (entry->namespace_decl, NULL_TREE, @@ -3214,9 +3196,14 @@ gfc_trans_use_stmts (gfc_namespace * ns) rent->local_name[0] ? rent->local_name : rent->use_name); gcc_assert (st && st->n.sym->attr.use_assoc); - if (st->n.sym->backend_decl && DECL_P (st->n.sym->backend_decl)) + if (st->n.sym->backend_decl + && DECL_P (st->n.sym->backend_decl) + && st->n.sym->module + && strcmp (st->n.sym->module, use_stmt->module_name) == 0) { - gcc_assert (DECL_EXTERNAL (entry->namespace_decl)); + gcc_assert (DECL_EXTERNAL (entry->namespace_decl) + || (TREE_CODE (st->n.sym->backend_decl) + != VAR_DECL)); decl = copy_node (st->n.sym->backend_decl); DECL_CONTEXT (decl) = entry->namespace_decl; DECL_EXTERNAL (decl) = 1; @@ -3236,6 +3223,7 @@ gfc_trans_use_stmts (gfc_namespace * ns) local_name = get_identifier (rent->local_name); else local_name = NULL_TREE; + gfc_set_backend_locus (&rent->where); (*debug_hooks->imported_module_or_decl) (decl, local_name, ns->proc_name->backend_decl, !use_stmt->only_flag); @@ -3243,6 +3231,30 @@ gfc_trans_use_stmts (gfc_namespace * ns) } } + +/* Generate all the required code for module variables. */ + +void +gfc_generate_module_vars (gfc_namespace * ns) +{ + module_namespace = ns; + cur_module = gfc_find_module (ns->proc_name->name); + + /* Check if the frontend left the namespace in a reasonable state. */ + gcc_assert (ns->proc_name && !ns->proc_name->tlink); + + /* Generate COMMON blocks. */ + gfc_trans_common (ns); + + /* Create decls for all the module variables. */ + gfc_traverse_ns (ns, gfc_create_module_variable); + + cur_module = NULL; + + gfc_trans_use_stmts (ns); +} + + static void gfc_generate_contained_functions (gfc_namespace * parent) { -- 2.7.4