summaryrefslogtreecommitdiff
path: root/gcc/symtab.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2014-09-19 23:56:52 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2014-09-19 23:56:52 +0000
commit8e857c4151f8f0aae992f9b5f22ee5b4c1cc1c73 (patch)
treed7d5f6d00208bddb323b80ac27eed3ded29bed4a /gcc/symtab.c
parent20a52496a54ae8916e2bfc4d38aec95bb3592242 (diff)
downloadgcc-8e857c4151f8f0aae992f9b5f22ee5b4c1cc1c73.tar.gz
PR c++/61825
* c-family/c-common.c (handle_alias_ifunc_attribute): Check that visibility change is possible (handle_weakref_attribute): Likewise. * cgraph.h (symtab_node): Add method get_create and field refuse_visibility_changes. (symtab_node::get_create): New method. * fold-const.c (tree_single_nonzero_warnv_p): Use get_create. * varasm.c (mark_weak): Verify that visibility change is possible. * gcc.dg/tree-ssa/nonzero-1.c: Require error to be output. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@215409 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/symtab.c')
-rw-r--r--gcc/symtab.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/gcc/symtab.c b/gcc/symtab.c
index 792b3b50ea6..9590fc83dd2 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -1811,9 +1811,9 @@ bool
symtab_node::nonzero_address ()
{
/* Weakrefs may be NULL when their target is not defined. */
- if (this->alias && this->weakref)
+ if (alias && weakref)
{
- if (this->analyzed)
+ if (analyzed)
{
symtab_node *target = ultimate_alias_target ();
@@ -1828,7 +1828,7 @@ symtab_node::nonzero_address ()
could be useful to eliminate the NULL pointer checks in LTO
programs. */
if (target->definition && !DECL_EXTERNAL (target->decl))
- return true;
+ return true;
if (target->resolution != LDPR_UNKNOWN
&& target->resolution != LDPR_UNDEF
&& flag_delete_null_pointer_checks)
@@ -1847,22 +1847,28 @@ symtab_node::nonzero_address ()
Those are handled by later check for definition.
When parsing, beware the cases when WEAK attribute is added later. */
- if (!DECL_WEAK (this->decl)
- && flag_delete_null_pointer_checks
- && symtab->state > PARSING)
- return true;
+ if (!DECL_WEAK (decl)
+ && flag_delete_null_pointer_checks)
+ {
+ refuse_visibility_changes = true;
+ return true;
+ }
/* If target is defined and not extern, we know it will be output and thus
it will bind to non-NULL.
Play safe for flag_delete_null_pointer_checks where weak definition maye
be re-defined by NULL. */
- if (this->definition && !DECL_EXTERNAL (this->decl)
- && (flag_delete_null_pointer_checks || !DECL_WEAK (this->decl)))
- return true;
+ if (definition && !DECL_EXTERNAL (decl)
+ && (flag_delete_null_pointer_checks || !DECL_WEAK (decl)))
+ {
+ if (!DECL_WEAK (decl))
+ refuse_visibility_changes = true;
+ return true;
+ }
/* As the last resort, check the resolution info. */
- if (this->resolution != LDPR_UNKNOWN
- && this->resolution != LDPR_UNDEF
+ if (resolution != LDPR_UNKNOWN
+ && resolution != LDPR_UNDEF
&& flag_delete_null_pointer_checks)
return true;
return false;