mirror of git://gcc.gnu.org/git/gcc.git
PR c++/77775 - misoptimization of PMF comparison
* constexpr.c (cxx_eval_component_reference): Use name matching for PMFs. From-SVN: r240757
This commit is contained in:
parent
76b294d48d
commit
2db613e5d3
|
|
@ -1,3 +1,9 @@
|
||||||
|
2016-09-30 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
PR c++/77775
|
||||||
|
* constexpr.c (cxx_eval_component_reference): Use name matching
|
||||||
|
for PMFs.
|
||||||
|
|
||||||
2016-10-04 Jason Merrill <jason@redhat.com>
|
2016-10-04 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
Implement P0091R2, Template argument deduction for class templates.
|
Implement P0091R2, Template argument deduction for class templates.
|
||||||
|
|
|
||||||
|
|
@ -2315,9 +2315,13 @@ cxx_eval_component_reference (const constexpr_ctx *ctx, tree t,
|
||||||
}
|
}
|
||||||
if (*non_constant_p)
|
if (*non_constant_p)
|
||||||
return t;
|
return t;
|
||||||
|
bool pmf = TYPE_PTRMEMFUNC_P (TREE_TYPE (whole));
|
||||||
FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (whole), i, field, value)
|
FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (whole), i, field, value)
|
||||||
{
|
{
|
||||||
if (field == part)
|
/* Use name match for PMF fields, as a variant will have a
|
||||||
|
different FIELD_DECL with a different type. */
|
||||||
|
if (pmf ? DECL_NAME (field) == DECL_NAME (part)
|
||||||
|
: field == part)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
return value;
|
return value;
|
||||||
|
|
@ -2342,6 +2346,8 @@ cxx_eval_component_reference (const constexpr_ctx *ctx, tree t,
|
||||||
if (is_really_empty_class (TREE_TYPE (t)))
|
if (is_really_empty_class (TREE_TYPE (t)))
|
||||||
return build_constructor (TREE_TYPE (t), NULL);
|
return build_constructor (TREE_TYPE (t), NULL);
|
||||||
|
|
||||||
|
gcc_assert (DECL_CONTEXT (part) == TYPE_MAIN_VARIANT (TREE_TYPE (whole)));
|
||||||
|
|
||||||
if (CONSTRUCTOR_NO_IMPLICIT_ZERO (whole))
|
if (CONSTRUCTOR_NO_IMPLICIT_ZERO (whole))
|
||||||
{
|
{
|
||||||
/* 'whole' is part of the aggregate initializer we're currently
|
/* 'whole' is part of the aggregate initializer we're currently
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
// PR c++/77775
|
||||||
|
// { dg-options -fdump-tree-gimple }
|
||||||
|
// { dg-final { scan-tree-dump "== viewAdded" "gimple" { target c++11 } } }
|
||||||
|
|
||||||
|
namespace Sublime {
|
||||||
|
struct View;
|
||||||
|
struct AreaIndex;
|
||||||
|
struct Area {
|
||||||
|
void qt_static_metacall();
|
||||||
|
void viewAdded(AreaIndex *, View *);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
void Sublime::Area::qt_static_metacall() {
|
||||||
|
typedef void (Area::*_t)(AreaIndex *, View *);
|
||||||
|
if (*reinterpret_cast<_t *>(1) == _t(&Area::viewAdded))
|
||||||
|
__builtin_abort();
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue