From cf74fb8675044d976ab9bcf852756b471e6b0012 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 10 Mar 2000 19:23:18 -0500 Subject: [PATCH] decl.c (push_throw_library_fn): Take the FUNCTION_TYPE. * decl.c (push_throw_library_fn): Take the FUNCTION_TYPE. * except.c (expand_end_eh_spec): Add the return type. * rtti.c (throw_bad_cast): Add the parmtypes. (throw_bad_typeid): Likewise. * semantics.c (expand_stmt): Only leave out rtl for unused artificials, and set DECL_IGNORED_P on them as well. * decl.c (wrapup_globals_for_namespace): Likewise. * decl.c (maybe_commonize_var): Skip all artificial decls. * pt.c (tsubst_decl): Don't copy TREE_ASM_WRITTEN. From-SVN: r32475 --- gcc/cp/ChangeLog | 16 ++++++++++++++++ gcc/cp/decl.c | 21 ++++++++++++--------- gcc/cp/except.c | 1 + gcc/cp/pt.c | 5 ----- gcc/cp/rtti.c | 11 +++++++---- gcc/cp/semantics.c | 16 ++++++++++------ 6 files changed, 46 insertions(+), 24 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d518d7395b0..052f2935867 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,19 @@ +2000-03-10 Jason Merrill + + * decl.c (push_throw_library_fn): Take the FUNCTION_TYPE. + * except.c (expand_end_eh_spec): Add the return type. + * rtti.c (throw_bad_cast): Add the parmtypes. + (throw_bad_typeid): Likewise. + + * semantics.c (expand_stmt): Only leave out rtl for unused + artificials, and set DECL_IGNORED_P on them as well. + * decl.c (wrapup_globals_for_namespace): Likewise. + +2000-03-09 Nathan Sidwell + + * decl.c (maybe_commonize_var): Skip all artificial decls. + * pt.c (tsubst_decl): Don't copy TREE_ASM_WRITTEN. + 2000-03-10 Jason Merrill * lang-options.h, decl2.c: Add -fno-enforce-eh-specs. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 53cbb745116..83747293c0c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1789,9 +1789,12 @@ wrapup_globals_for_namespace (namespace, data) /* Pretend we've output an unused static variable. This ensures that the toplevel __FUNCTION__ etc won't be emitted, unless needed. */ - if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) - && !TREE_USED (decl)) - TREE_ASM_WRITTEN (decl) = 1; + if (TREE_CODE (decl) == VAR_DECL && DECL_ARTIFICIAL (decl) + && !TREE_PUBLIC (decl) && !TREE_USED (decl)) + { + TREE_ASM_WRITTEN (decl) = 1; + DECL_IGNORED_P (decl) = 1; + } vec[len - i - 1] = decl; } @@ -6578,14 +6581,14 @@ push_void_library_fn (name, parmtypes) return push_library_fn (name, type); } -/* Like push_void_library_fn, but also note that this function throws +/* Like push_library_fn, but also note that this function throws and does not return. Used for __throw_foo and the like. */ tree -push_throw_library_fn (name, parmtypes) - tree name, parmtypes; +push_throw_library_fn (name, type) + tree name, type; { - tree fn = push_void_library_fn (name, parmtypes); + tree fn = push_library_fn (name, type); TREE_THIS_VOLATILE (fn) = 1; TREE_NOTHROW (fn) = 0; return fn; @@ -7272,7 +7275,7 @@ maybe_commonize_var (decl) linkage. */ if (TREE_STATIC (decl) /* Don't mess with __FUNCTION__. */ - && ! TREE_ASM_WRITTEN (decl) + && ! DECL_ARTIFICIAL (decl) && current_function_decl && DECL_CONTEXT (decl) == current_function_decl && (DECL_THIS_INLINE (current_function_decl) @@ -7307,7 +7310,7 @@ maybe_commonize_var (decl) if (TREE_PUBLIC (decl)) DECL_ASSEMBLER_NAME (decl) = build_static_name (current_function_decl, DECL_NAME (decl)); - else if (! DECL_ARTIFICIAL (decl)) + else { cp_warning_at ("sorry: semantics of inline function static data `%#D' are wrong (you'll wind up with multiple copies)", decl); cp_warning_at (" you can work around this by removing the initializer", decl); diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 3a54ea82d42..c6cdaa2a2da 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -719,6 +719,7 @@ expand_end_eh_spec (raises, try_block) tmp = tree_cons (NULL_TREE, integer_type_node, tree_cons (NULL_TREE, TREE_TYPE (decl), void_list_node)); + tmp = build_function_type (void_type_node, tmp); fn = push_throw_library_fn (fn, tmp); } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b9d46278656..28d08a5a513 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5924,11 +5924,6 @@ tsubst_decl (t, args, type, in_decl) TREE_TYPE (r) = TREE_TYPE (DECL_INITIAL (r)); } - /* If the template variable was marked TREE_ASM_WRITTEN, that - means we don't need to write out any of the instantiations - either. (__FUNCTION__ and its ilk are marked thusly.) */ - TREE_ASM_WRITTEN (r) = TREE_ASM_WRITTEN (t); - /* Even if the original location is out of scope, the newly substituted one is not. */ if (TREE_CODE (r) == VAR_DECL) diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 15e46174fcf..fa5f85c1e71 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -175,7 +175,8 @@ throw_bad_cast () if (IDENTIFIER_GLOBAL_VALUE (fn)) fn = IDENTIFIER_GLOBAL_VALUE (fn); else - fn = push_throw_library_fn (fn, ptr_type_node); + fn = push_throw_library_fn (fn, build_function_type (ptr_type_node, + void_list_node)); return build_call (fn, NULL_TREE); } @@ -187,9 +188,11 @@ throw_bad_typeid () if (IDENTIFIER_GLOBAL_VALUE (fn)) fn = IDENTIFIER_GLOBAL_VALUE (fn); else - fn = push_throw_library_fn (fn, build_reference_type - (build_qualified_type - (type_info_type_node, TYPE_QUAL_CONST))); + { + tree t = build_qualified_type (type_info_type_node, TYPE_QUAL_CONST); + t = build_function_type (build_reference_type (t), void_list_node); + fn = push_throw_library_fn (fn, t); + } return build_call (fn, NULL_TREE); } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 3402d3bb5f4..3071f1f0d20 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2392,12 +2392,16 @@ expand_stmt (t) expand_anon_union_decl (decl, NULL_TREE, DECL_ANON_UNION_ELEMS (decl)); } - else if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) - && TREE_USED (decl)) - /* Do not emit unused decls. This is not just an - optimization. We really do not want to emit - __PRETTY_FUNCTION__ etc, if they're never used. */ - make_rtl_for_local_static (decl); + else if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)) + { + if (DECL_ARTIFICIAL (decl) && ! TREE_USED (decl)) + /* Do not emit unused decls. This is not just an + optimization. We really do not want to emit + __PRETTY_FUNCTION__ etc, if they're never used. */ + DECL_IGNORED_P (decl) = 1; + else + make_rtl_for_local_static (decl); + } } break;