diff options
author | Jason Merrill <jason@yorick.cygnus.com> | 1998-10-04 20:10:49 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 1998-10-04 16:10:49 -0400 |
commit | 5f2c99c43b76e7d4bc46e445eaa04201c827ffe2 (patch) | |
tree | 2ec58476dda414b813c07876ff61079e5009558b | |
parent | b4558b577c353fad6143feb814c54d8e99931a7b (diff) | |
download | gcc-5f2c99c43b76e7d4bc46e445eaa04201c827ffe2.zip gcc-5f2c99c43b76e7d4bc46e445eaa04201c827ffe2.tar.gz gcc-5f2c99c43b76e7d4bc46e445eaa04201c827ffe2.tar.bz2 |
pt.c (pop_tinst_level): Call extract_interface_info.
* pt.c (pop_tinst_level): Call extract_interface_info.
(instantiate_decl): Don't save and restore file position.
* decl.c (cp_finish_decl): Make statics in extern inlines and
templates common, if possible and the target doesn't support weak
symbols.
From-SVN: r22824
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/decl.c | 42 | ||||
-rw-r--r-- | gcc/cp/pt.c | 9 |
3 files changed, 45 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bd28802..d803d39 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,12 @@ 1998-10-04 Jason Merrill <jason@yorick.cygnus.com> + * pt.c (pop_tinst_level): Call extract_interface_info. + (instantiate_decl): Don't save and restore file position. + + * decl.c (cp_finish_decl): Make statics in extern inlines and + templates common, if possible and the target doesn't support weak + symbols. + * decl.c (grokdeclarator): Remove redundant calls to build_type_variant and some duplicated code. * sig.c (build_signature_reference_type): Only take the type parm. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 9c4e08a..cae7256 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7298,20 +7298,52 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags) if (was_temp) end_temporary_allocation (); - /* Extern inline function static data has external linkage. - Instead of trying to deal with that, we disable inlining of - such functions. The ASM_WRITTEN check is to avoid hitting this - for __FUNCTION__. */ + /* Static data in a function with comdat linkage also has comdat + linkage. */ if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) + /* Don't mess with __FUNCTION__. */ && ! TREE_ASM_WRITTEN (decl) && current_function_decl && DECL_CONTEXT (decl) == current_function_decl - && DECL_THIS_INLINE (current_function_decl) + && (DECL_THIS_INLINE (current_function_decl) + || DECL_TEMPLATE_INSTANTIATION (current_function_decl)) && TREE_PUBLIC (current_function_decl)) { + /* Rather than try to get this right with inlining, we suppress + inlining of such functions. */ current_function_cannot_inline = "function with static variable cannot be inline"; + + /* If flag_weak, we don't need to mess with this, as we can just + make the function weak, and let it refer to its unique local + copy. This works because we don't allow the function to be + inlined. */ + if (! flag_weak) + { + if (DECL_INTERFACE_KNOWN (current_function_decl)) + { + TREE_PUBLIC (decl) = 1; + DECL_EXTERNAL (decl) = DECL_EXTERNAL (current_function_decl); + } + else if (DECL_INITIAL (decl) == NULL_TREE + || DECL_INITIAL (decl) == error_mark_node) + { + TREE_PUBLIC (decl) = 1; + DECL_COMMON (decl) = 1; + } + /* else we lose. We can only do this if we can use common, + which we can't if it has been initialized. */ + + if (TREE_PUBLIC (decl)) + DECL_ASSEMBLER_NAME (decl) + = build_static_name (current_function_decl, DECL_NAME (decl)); + else if (! DECL_ARTIFICIAL (decl)) + { + 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; + } + } } else if (TREE_CODE (decl) == VAR_DECL diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e08eaff..1545c06 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3995,6 +3995,7 @@ pop_tinst_level () this instantiation. */ lineno = old->line; input_filename = old->file; + extract_interface_info (); current_tinst_level = old->next; old->next = free_tinst_level; @@ -8004,8 +8005,6 @@ instantiate_decl (d) tree gen_tmpl; int nested = in_function_p (); int pattern_defined; - int line = lineno; - char *file = input_filename; /* This function should only be used to instantiate templates for functions and static member variables. */ @@ -8142,9 +8141,6 @@ instantiate_decl (d) { /* Defer all templates except inline functions used in another function. */ - lineno = line; - input_filename = file; - if (at_eof && !pattern_defined && DECL_EXPLICIT_INSTANTIATION (d)) /* [temp.explicit] @@ -8217,9 +8213,6 @@ instantiate_decl (d) } out: - lineno = line; - input_filename = file; - pop_from_top_level (); pop_tinst_level (); |