diff options
author | Richard Guenther <rguenther@suse.de> | 2010-10-04 09:19:55 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2010-10-04 09:19:55 +0000 |
commit | e5b1675528722f816f06359daf618ab9e35f915a (patch) | |
tree | 3df5663a777d19ca33ed5257ae33e1e30b4836fd /gcc/fortran/f95-lang.c | |
parent | b453ace381f3c9b664916076ccd0bd1dbc9d5cc3 (diff) | |
download | gcc-e5b1675528722f816f06359daf618ab9e35f915a.zip gcc-e5b1675528722f816f06359daf618ab9e35f915a.tar.gz gcc-e5b1675528722f816f06359daf618ab9e35f915a.tar.bz2 |
f95-lang.c (current_translation_unit): New global variable.
2010-10-04 Richard Guenther <rguenther@suse.de>
* f95-lang.c (current_translation_unit): New global variable.
(gfc_create_decls): Build a translation-unit decl.
(pushdecl): In the global binding-level use the
translation-unit decl as DECL_CONTEXT.
* trans-decl.c (gfc_get_symbol_decl): Use DECL_FILE_SCOPE_P.
(build_function_decl): Likewise. Delay setting the assembler
name, leave setting of DECL_CONTEXT to pushdecl.
(trans_function_start): Use DECL_FILE_SCOPE_P.
(gfc_create_module_variable): Likewise. Remove questionable
asserts.
* trans.c (gfc_generate_module_code): Likewise.
From-SVN: r164928
Diffstat (limited to 'gcc/fortran/f95-lang.c')
-rw-r--r-- | gcc/fortran/f95-lang.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c index f222139..55280bd 100644 --- a/gcc/fortran/f95-lang.c +++ b/gcc/fortran/f95-lang.c @@ -172,6 +172,9 @@ tree *ridpointers = NULL; /* True means we've initialized exception handling. */ bool gfc_eh_initialized_p; +/* The current translation unit. */ +static GTY(()) tree current_translation_unit; + /* Prepare expr to be an argument of a TRUTH_NOT_EXPR, or validate its data type for an `if' or `while' statement or ?..: exp. @@ -229,6 +232,9 @@ gfc_create_decls (void) gfc_build_builtin_function_decls (); gfc_init_constants (); + + /* Build our translation-unit decl. */ + current_translation_unit = build_translation_unit_decl (NULL_TREE); } @@ -491,8 +497,10 @@ tree pushdecl (tree decl) { /* External objects aren't nested, other objects may be. */ - if ((DECL_EXTERNAL (decl)) || (decl == current_function_decl)) - DECL_CONTEXT (decl) = 0; + if (DECL_EXTERNAL (decl)) + DECL_CONTEXT (decl) = NULL_TREE; + else if (global_bindings_p ()) + DECL_CONTEXT (decl) = current_translation_unit; else DECL_CONTEXT (decl) = current_function_decl; |