From 3d8695f529a41a639c6cc2a51cbcec7c8b243bc1 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 12 Apr 2019 12:25:59 -0400 Subject: 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 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/call.c | 1 + gcc/testsuite/g++.dg/cpp0x/initlist-pmf1.C | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist-pmf1.C (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8e63fda..8b2e757 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-04-12 Jason Merrill + + * call.c (null_member_pointer_value_p): Handle an empty CONSTRUCTOR + of PMF type. + 2019-04-12 Marek Polacek * except.c (build_noexcept_spec): Use build_converted_constant_bool_expr diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 519dad9..9582345 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -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); diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-pmf1.C b/gcc/testsuite/g++.dg/cpp0x/initlist-pmf1.C new file mode 100644 index 0000000..3035fef --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-pmf1.C @@ -0,0 +1,20 @@ +// { dg-do compile { target c++11 } } + +struct A +{ + void f(); +}; + +using ftype = decltype(&A::f); + +template +bool f() +{ + ftype p = ftype{}; + return p; +} + +int main() +{ + f(); +} -- cgit v1.1