re PR c++/82084 (ICE: constructing wstring with -O3)
authorRichard Biener <rguenther@suse.de>
Tue, 5 Sep 2017 12:58:00 +0000 (12:58 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 5 Sep 2017 12:58:00 +0000 (12:58 +0000)
2017-09-05  Richard Biener  <rguenther@suse.de>

PR tree-optimization/82084
* fold-const.c (can_native_encode_string_p): Handle wide characters.

From-SVN: r251711

gcc/ChangeLog
gcc/fold-const.c

index 5f60fe276908e516a50bdf1111feaf14ff8d09d3..7f5b384bca4bd160ca11e20bce60131dbd15ed1a 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-05  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/82084
+       * fold-const.c (can_native_encode_string_p): Handle wide characters.
+
 2017-09-05  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/82102
index 490483067eef7df3a8b2408f76ed9bd1bf930720..0cb2301a518d2fa3f2b6cc84f6d9f3a8a9841406 100644 (file)
@@ -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;