re PR c++/12909 (ambiguity in mangling vector types)

PR c++/12909
	* 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.
	* mangle.c (mangle_decl): Adjust.
	* cp-tree.h: Adjust.

From-SVN: r157202
This commit is contained in:
Jason Merrill 2010-03-03 14:01:46 -05:00 committed by Jason Merrill
parent 58a15cf8ee
commit d6dcdbd5f6
7 changed files with 37 additions and 27 deletions

View File

@ -6,6 +6,11 @@
ABI version, make the later mangled name an alias. ABI version, make the later mangled name an alias.
* method.c (make_alias_for): Copy DECL_ARGUMENTS. * method.c (make_alias_for): Copy DECL_ARGUMENTS.
* Make-lang.in (mangle.o): Depend on cgraph.h. * 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 <poletti.marco@gmail.com> 2010-03-01 Marco Poletti <poletti.marco@gmail.com>

View File

@ -4735,7 +4735,7 @@ extern tree build_memfn_type (tree, tree, cp_cv_quals);
extern tree change_return_type (tree, tree); extern tree change_return_type (tree, tree);
extern void maybe_retrofit_in_chrg (tree); extern void maybe_retrofit_in_chrg (tree);
extern void maybe_make_one_only (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, extern void grokclassfn (tree, tree,
enum overload_flags); enum overload_flags);
extern tree grok_array_decl (tree, tree); extern tree grok_array_decl (tree, tree);

View File

@ -4642,7 +4642,7 @@ maybe_commonize_var (tree decl)
/* Don't mess with __FUNCTION__. */ /* Don't mess with __FUNCTION__. */
&& ! DECL_ARTIFICIAL (decl) && ! DECL_ARTIFICIAL (decl)
&& DECL_FUNCTION_SCOPE_P (decl) && DECL_FUNCTION_SCOPE_P (decl)
&& vague_linkage_fn_p (DECL_CONTEXT (decl))) && vague_linkage_p (DECL_CONTEXT (decl)))
{ {
if (flag_weak) if (flag_weak)
{ {

View File

@ -1642,20 +1642,21 @@ maybe_make_one_only (tree decl)
} }
} }
/* Returns true iff DECL, a FUNCTION_DECL, has vague linkage. This /* Returns true iff DECL, a FUNCTION_DECL or VAR_DECL, has vague linkage.
predicate will give the right answer during parsing of the function, This predicate will give the right answer during parsing of the
which other tests may not. */ function, which other tests may not. */
bool bool
vague_linkage_fn_p (tree fn) vague_linkage_p (tree decl)
{ {
/* Unfortunately, import_export_decl has not always been called /* Unfortunately, import_export_decl has not always been called
before the function is processed, so we cannot simply check before the function is processed, so we cannot simply check
DECL_COMDAT. */ DECL_COMDAT. */
return (DECL_COMDAT (fn) return (DECL_COMDAT (decl)
|| ((DECL_DECLARED_INLINE_P (fn) || (((TREE_CODE (decl) == FUNCTION_DECL
|| DECL_TEMPLATE_INSTANTIATION (fn)) && DECL_DECLARED_INLINE_P (decl))
&& TREE_PUBLIC (fn))); || DECL_TEMPLATE_INSTANTIATION (decl))
&& TREE_PUBLIC (decl)));
} }
/* Determine whether or not we want to specifically import or export CTYPE, /* Determine whether or not we want to specifically import or export CTYPE,

View File

@ -3083,7 +3083,7 @@ mangle_decl (const tree decl)
DECL_IGNORED_P (alias) = 1; DECL_IGNORED_P (alias) = 1;
TREE_PUBLIC (alias) = TREE_PUBLIC (decl); TREE_PUBLIC (alias) = TREE_PUBLIC (decl);
DECL_VISIBILITY (alias) = DECL_VISIBILITY (decl); DECL_VISIBILITY (alias) = DECL_VISIBILITY (decl);
if (vague_linkage_fn_p (decl)) if (vague_linkage_p (decl))
DECL_WEAK (alias) = 1; DECL_WEAK (alias) = 1;
cgraph_same_body_alias (alias, decl); cgraph_same_body_alias (alias, decl);
} }

View File

@ -207,34 +207,38 @@ finish_thunk (tree thunk)
static GTY (()) int thunk_labelno; static GTY (()) int thunk_labelno;
/* Create a static alias to function. */ /* Create a static alias to target. */
tree tree
make_alias_for (tree function, tree newid) make_alias_for (tree target, tree newid)
{ {
tree alias = build_decl (DECL_SOURCE_LOCATION (function), tree alias = build_decl (DECL_SOURCE_LOCATION (target),
FUNCTION_DECL, newid, TREE_TYPE (function)); TREE_CODE (target), newid, TREE_TYPE (target));
DECL_LANG_SPECIFIC (alias) = DECL_LANG_SPECIFIC (function); DECL_LANG_SPECIFIC (alias) = DECL_LANG_SPECIFIC (target);
cxx_dup_lang_specific_decl (alias); cxx_dup_lang_specific_decl (alias);
DECL_CONTEXT (alias) = NULL; DECL_CONTEXT (alias) = NULL;
TREE_READONLY (alias) = TREE_READONLY (function); TREE_READONLY (alias) = TREE_READONLY (target);
TREE_THIS_VOLATILE (alias) = TREE_THIS_VOLATILE (function); TREE_THIS_VOLATILE (alias) = TREE_THIS_VOLATILE (target);
TREE_PUBLIC (alias) = 0; TREE_PUBLIC (alias) = 0;
DECL_INTERFACE_KNOWN (alias) = 1; DECL_INTERFACE_KNOWN (alias) = 1;
DECL_NOT_REALLY_EXTERN (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_EXTERNAL (alias) = 0;
DECL_ARTIFICIAL (alias) = 1; DECL_ARTIFICIAL (alias) = 1;
DECL_PENDING_INLINE_P (alias) = 0;
DECL_DECLARED_INLINE_P (alias) = 0;
DECL_USE_TEMPLATE (alias) = 0; DECL_USE_TEMPLATE (alias) = 0;
DECL_TEMPLATE_INSTANTIATED (alias) = 0; DECL_TEMPLATE_INSTANTIATED (alias) = 0;
DECL_TEMPLATE_INFO (alias) = NULL; DECL_TEMPLATE_INFO (alias) = NULL;
DECL_INITIAL (alias) = error_mark_node; if (TREE_CODE (alias) == FUNCTION_DECL)
DECL_ARGUMENTS (alias) = copy_list (DECL_ARGUMENTS (target)); {
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_ADDRESSABLE (alias) = 1;
TREE_USED (alias) = 1; TREE_USED (alias) = 1;
SET_DECL_ASSEMBLER_NAME (alias, DECL_NAME (alias)); SET_DECL_ASSEMBLER_NAME (alias, DECL_NAME (alias));

View File

@ -1607,7 +1607,7 @@ no_linkage_check (tree t, bool relaxed_p)
return no_linkage_check (TYPE_CONTEXT (t), relaxed_p); return no_linkage_check (TYPE_CONTEXT (t), relaxed_p);
else if (TREE_CODE (r) == FUNCTION_DECL) else if (TREE_CODE (r) == FUNCTION_DECL)
{ {
if (!relaxed_p || !vague_linkage_fn_p (r)) if (!relaxed_p || !vague_linkage_p (r))
return t; return t;
else else
r = CP_DECL_CONTEXT (r); r = CP_DECL_CONTEXT (r);