Another small patchlet to prepare for implicit address spaces. We'll
modify char_array_type_node etc. to have an address space for nvptx, and
we'll need to be careful to retain it in fix_string_type.
gcc/c-family/
* c-common.c (fix_string_type): Get the element type from the value's
type if possible.
------------------------------------------------------------------------
===================================================================
@@ -960,27 +960,28 @@ fix_string_type (tree value)
int length = TREE_STRING_LENGTH (value);
int nchars;
tree e_type, i_type, a_type;
+ tree valtype = TREE_TYPE (value);
/* Compute the number of elements, for the array type. */
- if (TREE_TYPE (value) == char_array_type_node || !TREE_TYPE (value))
+ if (valtype == char_array_type_node || !valtype)
{
nchars = length;
- e_type = char_type_node;
+ e_type = valtype ? TREE_TYPE (valtype) : char_type_node;
}
- else if (TREE_TYPE (value) == char16_array_type_node)
+ else if (valtype == char16_array_type_node)
{
nchars = length / (TYPE_PRECISION (char16_type_node) / BITS_PER_UNIT);
- e_type = char16_type_node;
+ e_type = TREE_TYPE (valtype);
}
- else if (TREE_TYPE (value) == char32_array_type_node)
+ else if (valtype == char32_array_type_node)
{
nchars = length / (TYPE_PRECISION (char32_type_node) / BITS_PER_UNIT);
- e_type = char32_type_node;
+ e_type = TREE_TYPE (valtype);
}
else
{
nchars = length / (TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT);
- e_type = wchar_type_node;
+ e_type = TREE_TYPE (valtype);
}
/* C89 2.2.4.1, C99 5.2.4.1 (Translation limits). The analogous