diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1b0b72bc6dd..926bb7b4edf 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -6,6 +6,11 @@ ABI version, make the later mangled name an alias. * method.c (make_alias_for): Copy DECL_ARGUMENTS. * Make-lang.in (mangle.o): Depend on cgraph.h. + * method.c (make_alias_for): Handle VAR_DECL, too. + * decl2.c (vague_linkage_p): Rename from vague_linkage_fn_p. + * tree.c (no_linkage_check): Adjust. + * decl.c (maybe_commonize_var): Adjust. + * cp-tree.h: Adjust. 2010-03-01 Marco Poletti diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 4e1815f90fb..5604a9d442d 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4735,7 +4735,7 @@ extern tree build_memfn_type (tree, tree, cp_cv_quals); extern tree change_return_type (tree, tree); extern void maybe_retrofit_in_chrg (tree); extern void maybe_make_one_only (tree); -extern bool vague_linkage_fn_p (tree); +extern bool vague_linkage_p (tree); extern void grokclassfn (tree, tree, enum overload_flags); extern tree grok_array_decl (tree, tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 3eec0c7b48c..67377b0fc8a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4642,7 +4642,7 @@ maybe_commonize_var (tree decl) /* Don't mess with __FUNCTION__. */ && ! DECL_ARTIFICIAL (decl) && DECL_FUNCTION_SCOPE_P (decl) - && vague_linkage_fn_p (DECL_CONTEXT (decl))) + && vague_linkage_p (DECL_CONTEXT (decl))) { if (flag_weak) { diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index c5b6e874ed2..81d7ee3212f 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1642,20 +1642,21 @@ maybe_make_one_only (tree decl) } } -/* Returns true iff DECL, a FUNCTION_DECL, has vague linkage. This - predicate will give the right answer during parsing of the function, - which other tests may not. */ +/* Returns true iff DECL, a FUNCTION_DECL or VAR_DECL, has vague linkage. + This predicate will give the right answer during parsing of the + function, which other tests may not. */ bool -vague_linkage_fn_p (tree fn) +vague_linkage_p (tree decl) { /* Unfortunately, import_export_decl has not always been called before the function is processed, so we cannot simply check DECL_COMDAT. */ - return (DECL_COMDAT (fn) - || ((DECL_DECLARED_INLINE_P (fn) - || DECL_TEMPLATE_INSTANTIATION (fn)) - && TREE_PUBLIC (fn))); + return (DECL_COMDAT (decl) + || (((TREE_CODE (decl) == FUNCTION_DECL + && DECL_DECLARED_INLINE_P (decl)) + || DECL_TEMPLATE_INSTANTIATION (decl)) + && TREE_PUBLIC (decl))); } /* Determine whether or not we want to specifically import or export CTYPE, diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 9478092daf6..02b8a82c26b 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -3083,7 +3083,7 @@ mangle_decl (const tree decl) DECL_IGNORED_P (alias) = 1; TREE_PUBLIC (alias) = TREE_PUBLIC (decl); DECL_VISIBILITY (alias) = DECL_VISIBILITY (decl); - if (vague_linkage_fn_p (decl)) + if (vague_linkage_p (decl)) DECL_WEAK (alias) = 1; cgraph_same_body_alias (alias, decl); } diff --git a/gcc/cp/method.c b/gcc/cp/method.c index c25cedba178..a93ad068e52 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -207,34 +207,38 @@ finish_thunk (tree thunk) static GTY (()) int thunk_labelno; -/* Create a static alias to function. */ +/* Create a static alias to target. */ tree -make_alias_for (tree function, tree newid) +make_alias_for (tree target, tree newid) { - tree alias = build_decl (DECL_SOURCE_LOCATION (function), - FUNCTION_DECL, newid, TREE_TYPE (function)); - DECL_LANG_SPECIFIC (alias) = DECL_LANG_SPECIFIC (function); + tree alias = build_decl (DECL_SOURCE_LOCATION (target), + TREE_CODE (target), newid, TREE_TYPE (target)); + DECL_LANG_SPECIFIC (alias) = DECL_LANG_SPECIFIC (target); cxx_dup_lang_specific_decl (alias); DECL_CONTEXT (alias) = NULL; - TREE_READONLY (alias) = TREE_READONLY (function); - TREE_THIS_VOLATILE (alias) = TREE_THIS_VOLATILE (function); + TREE_READONLY (alias) = TREE_READONLY (target); + TREE_THIS_VOLATILE (alias) = TREE_THIS_VOLATILE (target); TREE_PUBLIC (alias) = 0; DECL_INTERFACE_KNOWN (alias) = 1; DECL_NOT_REALLY_EXTERN (alias) = 1; - DECL_THIS_STATIC (alias) = 1; - DECL_SAVED_FUNCTION_DATA (alias) = NULL; - DECL_DESTRUCTOR_P (alias) = 0; - DECL_CONSTRUCTOR_P (alias) = 0; DECL_EXTERNAL (alias) = 0; DECL_ARTIFICIAL (alias) = 1; - DECL_PENDING_INLINE_P (alias) = 0; - DECL_DECLARED_INLINE_P (alias) = 0; DECL_USE_TEMPLATE (alias) = 0; DECL_TEMPLATE_INSTANTIATED (alias) = 0; DECL_TEMPLATE_INFO (alias) = NULL; - DECL_INITIAL (alias) = error_mark_node; - DECL_ARGUMENTS (alias) = copy_list (DECL_ARGUMENTS (target)); + if (TREE_CODE (alias) == FUNCTION_DECL) + { + DECL_SAVED_FUNCTION_DATA (alias) = NULL; + DECL_DESTRUCTOR_P (alias) = 0; + DECL_CONSTRUCTOR_P (alias) = 0; + DECL_PENDING_INLINE_P (alias) = 0; + DECL_DECLARED_INLINE_P (alias) = 0; + DECL_INITIAL (alias) = error_mark_node; + DECL_ARGUMENTS (alias) = copy_list (DECL_ARGUMENTS (target)); + } + else + TREE_STATIC (alias) = 1; TREE_ADDRESSABLE (alias) = 1; TREE_USED (alias) = 1; SET_DECL_ASSEMBLER_NAME (alias, DECL_NAME (alias)); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 31b54f6ce9c..9867d2efb66 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1607,7 +1607,7 @@ no_linkage_check (tree t, bool relaxed_p) return no_linkage_check (TYPE_CONTEXT (t), relaxed_p); else if (TREE_CODE (r) == FUNCTION_DECL) { - if (!relaxed_p || !vague_linkage_fn_p (r)) + if (!relaxed_p || !vague_linkage_p (r)) return t; else r = CP_DECL_CONTEXT (r);