aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-04-12 12:25:59 -0400
committerJason Merrill <jason@gcc.gnu.org>2019-04-12 12:25:59 -0400
commit3d8695f529a41a639c6cc2a51cbcec7c8b243bc1 (patch)
tree11dd1e42b504792ecf05b7fcc542b4d3d9c3d619 /gcc
parent76416d899cb6d26088a9cd22da5a23914fec2ce6 (diff)
downloadgcc-3d8695f529a41a639c6cc2a51cbcec7c8b243bc1.zip
gcc-3d8695f529a41a639c6cc2a51cbcec7c8b243bc1.tar.gz
gcc-3d8695f529a41a639c6cc2a51cbcec7c8b243bc1.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/call.c1
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist-pmf1.C20
3 files changed, 26 insertions, 0 deletions
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 <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
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 <class T>
+bool f()
+{
+ ftype p = ftype{};
+ return p;
+}
+
+int main()
+{
+ f<int>();
+}