From: Marek Polacek Date: Wed, 13 Feb 2019 21:39:18 +0000 (+0000) Subject: PR c++/89297 - ICE with OVERLOAD in template. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f83fad402e6d6503a2322977837a9dba7edf68b8;p=gcc.git PR c++/89297 - ICE with OVERLOAD in template. * semantics.c (finish_compound_literal): Call instantiate_non_dependent_expr_sfinae. * g++.dg/cpp0x/initlist113.C: New test. From-SVN: r268854 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ef51d9a46e6..d6d1f595f1c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-02-13 Marek Polacek + + PR c++/89297 - ICE with OVERLOAD in template. + * semantics.c (finish_compound_literal): Call + instantiate_non_dependent_expr_sfinae. + 2019-02-13 Alexandre Oliva PR c++/86379 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 89ea438ebee..aa5a163dd64 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2827,9 +2827,13 @@ finish_compound_literal (tree type, tree compound_literal, return error_mark_node; compound_literal = reshape_init (type, compound_literal, complain); if (SCALAR_TYPE_P (type) - && !BRACE_ENCLOSED_INITIALIZER_P (compound_literal) - && !check_narrowing (type, compound_literal, complain)) - return error_mark_node; + && !BRACE_ENCLOSED_INITIALIZER_P (compound_literal)) + { + tree t = instantiate_non_dependent_expr_sfinae (compound_literal, + complain); + if (!check_narrowing (type, t, complain)) + return error_mark_node; + } if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == NULL_TREE) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 74d0ad3e0e6..c4aef56378b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-02-13 Marek Polacek + + PR c++/89297 - ICE with OVERLOAD in template. + * g++.dg/cpp0x/initlist113.C: New test. + 2019-02-13 Alexandre Oliva PR c++/86379 diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist113.C b/gcc/testsuite/g++.dg/cpp0x/initlist113.C new file mode 100644 index 00000000000..0b7e7ff606a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist113.C @@ -0,0 +1,11 @@ +// PR c++/89297 +// { dg-do compile { target c++11 } } + +int id(int v) { return v; } +float id(float v) { return v; } + +template +int foo(int v) +{ + return int{id(v)}; +}