diff options
author | Mark Mitchell <mark@codesourcery.com> | 1999-09-24 08:03:42 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1999-09-24 08:03:42 +0000 |
commit | f39ee88428554ca0c01d784071ba4f794119a438 (patch) | |
tree | 62ab6c893fe00e5e5c37b56aba255d2c1c2dec48 | |
parent | d2cd3d9fca34e1097c737c0e875b64383beca6b0 (diff) | |
download | gcc-f39ee88428554ca0c01d784071ba4f794119a438.zip gcc-f39ee88428554ca0c01d784071ba4f794119a438.tar.gz gcc-f39ee88428554ca0c01d784071ba4f794119a438.tar.bz2 |
decl.c (pushdecl): Don't make local declarations of extern variables give the variable a...
* decl.c (pushdecl): Don't make local declarations of extern
variables give the variable a DECL_CONTEXT for the function.
(make_rtl_for_nonlocal_decl): Don't fuss with obstacks. Simplify.
Don't accidentally make RTL for local declarations.
(emit_local_var): Handle declarations with asm-specifiers here.
From-SVN: r29650
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/decl.c | 52 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.ext/asmspec1.C | 8 |
3 files changed, 48 insertions, 20 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 216ecd0..8caac2b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +1999-09-24 Mark Mitchell <mark@codesourcery.com> + + * decl.c (pushdecl): Don't make local declarations of extern + variables give the variable a DECL_CONTEXT for the function. + (make_rtl_for_nonlocal_decl): Don't fuss with obstacks. Simplify. + Don't accidentally make RTL for local declarations. + (emit_local_var): Handle declarations with asm-specifiers here. + 1999-09-23 Mark Mitchell <mark@codesourcery.com> * ir.texi: Improve documentation for TARGET_EXPRs. Discuss diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 70b8e11..d4d7be6 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3666,7 +3666,11 @@ pushdecl (x) if (current_function_decl && x != current_function_decl /* A local declaration for a function doesn't constitute nesting. */ - && (TREE_CODE (x) != FUNCTION_DECL || DECL_INITIAL (x)) + && !(TREE_CODE (x) == FUNCTION_DECL && !DECL_INITIAL (x)) + /* A local declaration for an `extern' variable is in the + scoped of the current namespace, not the current + function. */ + && !(TREE_CODE (x) == VAR_DECL && DECL_EXTERNAL (x)) /* Don't change DECL_CONTEXT of virtual methods. */ && (TREE_CODE (x) != FUNCTION_DECL || !DECL_VIRTUAL_P (x)) && !DECL_CONTEXT (x)) @@ -7369,25 +7373,27 @@ make_rtl_for_nonlocal_decl (decl, init, asmspec) type = TREE_TYPE (decl); toplev = toplevel_bindings_p (); - push_obstacks_nochange (); - if (TREE_STATIC (decl) - && TYPE_NEEDS_DESTRUCTOR (type) - && allocation_temporary_p ()) - end_temporary_allocation (); - if (TREE_CODE (decl) == VAR_DECL && DECL_VIRTUAL_P (decl)) + /* Handle non-variables up front. */ + if (TREE_CODE (decl) != VAR_DECL) + { + rest_of_decl_compilation (decl, asmspec, toplev, at_eof); + return; + } + + /* Set the DECL_ASSEMBLER_NAME for the variable. */ + if (asmspec) + DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec); + + if (DECL_VIRTUAL_P (decl)) make_decl_rtl (decl, NULL_PTR, toplev); - else if (TREE_CODE (decl) == VAR_DECL - && TREE_READONLY (decl) + else if (TREE_READONLY (decl) && DECL_INITIAL (decl) != NULL_TREE && DECL_INITIAL (decl) != error_mark_node && ! EMPTY_CONSTRUCTOR_P (DECL_INITIAL (decl))) { DECL_INITIAL (decl) = save_expr (DECL_INITIAL (decl)); - if (asmspec) - DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec); - if (! toplev && TREE_STATIC (decl) && ! TREE_SIDE_EFFECTS (decl) @@ -7415,12 +7421,10 @@ make_rtl_for_nonlocal_decl (decl, init, asmspec) } make_decl_rtl (decl, asmspec, toplev); } - else + else if (toplev) rest_of_decl_compilation (decl, asmspec, toplev, at_eof); } - else if (TREE_CODE (decl) == VAR_DECL - && DECL_LANG_SPECIFIC (decl) - && DECL_IN_AGGR_P (decl)) + else if (DECL_LANG_SPECIFIC (decl) && DECL_IN_AGGR_P (decl)) { my_friendly_assert (TREE_STATIC (decl), 19990828); @@ -7439,10 +7443,9 @@ make_rtl_for_nonlocal_decl (decl, init, asmspec) else rest_of_decl_compilation (decl, asmspec, toplev, at_eof); } - else + else if (TREE_CODE (CP_DECL_CONTEXT (decl)) == NAMESPACE_DECL + || (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))) rest_of_decl_compilation (decl, asmspec, toplev, at_eof); - - pop_obstacks (); } /* The old ARM scoping rules injected variables declared in the @@ -7587,7 +7590,16 @@ emit_local_var (decl) my_friendly_assert (TREE_CODE (decl) == RESULT_DECL, 19990828); else - expand_decl (decl); + { + if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl)) + /* The user must have specified an assembler name for this + variable. Set that up now. */ + rest_of_decl_compilation + (decl, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), + /*top_level=*/0, /*at_end=*/0); + else + expand_decl (decl); + } /* Actually do the initialization. */ expand_start_target_temps (); diff --git a/gcc/testsuite/g++.old-deja/g++.ext/asmspec1.C b/gcc/testsuite/g++.old-deja/g++.ext/asmspec1.C new file mode 100644 index 0000000..d86d30a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/asmspec1.C @@ -0,0 +1,8 @@ +// Build don't link: +// Skip if not target: i?86-*-* +// Origin: Anthony Green <green@cygnus.com> + +void foo () +{ + register const char *h asm("%esi") = "hey"; +} |