Message ID | CAMqJFCpPHH+Uv=h0XZFygo4CyvYF+yz8c8+8Vdr7nbuaemvpiA@mail.gmail.com |
---|---|
State | New |
Headers | show |
Series | RFA: Don't squash target character arrays into a narrower host string | expand |
On Sun, May 16, 2021 at 11:12 PM Joern Rennecke <joern.rennecke@embecosm.com> wrote: > > braced_list_to_string creates a host string, so it's not suitable when > e.g. the host > has 8 bit chars, but the target has 16 bit chars. > > The attached patch checks if host and target char sizes are different > and in that case > falls back to leaving the array as an array. The check might be better suited in braced_list_to_string itself (just in case we get more uses). OK with that change. Richard. > Bootstrapped on x86_64-pc-linux-gnu. > > FWIW, we also have patches for cpplib / lexer / parser char and string > handling to make 8 -> 16 bit char cross-compiling work, but they can't > be ported forward easily because the parser has changed since gcc9.
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 7bd799d1825..5e87d8ba4df 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -9169,7 +9169,7 @@ braced_lists_to_strings (tree type, tree ctor, bool member) return ctor; if ((TREE_CODE (ttp) == ARRAY_TYPE || TREE_CODE (ttp) == INTEGER_TYPE) - && TYPE_STRING_FLAG (ttp)) + && TYPE_STRING_FLAG (ttp) && TYPE_PRECISION (char_type_node) == CHAR_BIT) return braced_list_to_string (type, ctor, member); code = TREE_CODE (ttp);