summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-16 14:12:48 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-16 14:12:48 +0000
commit76d7e125d09ee195d1d976159e6f5f1524976bee (patch)
tree22195195101e0355f7f0fa98a44461a2b33aabda
parent18a7d8073e62c7dafc7c2b04546b6e1169067ee2 (diff)
downloadgcc-76d7e125d09ee195d1d976159e6f5f1524976bee.tar.gz
PR c++/83227 - C++17 ICE with init-list derived-to-base conversion.
* call.c (convert_like_real): Don't use the copy-list-initialization shortcut for ck_base. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@257738 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/call.c9
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist98.C17
3 files changed, 26 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4fb837987ec..cfdc374afd5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2018-02-16 Jason Merrill <jason@redhat.com>
+ PR c++/83227 - C++17 ICE with init-list derived-to-base conversion.
+ * call.c (convert_like_real): Don't use the copy-list-initialization
+ shortcut for ck_base.
+
PR c++/84045 - ICE with typedef and noexcept.
* except.c (build_noexcept_spec): Use strip_typedefs_expr.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index d35e844fd40..aa1d8210edf 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6878,6 +6878,11 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
&& DECL_INHERITED_CTOR (current_function_decl))
return expr;
+ if (TREE_CODE (expr) == TARGET_EXPR
+ && TARGET_EXPR_LIST_INIT_P (expr))
+ /* Copy-list-initialization doesn't actually involve a copy. */
+ return expr;
+
/* Fall through. */
case ck_base:
if (convs->kind == ck_base && !convs->need_temporary_p)
@@ -6903,10 +6908,6 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
flags |= LOOKUP_ONLYCONVERTING;
if (convs->rvaluedness_matches_p)
flags |= LOOKUP_PREFER_RVALUE;
- if (TREE_CODE (expr) == TARGET_EXPR
- && TARGET_EXPR_LIST_INIT_P (expr))
- /* Copy-list-initialization doesn't actually involve a copy. */
- return expr;
expr = build_temp (expr, totype, flags, &diag_kind, complain);
if (diag_kind && complain)
{
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist98.C b/gcc/testsuite/g++.dg/cpp0x/initlist98.C
new file mode 100644
index 00000000000..4f2fcd20219
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist98.C
@@ -0,0 +1,17 @@
+// PR c++/83227
+// { dg-do compile { target c++11 } }
+
+#include <initializer_list>
+
+template <typename d> struct f {
+ f(std::initializer_list<d>) {}
+};
+
+struct h {};
+struct i : h {
+ i();
+};
+void foo(f<h>);
+int main() {
+ foo({i{}});
+}