From 54c430044ba9a35a590e591108b184535eba5763 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 5 Sep 2017 12:58:00 +0000 Subject: re PR c++/82084 (ICE: constructing wstring with -O3) 2017-09-05 Richard Biener PR tree-optimization/82084 * fold-const.c (can_native_encode_string_p): Handle wide characters. From-SVN: r251711 --- gcc/ChangeLog | 5 +++++ gcc/fold-const.c | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5f60fe2..7f5b384 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2017-09-05 Richard Biener + PR tree-optimization/82084 + * fold-const.c (can_native_encode_string_p): Handle wide characters. + +2017-09-05 Richard Biener + PR tree-optimization/82102 * tree-ssa-pre.c (fini_eliminate): Check if lhs is NULL. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 4904830..0cb2301 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7489,10 +7489,11 @@ can_native_encode_string_p (const_tree expr) { tree type = TREE_TYPE (expr); - if (TREE_CODE (type) != ARRAY_TYPE + /* Wide-char strings are encoded in target byte-order so native + encoding them is trivial. */ + if (BITS_PER_UNIT != CHAR_BIT + || TREE_CODE (type) != ARRAY_TYPE || TREE_CODE (TREE_TYPE (type)) != INTEGER_TYPE - || (GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (type))) - != BITS_PER_UNIT) || !tree_fits_shwi_p (TYPE_SIZE_UNIT (type))) return false; return true; -- cgit v1.1