aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2023-01-09 23:41:20 +0100
committerJakub Jelinek <jakub@redhat.com>2023-01-09 23:41:20 +0100
commit01ea66a6c56e53163d9430f4d87615d570848aa8 (patch)
tree70ce38fd433a7df19cbc46482b8dcea158ea5443 /gcc/cp
parent799e2e7f023784b9cdcebfe5751d183d125b2bd8 (diff)
downloadgcc-01ea66a6c56e53163d9430f4d87615d570848aa8.zip
gcc-01ea66a6c56e53163d9430f4d87615d570848aa8.tar.gz
gcc-01ea66a6c56e53163d9430f4d87615d570848aa8.tar.bz2
c++: Only do maybe_init_list_as_range optimization if !processing_template_decl [PR108047]
The last testcase in this patch ICEs, because maybe_init_list_as_range -> maybe_init_list_as_array calls maybe_constant_init in: /* Don't do this if the conversion would be constant. */ first = maybe_constant_init (first); if (TREE_CONSTANT (first)) return NULL_TREE; but maybe_constant_init shouldn't be called when processing_template_decl. While we could replace that call with fold_non_dependent_init, my limited understanding is that this is an optimization and even if we don't optimize it when processing_template_decl, build_user_type_conversion_1 will be called again during instantiation with !processing_template_decl if it is every instantiated and we can do the optimization only then. 2023-01-09 Jakub Jelinek <jakub@redhat.com> PR c++/105838 PR c++/108047 PR c++/108266 * call.cc (maybe_init_list_as_range): Always return NULL_TREE if processing_template_decl. * g++.dg/tree-ssa/initlist-opt2.C: New test. * g++.dg/tree-ssa/initlist-opt3.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/call.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index c25df17..bd174b8 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -4285,7 +4285,8 @@ maybe_init_list_as_array (tree elttype, tree init)
static tree
maybe_init_list_as_range (tree fn, tree expr)
{
- if (BRACE_ENCLOSED_INITIALIZER_P (expr)
+ if (!processing_template_decl
+ && BRACE_ENCLOSED_INITIALIZER_P (expr)
&& is_list_ctor (fn)
&& decl_in_std_namespace_p (fn))
{