https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93210
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Author: jakub Date: Fri Jan 10 21:18:22 2020 New Revision: 280141 URL: https://gcc.gnu.org/viewcvs?rev=280141&root=gcc&view=rev Log: PR tree-optimization/93210 * fold-const.h (native_encode_initializer, can_native_interpret_type_p): Declare. * fold-const.c (native_encode_string): Fix up handling with off != -1, simplify. (native_encode_initializer): New function, moved from dwarf2out.c. Adjust to native_encode_expr compatible arguments, including dry-run and partial extraction modes. Don't handle STRING_CST. (can_native_interpret_type_p): No longer static. * gimple-fold.c (fold_ctor_reference): For native_encode_expr, verify offset / BITS_PER_UNIT fits into int and don't call it if can_native_interpret_type_p fails. If suboff is NULL and for CONSTRUCTOR fold_{,non}array_ctor_reference returns NULL, retry with native_encode_initializer. (fold_const_aggregate_ref_1): Formatting fix. * dwarf2out.c (native_encode_initializer): Moved to fold-const.c. (tree_add_const_value_attribute): Adjust caller. * gcc.dg/pr93210.c: New test. * g++.dg/opt/pr93210.C: New test. Added: trunk/gcc/testsuite/g++.dg/opt/pr93210.C trunk/gcc/testsuite/gcc.dg/pr93210.c Modified: trunk/gcc/ChangeLog trunk/gcc/dwarf2out.c trunk/gcc/fold-const.c trunk/gcc/fold-const.h trunk/gcc/gimple-fold.c trunk/gcc/testsuite/ChangeLog