From 50867d20f4356714df1392a35240db8712c878f4 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 20 Dec 2018 18:31:05 +0100 Subject: [PATCH] cp-tree.h (cp_fully_fold_init): Declare. * cp-tree.h (cp_fully_fold_init): Declare. * cp-gimplify.c (cp_fully_fold_init): New function. * typeck2.c (split_nonconstant_init, store_init_value): Use it instead of cp_fully_fold. From-SVN: r267305 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/cp-gimplify.c | 14 ++++++++++++++ gcc/cp/cp-tree.h | 1 + gcc/cp/typeck2.c | 4 ++-- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 01d2f57..c1b7bba 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-12-20 Jakub Jelinek + + * cp-tree.h (cp_fully_fold_init): Declare. + * cp-gimplify.c (cp_fully_fold_init): New function. + * typeck2.c (split_nonconstant_init, store_init_value): Use it + instead of cp_fully_fold. + 2018-12-19 Segher Boessenkool * parser.c (cp_parser_asm_definition): Do not allow any asm qualifiers diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index d27e39c..9d848ea 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -2171,6 +2171,20 @@ cp_fully_fold (tree x) return cp_fold_rvalue (x); } +/* Likewise, but also fold recursively, which cp_fully_fold doesn't perform + in some cases. */ + +tree +cp_fully_fold_init (tree x) +{ + if (processing_template_decl) + return x; + x = cp_fully_fold (x); + hash_set pset; + cp_walk_tree (&x, cp_fold_r, &pset, NULL); + return x; +} + /* c-common interface to cp_fold. If IN_INIT, this is in a static initializer and certain changes are made to the folding done. Or should be (FIXME). We never touch maybe_const, as it is only used for the C front-end diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 8a95095..f6b7c6e 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -7544,6 +7544,7 @@ extern bool cxx_omp_privatize_by_reference (const_tree); extern bool cxx_omp_disregard_value_expr (tree, bool); extern void cp_fold_function (tree); extern tree cp_fully_fold (tree); +extern tree cp_fully_fold_init (tree); extern void clear_fold_cache (void); extern tree lookup_hotness_attribute (tree); extern tree process_stmt_hotness_attribute (tree); diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 209832b..cc9bf02 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -755,7 +755,7 @@ split_nonconstant_init (tree dest, tree init) init = TARGET_EXPR_INITIAL (init); if (TREE_CODE (init) == CONSTRUCTOR) { - init = cp_fully_fold (init); + init = cp_fully_fold_init (init); code = push_stmt_list (); if (split_nonconstant_init_1 (dest, init)) init = NULL_TREE; @@ -863,7 +863,7 @@ store_init_value (tree decl, tree init, vec** cleanups, int flags) if (!const_init) value = oldval; } - value = cp_fully_fold (value); + value = cp_fully_fold_init (value); /* Handle aggregate NSDMI in non-constant initializers, too. */ value = replace_placeholders (value, decl); -- 2.7.4