Avoid ICE on pmf{} in template.

Now that we return the original CONSTRUCTOR from finish_compound_literal,
the call to null_member_pointer_value_p in tsubst_copy_and_build was getting
confused because the CONSTRUCTOR was still empty rather than a valid PMF
value.

	* call.c (null_member_pointer_value_p): Handle an empty CONSTRUCTOR
	of PMF type.

From-SVN: r270324
This commit is contained in:
Jason Merrill 2019-04-12 12:25:59 -04:00 committed by Jason Merrill
parent 76416d899c
commit 3d8695f529
3 changed files with 26 additions and 0 deletions

View file

@ -1,3 +1,8 @@
2019-04-12 Jason Merrill <jason@redhat.com>
* call.c (null_member_pointer_value_p): Handle an empty CONSTRUCTOR
of PMF type.
2019-04-12 Marek Polacek <polacek@redhat.com>
* except.c (build_noexcept_spec): Use build_converted_constant_bool_expr

View file

@ -569,6 +569,7 @@ null_member_pointer_value_p (tree t)
return false;
else if (TYPE_PTRMEMFUNC_P (type))
return (TREE_CODE (t) == CONSTRUCTOR
&& CONSTRUCTOR_NELTS (t)
&& integer_zerop (CONSTRUCTOR_ELT (t, 0)->value));
else if (TYPE_PTRDATAMEM_P (type))
return integer_all_onesp (t);

View file

@ -0,0 +1,20 @@
// { dg-do compile { target c++11 } }
struct A
{
void f();
};
using ftype = decltype(&A::f);
template <class T>
bool f()
{
ftype p = ftype{};
return p;
}
int main()
{
f<int>();
}