]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-lex.c (lex_string): Use charwidth to compute bytemask.
authorJakub Jelinek <jakub@redhat.com>
Tue, 12 Sep 2000 23:45:51 +0000 (01:45 +0200)
committerUlrich Drepper <drepper@gcc.gnu.org>
Tue, 12 Sep 2000 23:45:51 +0000 (23:45 +0000)
* c-lex.c (lex_string): Use charwidth to compute bytemask.
  * expr.c (expand_expr): Don't optimize constant array references
  initialized with wide string constants.

From-SVN: r36380

gcc/ChangeLog
gcc/c-lex.c
gcc/expr.c

index 46e9945efb78ef4a0e3963748b3ea9aa1f3c4f4c..c6e8733ca9bcaf5a3263533d16adafa02b445919 100644 (file)
@@ -1,3 +1,9 @@
+2000-09-12  Jakub Jelinek  <jakub@redhat.com>
+
+       * c-lex.c (lex_string): Use charwidth to compute bytemask.
+       * expr.c (expand_expr): Don't optimize constant array references
+       initialized with wide string constants.
+
 2000-09-13  Michael Hayes  <mhayes@cygnus.com>
 
         * loop.c (note_set_pseudo_multiple_uses): Correct.
index fa5c7a79cef61677ff8b5e47a353b6719b6a8725..f9c5cb432f94af8739f8628b8a03adf0c0103ee6 100644 (file)
@@ -2381,7 +2381,7 @@ lex_string (str, len, wide)
       if (wide)
        {
          unsigned charwidth = TYPE_PRECISION (char_type_node);
-         unsigned bytemask = (1 << width) - 1;
+         unsigned bytemask = (1 << charwidth) - 1;
          int byte;
 
          for (byte = 0; byte < WCHAR_BYTES; ++byte)
index 9c4237bb43d5cb7b06c50bda1ca207cc670941d3..baa4ef134b797a325d3a1fe17e95373a387b54aa 100644 (file)
@@ -6619,9 +6619,16 @@ expand_expr (exp, target, tmode, modifier)
                else if (TREE_CODE (init) == STRING_CST
                         && 0 > compare_tree_int (index,
                                                  TREE_STRING_LENGTH (init)))
-                 return (GEN_INT
-                         (TREE_STRING_POINTER
-                          (init)[TREE_INT_CST_LOW (index)]));
+                 {
+                   tree type = TREE_TYPE (TREE_TYPE (init));
+                   enum machine_mode mode = TYPE_MODE (type);
+
+                   if (GET_MODE_CLASS (mode) == MODE_INT
+                       && GET_MODE_SIZE (mode) == 1)
+                     return (GEN_INT
+                             (TREE_STRING_POINTER
+                              (init)[TREE_INT_CST_LOW (index)]));
+                 }
              }
          }
       }