PR c++/80485 - inline function non-zero address.

* symtab.c (nonzero_address): Check DECL_COMDAT.

From-SVN: r260762
This commit is contained in:
Jason Merrill 2018-05-25 12:44:55 -04:00 committed by Jason Merrill
parent 18b119378a
commit f22ed1ed2a
3 changed files with 24 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2018-05-25 Jason Merrill <jason@redhat.com>
PR c++/80485 - inline function non-zero address.
* symtab.c (nonzero_address): Check DECL_COMDAT.
2018-05-25 Uros Bizjak <ubizjak@gmail.com>
PR target/83628

View File

@ -1959,11 +1959,11 @@ symtab_node::nonzero_address ()
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
/* If target is defined and either comdat or 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 may
be re-defined by NULL. */
if (definition && !DECL_EXTERNAL (decl)
if (definition && (!DECL_EXTERNAL (decl) || DECL_COMDAT (decl))
&& (flag_delete_null_pointer_checks || !DECL_WEAK (decl)))
{
if (!DECL_WEAK (decl))

View File

@ -0,0 +1,15 @@
// PR c++/80485
// { dg-do compile { target c++11 } }
struct dummy {
void nonnull() {};
void nonnull2();
};
typedef void (dummy::*safe_bool)();
constexpr safe_bool a = &dummy::nonnull;
constexpr safe_bool b = &dummy::nonnull2;
static_assert( static_cast<bool>( a ), "" );
static_assert( static_cast<bool>( b ), "" );